Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
starrocks-xupeng committed Jul 18, 2022
1 parent 6d40005 commit 804383f
Showing 1 changed file with 43 additions and 18 deletions.
Expand Up @@ -771,25 +771,50 @@ public void write(DataOutput out) throws IOException {
writable.write(buffer);

BDBEnvironment environment = initBDBEnv("testJournalWithPrefix");
BDBJEJournal journal = new BDBJEJournal(environment, "aaa_");
Assert.assertEquals("aaa_", journal.getPrefix());

journal.open();
journal.batchWriteBegin();
journal.batchWriteAppend(1, buffer);
journal.batchWriteAppend(2, buffer);
journal.batchWriteCommit();

journal.rollJournal(3);
journal.open();
journal.batchWriteBegin();
journal.batchWriteAppend(3, buffer);
journal.batchWriteAppend(4, buffer);
journal.batchWriteCommit();
// test journal with prefix works fine
{
BDBJEJournal journalWithPrefix = new BDBJEJournal(environment, "aaa_");
Assert.assertEquals("aaa_", journalWithPrefix.getPrefix());
journalWithPrefix.open();
journalWithPrefix.batchWriteBegin();
journalWithPrefix.batchWriteAppend(1, buffer);
journalWithPrefix.batchWriteAppend(2, buffer);
journalWithPrefix.batchWriteCommit();

journalWithPrefix.rollJournal(3);
journalWithPrefix.open();
journalWithPrefix.batchWriteBegin();
journalWithPrefix.batchWriteAppend(3, buffer);
journalWithPrefix.batchWriteAppend(4, buffer);
journalWithPrefix.batchWriteCommit();

List<Long> l = journalWithPrefix.getDatabaseNames();
Assert.assertEquals(2, l.size());
Assert.assertEquals((Long) 1L, l.get(0));
Assert.assertEquals((Long) 3L, l.get(1));
}

List<Long> l = journal.getDatabaseNames();
Assert.assertEquals(2, l.size());
Assert.assertEquals((Long) 1L, l.get(0));
Assert.assertEquals((Long) 3L, l.get(1));
// test journal without prefix works fine at the same time
{
BDBJEJournal journalWithoutPrefix = new BDBJEJournal(environment);
journalWithoutPrefix.open();
journalWithoutPrefix.batchWriteBegin();
journalWithoutPrefix.batchWriteAppend(1, buffer);
journalWithoutPrefix.batchWriteAppend(2, buffer);
journalWithoutPrefix.batchWriteCommit();

journalWithoutPrefix.rollJournal(3);
journalWithoutPrefix.open();
journalWithoutPrefix.batchWriteBegin();
journalWithoutPrefix.batchWriteAppend(3, buffer);
journalWithoutPrefix.batchWriteAppend(4, buffer);
journalWithoutPrefix.batchWriteCommit();

List<Long> l = journalWithoutPrefix.getDatabaseNames();
Assert.assertEquals(2, l.size());
Assert.assertEquals((Long) 1L, l.get(0));
Assert.assertEquals((Long) 3L, l.get(1));
}
}
}

0 comments on commit 804383f

Please sign in to comment.