Add doc + refactor + fix formatting

This commit is contained in:
Ankit Gupta
2014-04-19 13:05:21 -07:00
parent 1d6c1e018f
commit dc28a726c1
7 changed files with 111 additions and 73 deletions

View File

@@ -7,70 +7,70 @@ package org.rocksdb;
public class Iterator {
private long nativeHandle_;
public Iterator(long nativeHandle) {
nativeHandle_ = nativeHandle;
}
public boolean isValid() {
assert(isInitialized());
return isValid0(nativeHandle_);
}
public void seekToFirst() {
assert(isInitialized());
seekToFirst0(nativeHandle_);
}
public void seekToLast() {
assert(isInitialized());
seekToLast0(nativeHandle_);
}
public void next() {
assert(isInitialized());
next0(nativeHandle_);
}
public void prev() {
assert(isInitialized());
prev0(nativeHandle_);
}
public byte[] key() {
assert(isInitialized());
return key0(nativeHandle_);
}
public byte[] value() {
assert(isInitialized());
return value0(nativeHandle_);
}
public void seek(byte[] target) {
assert(isInitialized());
seek0(nativeHandle_, target, target.length);
}
public void status(){
assert(isInitialized());
status0(nativeHandle_);
}
public synchronized void close() {
if(nativeHandle_ != 0) {
close0(nativeHandle_);
}
}
@Override protected void finalize() {
close();
}
private boolean isInitialized() {
return (nativeHandle_ != 0);
}
private native boolean isValid0(long handle);
private native void close0(long handle);
private native void seekToFirst0(long handle);
@@ -81,4 +81,4 @@ public class Iterator {
private native byte[] value0(long handle);
private native void seek0(long handle, byte[] target, int targetLen);
private native void status0(long handle);
}
}

View File

@@ -508,7 +508,7 @@ public class Options {
return maxBackgroundCompactions(nativeHandle_);
}
/**
/**
* Creates statistics object which collects metrics about database operations.
Statistics objects should not be shared between DB instances as
it does not use any locks to prevent concurrent updates.

View File

@@ -135,7 +135,7 @@ public class RocksDB {
throws RocksDBException {
remove(nativeHandle_, writeOpt.nativeHandle_, key, key.length);
}
public Iterator iterator() {
return new Iterator(iterator0(nativeHandle_));
}