Skip to content

Commit

Permalink
remove fast, change bitsPerKey long to int
Browse files Browse the repository at this point in the history
  • Loading branch information
halibobo1205 committed Jul 26, 2021
1 parent 69d896a commit a169b78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
25 changes: 4 additions & 21 deletions leveldb-api/src/main/java/org/iq80/leveldb/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ public class Options
private DBComparator comparator;
private Logger logger;
private long cacheSize;
private long bitsPerKey;
private int bitsPerKey;

private int maxBatchSize = 52_000;

private boolean fast;

//M
private int maxManifestSize = 128;

Expand Down Expand Up @@ -182,12 +180,12 @@ public Options paranoidChecks(boolean paranoidChecks)
return this;
}

public long bitsPerKey()
public int bitsPerKey()
{
return bitsPerKey;
}

public Options bitsPerKey(long bitsPerKey)
public Options bitsPerKey(int bitsPerKey)
{
this.bitsPerKey = bitsPerKey;
return this;
Expand All @@ -207,21 +205,6 @@ public Options maxBatchSize(int maxBatchSize)
return this;
}

public boolean fast()
{
return fast;
}

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

this.fast = fast;
return this;
}

public int maxManifestSize()
{
return maxManifestSize;
Expand All @@ -230,7 +213,7 @@ public int maxManifestSize()
public Options maxManifestSize(int maxManifestSize)
{
if (maxManifestSize < 0) {
fast(false);
maxManifestSize = -1;
maxBatchSize(-1);
}
this.maxManifestSize = maxManifestSize;
Expand Down
10 changes: 4 additions & 6 deletions leveldb/src/main/java/org/iq80/leveldb/impl/VersionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,11 @@ public void apply(VersionEdit edit)
for (Entry<Integer, Long> entry : edit.getDeletedFiles().entries()) {
Integer level = entry.getKey();
Long fileNumber = entry.getValue();
if (!versionSet.options.fast()) {
levels.get(level).deletedFiles.add(fileNumber);
batchSize++;
}

// todo missing update to addedFiles?
levels.get(level).deletedFiles.add(fileNumber);
batchSize++;


// missing update to addedFiles for open db to release resource
if (levels.get(level).addedFilesMap.remove(fileNumber) != null) {
batchSize--;
Expand Down Expand Up @@ -771,7 +770,6 @@ public void apply(VersionEdit edit)
if (levels.get(level).deletedFiles.remove(fileMetaData.getNumber())) {
batchSize--;
}
//levels.get(level).addedFiles.add(fileMetaData);
levels.get(level).addedFilesMap.put(fileMetaData.getNumber(), fileMetaData);
batchSize++;
}
Expand Down

0 comments on commit a169b78

Please sign in to comment.