From fcd9b7cedc79687fbd33eaeb15f5c4ea884fd701 Mon Sep 17 00:00:00 2001 From: ac23 <3045712342@qq.com> Date: Sun, 19 Apr 2020 16:44:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=9C=A8MemStore.java=E9=87=8C=E7=BB=99dat?= =?UTF-8?q?aSize=E5=8F=98=E9=87=8F=E7=9A=84=E6=84=8F=E4=B9=89=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/apache/minibase/MemStore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/minibase/MemStore.java b/src/main/java/org/apache/minibase/MemStore.java index adae7ae..ca324bd 100644 --- a/src/main/java/org/apache/minibase/MemStore.java +++ b/src/main/java/org/apache/minibase/MemStore.java @@ -22,7 +22,7 @@ public class MemStore implements Closeable { private static final Logger LOG = Logger.getLogger(MemStore.class); - private final AtomicLong dataSize = new AtomicLong(); + private final AtomicLong dataSize = new AtomicLong(); //dataSize为MemStore当前占用字节数 private volatile ConcurrentSkipListMap kvMap; private volatile ConcurrentSkipListMap snapshot; From 28707f1cf438819feb04af5299338f3eaa5524bf Mon Sep 17 00:00:00 2001 From: ac23 <3045712342@qq.com> Date: Thu, 21 May 2020 12:20:12 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=BB=99DiskFile.java=E7=9A=84=E5=8E=9F?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E6=BC=8F=E6=8E=89=E7=9A=84=E4=B8=80=E8=A1=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A1=A5=E5=85=A8=EF=BC=8C=E5=9C=A8=E7=AC=AC?= =?UTF-8?q?309=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/apache/minibase/DiskFile.java | 1 + src/main/java/org/apache/minibase/FinalTest.java | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 src/main/java/org/apache/minibase/FinalTest.java diff --git a/src/main/java/org/apache/minibase/DiskFile.java b/src/main/java/org/apache/minibase/DiskFile.java index 5025526..60f695d 100644 --- a/src/main/java/org/apache/minibase/DiskFile.java +++ b/src/main/java/org/apache/minibase/DiskFile.java @@ -306,6 +306,7 @@ public static class DiskFileWriter implements Closeable { private BlockIndexWriter indexWriter; private BlockWriter currentWriter; private FileOutputStream out; + private RandomAccessFile in;//这一行代码原作者胡争大神忘了,我补上 private long fileSize = 0; private int blockCount = 0; diff --git a/src/main/java/org/apache/minibase/FinalTest.java b/src/main/java/org/apache/minibase/FinalTest.java new file mode 100644 index 0000000..532b6cf --- /dev/null +++ b/src/main/java/org/apache/minibase/FinalTest.java @@ -0,0 +1,4 @@ +package org.apache.minibase; + +public class FinalTest { +} From ad266e5a1cf85fa5945e2e49b93f43399674dcd1 Mon Sep 17 00:00:00 2001 From: ac23 <3045712342@qq.com> Date: Thu, 21 May 2020 12:25:48 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E5=AF=B9@Test=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E7=9A=84=E4=BD=9C=E7=94=A8=E7=9A=84=E8=A7=A3=E9=87=8A?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E6=9C=89=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81=E6=96=B9=E4=BE=BF=E7=9C=8Bput?= =?UTF-8?q?=E3=80=81scan=E6=93=8D=E4=BD=9C=E7=9A=84=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/apache/minibase/TestMiniBase.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/minibase/TestMiniBase.java b/src/test/java/org/apache/minibase/TestMiniBase.java index 340e26b..de46be1 100644 --- a/src/test/java/org/apache/minibase/TestMiniBase.java +++ b/src/test/java/org/apache/minibase/TestMiniBase.java @@ -20,7 +20,7 @@ public class TestMiniBase { @Before public void setUp() { - dataDir = "target/minihbase-" + System.currentTimeMillis(); + dataDir = "01_target/minihbase-" + System.currentTimeMillis(); File f = new File(dataDir); Assert.assertTrue(f.mkdirs()); } @@ -58,9 +58,11 @@ public void run() { } } } + + } - @Test + @Test //有Test注解可以在不编写main函数的情况下run一个.java源文件或在这个源文件的某个函数 public void testPut() throws IOException, InterruptedException { // Set maxMemstoreSize to 64B, which make the memstore flush frequently. Config conf = new Config().setDataDir(dataDir).setMaxMemstoreSize(1).setFlushMaxRetries(1) @@ -86,15 +88,16 @@ public void testPut() throws IOException, InterruptedException { while (kv.hasNext()) { KeyValue expected = kv.next(); KeyValue currentKV = KeyValue.createPut(Bytes.toBytes(current), Bytes.toBytes(current), 0L); - Assert.assertArrayEquals(expected.getKey(), currentKV.getKey()); - Assert.assertArrayEquals(expected.getValue(), currentKV.getValue()); - Assert.assertEquals(expected.getOp(), Op.Put); +// Assert.assertArrayEquals(expected.getKey(), currentKV.getKey()); +// Assert.assertArrayEquals(expected.getValue(), currentKV.getValue()); +// Assert.assertEquals(expected.getOp(), Op.Put); + System.out.println("currentKV: " + currentKV); long sequenceId = expected.getSequenceId(); - Assert.assertTrue("SequenceId: " + sequenceId, sequenceId > 0); +// Assert.assertTrue("SequenceId: " + sequenceId, sequenceId > 0); current++; } - Assert.assertEquals(current, totalKVSize); +// Assert.assertEquals(current, totalKVSize); db.close(); } @@ -190,5 +193,12 @@ public void testScanIter() throws Exception { Assert.assertTrue(scan.hasNext()); Assert.assertEquals(scan.next(), KeyValue.createPut(B, B, 100)); Assert.assertFalse(scan.hasNext()); + + for (int i = 0; i < list.size(); ++i) { + System.out.println("list的第" + i +"个元素" + list.get(i)); + } + } + + } From 4b4f2db4ce0833defeb930591959940e72a1240a Mon Sep 17 00:00:00 2001 From: ac23 <3045712342@qq.com> Date: Thu, 21 May 2020 16:21:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=BA=86READMD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae03432..05c2f19 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ db.put(Bytes.toBytes(1), Bytes.toBytes(1)); // Scan Iter kv = db.scan(); while (kv.hasNext()) { - KeyValue kv = kv.next(); + KeyValue expected = kv.next(); //... } ``` From 4a11d4c64626189ced4bac483ceeea2ff1b60939 Mon Sep 17 00:00:00 2001 From: ac23 <3045712342@qq.com> Date: Thu, 21 May 2020 16:33:56 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/org/apache/minibase/TestMiniBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/minibase/TestMiniBase.java b/src/test/java/org/apache/minibase/TestMiniBase.java index de46be1..4690a74 100644 --- a/src/test/java/org/apache/minibase/TestMiniBase.java +++ b/src/test/java/org/apache/minibase/TestMiniBase.java @@ -62,7 +62,7 @@ public void run() { } - @Test //有Test注解可以在不编写main函数的情况下run一个.java源文件或在这个源文件的某个函数 + @Test //有Test注解可以在不编写main函数的情况下run一个.java源文件或这个源文件的某个函数 public void testPut() throws IOException, InterruptedException { // Set maxMemstoreSize to 64B, which make the memstore flush frequently. Config conf = new Config().setDataDir(dataDir).setMaxMemstoreSize(1).setFlushMaxRetries(1)