Skip to content

Commit

Permalink
HaloDB.size method
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Khodakivskiy committed Feb 22, 2019
1 parent 8facc50 commit 156e96f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/oath/halodb/HaloDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public byte[] get(byte[] key) throws HaloDBException {
}
}

public int size(byte[] key) {
return dbInternal.size(key);
}

public boolean put(byte[] key, byte[] value) throws HaloDBException {
try {
return dbInternal.put(key, value);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/oath/halodb/HaloDBInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ long size() {
return inMemoryIndex.size();
}

int size(byte[] key) {
InMemoryIndexMetaData metaData = inMemoryIndex.get(key);
if (metaData == null) {
return 0;
}

return metaData.getValueSize();
}

void setIOErrorFlag() throws IOException {
DBMetaData metaData = new DBMetaData(dbDirectory);
metaData.loadFromFileIfExists();
Expand Down

0 comments on commit 156e96f

Please sign in to comment.