Skip to content

Commit

Permalink
recover manifest batch:add manifest size
Browse files Browse the repository at this point in the history
  • Loading branch information
halibobo1205 committed Jul 13, 2021
1 parent 62ffd04 commit 18b1185
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
23 changes: 22 additions & 1 deletion leveldb-api/src/main/java/org/iq80/leveldb/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class Options

private boolean fast;

//M
private int maxManifestSize = 128;

static void checkArgNotNull(Object value, String name)
{
if (value == null) {
Expand Down Expand Up @@ -199,8 +202,26 @@ public boolean fast()

public Options fast(boolean fast)
{
maxBatchSize = Integer.MAX_VALUE;
if (fast) {
maxBatchSize = Integer.MAX_VALUE;
}

this.fast = fast;
return this;
}

public int maxManifestSize()
{
return maxManifestSize;
}

public Options maxManifestSize(int maxManifestSize)
{
if (maxManifestSize < 0) {
fast(false);
maxBatchSize(-1);
}
this.maxManifestSize = maxManifestSize;
return this;
}
}
6 changes: 2 additions & 4 deletions leveldb/src/main/java/org/iq80/leveldb/impl/VersionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,8 @@ public void apply(VersionEdit edit)
}
fileMetaData.setAllowedSeeks(allowedSeeks);

if (!versionSet.options.fast()) {
if (levels.get(level).deletedFiles.remove(fileMetaData.getNumber())) {
batchSize--;
}
if (levels.get(level).deletedFiles.remove(fileMetaData.getNumber())) {
batchSize--;
}
//levels.get(level).addedFiles.add(fileMetaData);
levels.get(level).addedFilesMap.put(fileMetaData.getNumber(), fileMetaData);
Expand Down
9 changes: 5 additions & 4 deletions leveldb/src/test/java/org/iq80/leveldb/impl/DbImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -877,19 +877,20 @@ public void testHugeManifest()
dbOptions.createIfMissing(true);
dbOptions.paranoidChecks(true);
dbOptions.verifyChecksums(true);
dbOptions.maxBatchSize(7500);
dbOptions.maxBatchSize(64_000);
dbOptions.compressionType(CompressionType.SNAPPY);
dbOptions.blockSize(4 * 1024);
dbOptions.writeBufferSize(10 * 1024 * 1024);
dbOptions.cacheSize(10 * 1024 * 1024L);
dbOptions.maxOpenFiles(1000);
dbOptions.maxOpenFiles(100_000);
dbOptions.fast(true);
dbOptions.maxManifestSize(256);
try {
long s = System.currentTimeMillis();
database = factory.open(file, dbOptions);
long e = System.currentTimeMillis();
System.out.println("open cost :" + (e - s));
int sum = 0;
/*int sum = 0;
DBIterator iterable = database.iterator();
iterable.seekToFirst();
while (iterable.hasNext()) {
Expand All @@ -900,7 +901,7 @@ public void testHugeManifest()
System.out.println("ite cost: " + (ee - e));
System.out.println("record:" + sum);
iterable.close();
iterable.close();*/
database.close();
}
catch (Exception e) {
Expand Down

0 comments on commit 18b1185

Please sign in to comment.