Fix formatting errors

main
Ankit Gupta 11 years ago
parent c990a7645a
commit 22d45de2ed
  1. 4
      java/RocksDBSample.java
  2. 85
      java/org/rocksdb/Options.java
  3. 28
      java/rocksjni/options.cc

@ -38,14 +38,14 @@ public class RocksDBSample {
options.setDisableSeekCompaction(true); options.setDisableSeekCompaction(true);
options.setBlockSize(64*1024); options.setBlockSize(64*1024);
options.setMaxBackgroundCompactions(10); options.setMaxBackgroundCompactions(10);
assert(options.createIfMissing() == true); assert(options.createIfMissing() == true);
assert(options.writeBufferSize() == 8192); assert(options.writeBufferSize() == 8192);
assert(options.maxWriteBufferNumber() == 3); assert(options.maxWriteBufferNumber() == 3);
assert(options.disableSeekCompaction() == true); assert(options.disableSeekCompaction() == true);
assert(options.blockSize() == 65536); assert(options.blockSize() == 65536);
assert(options.maxBackgroundCompactions() == 10); assert(options.maxBackgroundCompactions() == 10);
try { try {
db = RocksDB.open(options, db_path_not_found); db = RocksDB.open(options, db_path_not_found);
db.put("hello".getBytes(), "world".getBytes()); db.put("hello".getBytes(), "world".getBytes());

@ -34,7 +34,7 @@ public class Options {
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setCreateIfMissing(boolean flag) { public void setCreateIfMissing(boolean flag) {
checkInitialization(); assert(isInitialized());
setCreateIfMissing(nativeHandle_, flag); setCreateIfMissing(nativeHandle_, flag);
} }
@ -46,31 +46,31 @@ public class Options {
* @see setCreateIfMissing() * @see setCreateIfMissing()
*/ */
public boolean createIfMissing() { public boolean createIfMissing() {
checkInitialization(); assert(isInitialized());
return createIfMissing(nativeHandle_); return createIfMissing(nativeHandle_);
} }
/** /**
* Amount of data to build up in memory (backed by an unsorted log * Amount of data to build up in memory (backed by an unsorted log
* on disk) before converting to a sorted on-disk file. * on disk) before converting to a sorted on-disk file.
* *
* Larger values increase performance, especially during bulk loads. * Larger values increase performance, especially during bulk loads.
* Up to max_write_buffer_number write buffers may be held in memory * Up to max_write_buffer_number write buffers may be held in memory
* at the same time, so you may wish to adjust this parameter * at the same time, so you may wish to adjust this parameter
* to control memory usage. * to control memory usage.
* *
* Also, a larger write buffer will result in a longer recovery time * Also, a larger write buffer will result in a longer recovery time
* the next time the database is opened. * the next time the database is opened.
* *
* Default: 4MB * Default: 4MB
* @param size of write buffer * @param size of write buffer
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setWriteBufferSize(int writeBufferSize) { public void setWriteBufferSize(int writeBufferSize) {
checkInitialization(); assert(isInitialized());
setWriteBufferSize(nativeHandle_, writeBufferSize); setWriteBufferSize(nativeHandle_, writeBufferSize);
} }
/** /**
* Return size of write buffer size. * Return size of write buffer size.
* *
@ -78,108 +78,109 @@ public class Options {
* @see setWriteBufferSize() * @see setWriteBufferSize()
*/ */
public int writeBufferSize() { public int writeBufferSize() {
checkInitialization(); assert(isInitialized());
return writeBufferSize(nativeHandle_); return writeBufferSize(nativeHandle_);
} }
/** /**
* The maximum number of write buffers that are built up in memory. * The maximum number of write buffers that are built up in memory.
* The default is 2, so that when 1 write buffer is being flushed to * The default is 2, so that when 1 write buffer is being flushed to
* storage, new writes can continue to the other write buffer. * storage, new writes can continue to the other write buffer.
* Default: 2 * Default: 2
* *
* @param maximum number of write buffers * @param maximum number of write buffers
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setMaxWriteBufferNumber(int maxWriteBufferNumber) { public void setMaxWriteBufferNumber(int maxWriteBufferNumber) {
checkInitialization(); assert(isInitialized());
setMaxWriteBufferNumber(nativeHandle_, maxWriteBufferNumber); setMaxWriteBufferNumber(nativeHandle_, maxWriteBufferNumber);
} }
/** /**
* Returns maximum number of write buffers. * Returns maximum number of write buffers.
* *
* @return maximum number of write buffers. * @return maximum number of write buffers.
* @see setMaxWriteBufferNumber() * @see setMaxWriteBufferNumber()
*/ */
public int maxWriteBufferNumber() { public int maxWriteBufferNumber() {
checkInitialization(); assert(isInitialized());
return maxWriteBufferNumber(nativeHandle_); return maxWriteBufferNumber(nativeHandle_);
} }
/* /*
* Approximate size of user data packed per block. Note that the * Approximate size of user data packed per block. Note that the
* block size specified here corresponds to uncompressed data. The * block size specified here corresponds to uncompressed data. The
* actual size of the unit read from disk may be smaller if * actual size of the unit read from disk may be smaller if
* compression is enabled. This parameter can be changed dynamically. * compression is enabled. This parameter can be changed dynamically.
* *
* Default: 4K * Default: 4K
* *
* @param block size * @param block size
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setBlockSize(int blockSize) { public void setBlockSize(int blockSize) {
checkInitialization(); assert(isInitialized());
setBlockSize(nativeHandle_, blockSize); setBlockSize(nativeHandle_, blockSize);
} }
/* /*
* Returns block size. * Returns block size.
* *
* @return block size. * @return block size.
* @see setBlockSize() * @see setBlockSize()
*/ */
public int blockSize() { public int blockSize() {
checkInitialization(); assert(isInitialized());
return blockSize(nativeHandle_); return blockSize(nativeHandle_);
} }
/* /*
* Disable compaction triggered by seek. * Disable compaction triggered by seek.
* With bloomfilter and fast storage, a miss on one level * With bloomfilter and fast storage, a miss on one level
* is very cheap if the file handle is cached in table cache * is very cheap if the file handle is cached in table cache
* (which is true if max_open_files is large). * (which is true if max_open_files is large).
* * Default: true
*
* @param disable seek compaction * @param disable seek compaction
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setDisableSeekCompaction(boolean disableSeekCompaction) { public void setDisableSeekCompaction(boolean disableSeekCompaction) {
checkInitialization(); assert(isInitialized());
setDisableSeekCompaction(nativeHandle_, disableSeekCompaction); setDisableSeekCompaction(nativeHandle_, disableSeekCompaction);
} }
/* /*
* Returns true if disable seek compaction is set to true. * Returns true if disable seek compaction is set to true.
* *
* @return true if disable seek compaction is set to true. * @return true if disable seek compaction is set to true.
* @see setDisableSeekCompaction() * @see setDisableSeekCompaction()
*/ */
public boolean disableSeekCompaction() { public boolean disableSeekCompaction() {
checkInitialization(); assert(isInitialized());
return disableSeekCompaction(nativeHandle_); return disableSeekCompaction(nativeHandle_);
} }
/* /*
* Maximum number of concurrent background jobs, submitted to * Maximum number of concurrent background jobs, submitted to
* the default LOW priority thread pool * the default LOW priority thread pool
* Default: 1 * Default: 1
* *
* @param maximum number of concurrent background jobs. * @param maximum number of concurrent background jobs.
* @see RocksDB::Open() * @see RocksDB::Open()
*/ */
public void setMaxBackgroundCompactions(int maxBackgroundCompactions) { public void setMaxBackgroundCompactions(int maxBackgroundCompactions) {
checkInitialization(); assert(isInitialized());
setMaxBackgroundCompactions(nativeHandle_, maxBackgroundCompactions); setMaxBackgroundCompactions(nativeHandle_, maxBackgroundCompactions);
} }
/* /*
* Returns maximum number of background concurrent jobs * Returns maximum number of background concurrent jobs
* *
* @return maximum number of background concurrent jobs * @return maximum number of background concurrent jobs
* @see setMaxBackgroundCompactions * @see setMaxBackgroundCompactions
*/ */
public int maxBackgroundCompactions() { public int maxBackgroundCompactions() {
checkInitialization(); assert(isInitialized());
return maxBackgroundCompactions(nativeHandle_); return maxBackgroundCompactions(nativeHandle_);
} }
@ -192,9 +193,9 @@ public class Options {
dispose0(); dispose0();
} }
} }
private void checkInitialization() { private boolean isInitialized() {
assert(nativeHandle_ != 0); return (nativeHandle_ != 0);
} }
private native void newOptions(); private native void newOptions();
@ -202,7 +203,7 @@ public class Options {
private native void setCreateIfMissing(long handle, boolean flag); private native void setCreateIfMissing(long handle, boolean flag);
private native boolean createIfMissing(long handle); private native boolean createIfMissing(long handle);
private native void setWriteBufferSize(long handle, int writeBufferSize); private native void setWriteBufferSize(long handle, int writeBufferSize);
private native int writeBufferSize(long handle); private native int writeBufferSize(long handle);
private native void setMaxWriteBufferNumber(long handle, int maxWriteBufferNumber); private native void setMaxWriteBufferNumber(long handle, int maxWriteBufferNumber);
private native int maxWriteBufferNumber(long handle); private native int maxWriteBufferNumber(long handle);
private native void setBlockSize(long handle, int blockSize); private native void setBlockSize(long handle, int blockSize);
@ -210,7 +211,7 @@ public class Options {
private native void setDisableSeekCompaction(long handle, boolean disableSeekCompaction); private native void setDisableSeekCompaction(long handle, boolean disableSeekCompaction);
private native boolean disableSeekCompaction(long handle); private native boolean disableSeekCompaction(long handle);
private native void setMaxBackgroundCompactions(long handle, int maxBackgroundCompactions); private native void setMaxBackgroundCompactions(long handle, int maxBackgroundCompactions);
private native int maxBackgroundCompactions(long handle); private native int maxBackgroundCompactions(long handle);
long nativeHandle_; long nativeHandle_;
} }

@ -65,7 +65,7 @@ jboolean Java_org_rocksdb_Options_createIfMissing(
*/ */
void Java_org_rocksdb_Options_setWriteBufferSize( void Java_org_rocksdb_Options_setWriteBufferSize(
JNIEnv* env, jobject jobj, jlong jhandle, jint jwrite_buffer_size) { JNIEnv* env, jobject jobj, jlong jhandle, jint jwrite_buffer_size) {
reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size = reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size =
static_cast<size_t>(jwrite_buffer_size); static_cast<size_t>(jwrite_buffer_size);
} }
@ -77,7 +77,7 @@ void Java_org_rocksdb_Options_setWriteBufferSize(
*/ */
jint Java_org_rocksdb_Options_writeBufferSize( jint Java_org_rocksdb_Options_writeBufferSize(
JNIEnv* env, jobject jobj, jlong jhandle) { JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size; return reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size;
} }
/* /*
@ -87,7 +87,8 @@ jint Java_org_rocksdb_Options_writeBufferSize(
*/ */
void Java_org_rocksdb_Options_setMaxWriteBufferNumber( void Java_org_rocksdb_Options_setMaxWriteBufferNumber(
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_write_buffer_number) { JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_write_buffer_number) {
reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number = jmax_write_buffer_number; reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number =
jmax_write_buffer_number;
} }
@ -98,7 +99,7 @@ void Java_org_rocksdb_Options_setMaxWriteBufferNumber(
*/ */
jint Java_org_rocksdb_Options_maxWriteBufferNumber( jint Java_org_rocksdb_Options_maxWriteBufferNumber(
JNIEnv* env, jobject jobj, jlong jhandle) { JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number; return reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number;
} }
/* /*
@ -108,7 +109,7 @@ jint Java_org_rocksdb_Options_maxWriteBufferNumber(
*/ */
void Java_org_rocksdb_Options_setBlockSize( void Java_org_rocksdb_Options_setBlockSize(
JNIEnv* env, jobject jobj, jlong jhandle, jint jblock_size) { JNIEnv* env, jobject jobj, jlong jhandle, jint jblock_size) {
reinterpret_cast<rocksdb::Options*>(jhandle)->block_size = reinterpret_cast<rocksdb::Options*>(jhandle)->block_size =
static_cast<size_t>(jblock_size); static_cast<size_t>(jblock_size);
} }
@ -119,7 +120,7 @@ void Java_org_rocksdb_Options_setBlockSize(
*/ */
jint Java_org_rocksdb_Options_blockSize( jint Java_org_rocksdb_Options_blockSize(
JNIEnv* env, jobject jobj, jlong jhandle) { JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->block_size; return reinterpret_cast<rocksdb::Options*>(jhandle)->block_size;
} }
/* /*
@ -128,8 +129,10 @@ jint Java_org_rocksdb_Options_blockSize(
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_Options_setDisableSeekCompaction( void Java_org_rocksdb_Options_setDisableSeekCompaction(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jdisable_seek_compaction) { JNIEnv* env, jobject jobj, jlong jhandle,
reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction = jdisable_seek_compaction; jboolean jdisable_seek_compaction) {
reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction =
jdisable_seek_compaction;
} }
/* /*
@ -148,8 +151,10 @@ jboolean Java_org_rocksdb_Options_disableSeekCompaction(
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_Options_setMaxBackgroundCompactions( void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_background_compactions) { JNIEnv* env, jobject jobj, jlong jhandle,
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions = jmax_background_compactions; jint jmax_background_compactions) {
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions =
jmax_background_compactions;
} }
/* /*
@ -159,7 +164,8 @@ void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
*/ */
jint Java_org_rocksdb_Options_maxBackgroundCompactions( jint Java_org_rocksdb_Options_maxBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle) { JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions; return
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions;
} }

Loading…
Cancel
Save