Skip to content

Commit 22d45de

Browse files
author
Ankit Gupta
committed
Fix formatting errors
1 parent c990a76 commit 22d45de

File tree

3 files changed

+62
-55
lines changed

3 files changed

+62
-55
lines changed

java/RocksDBSample.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public static void main(String[] args) {
3838
options.setDisableSeekCompaction(true);
3939
options.setBlockSize(64*1024);
4040
options.setMaxBackgroundCompactions(10);
41-
41+
4242
assert(options.createIfMissing() == true);
4343
assert(options.writeBufferSize() == 8192);
4444
assert(options.maxWriteBufferNumber() == 3);
4545
assert(options.disableSeekCompaction() == true);
4646
assert(options.blockSize() == 65536);
4747
assert(options.maxBackgroundCompactions() == 10);
48-
48+
4949
try {
5050
db = RocksDB.open(options, db_path_not_found);
5151
db.put("hello".getBytes(), "world".getBytes());

java/org/rocksdb/Options.java

+43-42
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public Options() {
3434
* @see RocksDB::Open()
3535
*/
3636
public void setCreateIfMissing(boolean flag) {
37-
checkInitialization();
37+
assert(isInitialized());
3838
setCreateIfMissing(nativeHandle_, flag);
3939
}
4040

@@ -46,140 +46,141 @@ public void setCreateIfMissing(boolean flag) {
4646
* @see setCreateIfMissing()
4747
*/
4848
public boolean createIfMissing() {
49-
checkInitialization();
49+
assert(isInitialized());
5050
return createIfMissing(nativeHandle_);
5151
}
52-
52+
5353
/**
5454
* Amount of data to build up in memory (backed by an unsorted log
5555
* on disk) before converting to a sorted on-disk file.
56-
*
56+
*
5757
* Larger values increase performance, especially during bulk loads.
5858
* Up to max_write_buffer_number write buffers may be held in memory
59-
* at the same time, so you may wish to adjust this parameter
59+
* at the same time, so you may wish to adjust this parameter
6060
* to control memory usage.
61-
*
61+
*
6262
* Also, a larger write buffer will result in a longer recovery time
6363
* the next time the database is opened.
64-
*
64+
*
6565
* Default: 4MB
6666
* @param size of write buffer
6767
* @see RocksDB::Open()
68-
*/
68+
*/
6969
public void setWriteBufferSize(int writeBufferSize) {
70-
checkInitialization();
70+
assert(isInitialized());
7171
setWriteBufferSize(nativeHandle_, writeBufferSize);
7272
}
73-
73+
7474
/**
7575
* Return size of write buffer size.
7676
*
7777
* @return size of write buffer.
7878
* @see setWriteBufferSize()
7979
*/
8080
public int writeBufferSize() {
81-
checkInitialization();
81+
assert(isInitialized());
8282
return writeBufferSize(nativeHandle_);
8383
}
84-
84+
8585
/**
8686
* The maximum number of write buffers that are built up in memory.
8787
* The default is 2, so that when 1 write buffer is being flushed to
8888
* storage, new writes can continue to the other write buffer.
8989
* Default: 2
90-
*
90+
*
9191
* @param maximum number of write buffers
9292
* @see RocksDB::Open()
9393
*/
9494
public void setMaxWriteBufferNumber(int maxWriteBufferNumber) {
95-
checkInitialization();
95+
assert(isInitialized());
9696
setMaxWriteBufferNumber(nativeHandle_, maxWriteBufferNumber);
9797
}
98-
98+
9999
/**
100100
* Returns maximum number of write buffers.
101-
*
101+
*
102102
* @return maximum number of write buffers.
103103
* @see setMaxWriteBufferNumber()
104104
*/
105105
public int maxWriteBufferNumber() {
106-
checkInitialization();
106+
assert(isInitialized());
107107
return maxWriteBufferNumber(nativeHandle_);
108108
}
109-
109+
110110
/*
111111
* Approximate size of user data packed per block. Note that the
112112
* block size specified here corresponds to uncompressed data. The
113113
* actual size of the unit read from disk may be smaller if
114114
* compression is enabled. This parameter can be changed dynamically.
115-
*
115+
*
116116
* Default: 4K
117-
*
117+
*
118118
* @param block size
119119
* @see RocksDB::Open()
120120
*/
121121
public void setBlockSize(int blockSize) {
122-
checkInitialization();
122+
assert(isInitialized());
123123
setBlockSize(nativeHandle_, blockSize);
124124
}
125-
125+
126126
/*
127127
* Returns block size.
128-
*
128+
*
129129
* @return block size.
130-
* @see setBlockSize()
130+
* @see setBlockSize()
131131
*/
132132
public int blockSize() {
133-
checkInitialization();
133+
assert(isInitialized());
134134
return blockSize(nativeHandle_);
135135
}
136-
136+
137137
/*
138138
* Disable compaction triggered by seek.
139139
* With bloomfilter and fast storage, a miss on one level
140140
* is very cheap if the file handle is cached in table cache
141141
* (which is true if max_open_files is large).
142-
*
142+
* Default: true
143+
*
143144
* @param disable seek compaction
144145
* @see RocksDB::Open()
145146
*/
146147
public void setDisableSeekCompaction(boolean disableSeekCompaction) {
147-
checkInitialization();
148+
assert(isInitialized());
148149
setDisableSeekCompaction(nativeHandle_, disableSeekCompaction);
149150
}
150-
151+
151152
/*
152153
* Returns true if disable seek compaction is set to true.
153-
*
154+
*
154155
* @return true if disable seek compaction is set to true.
155156
* @see setDisableSeekCompaction()
156157
*/
157158
public boolean disableSeekCompaction() {
158-
checkInitialization();
159+
assert(isInitialized());
159160
return disableSeekCompaction(nativeHandle_);
160161
}
161-
162+
162163
/*
163164
* Maximum number of concurrent background jobs, submitted to
164165
* the default LOW priority thread pool
165166
* Default: 1
166-
*
167+
*
167168
* @param maximum number of concurrent background jobs.
168169
* @see RocksDB::Open()
169170
*/
170171
public void setMaxBackgroundCompactions(int maxBackgroundCompactions) {
171-
checkInitialization();
172+
assert(isInitialized());
172173
setMaxBackgroundCompactions(nativeHandle_, maxBackgroundCompactions);
173174
}
174-
175+
175176
/*
176177
* Returns maximum number of background concurrent jobs
177-
*
178+
*
178179
* @return maximum number of background concurrent jobs
179180
* @see setMaxBackgroundCompactions
180181
*/
181182
public int maxBackgroundCompactions() {
182-
checkInitialization();
183+
assert(isInitialized());
183184
return maxBackgroundCompactions(nativeHandle_);
184185
}
185186

@@ -192,25 +193,25 @@ public synchronized void dispose() {
192193
dispose0();
193194
}
194195
}
195-
196-
private void checkInitialization() {
197-
assert(nativeHandle_ != 0);
196+
197+
private boolean isInitialized() {
198+
return (nativeHandle_ != 0);
198199
}
199200

200201
private native void newOptions();
201202
private native void dispose0();
202203
private native void setCreateIfMissing(long handle, boolean flag);
203204
private native boolean createIfMissing(long handle);
204205
private native void setWriteBufferSize(long handle, int writeBufferSize);
205-
private native int writeBufferSize(long handle);
206+
private native int writeBufferSize(long handle);
206207
private native void setMaxWriteBufferNumber(long handle, int maxWriteBufferNumber);
207208
private native int maxWriteBufferNumber(long handle);
208209
private native void setBlockSize(long handle, int blockSize);
209210
private native int blockSize(long handle);
210211
private native void setDisableSeekCompaction(long handle, boolean disableSeekCompaction);
211212
private native boolean disableSeekCompaction(long handle);
212213
private native void setMaxBackgroundCompactions(long handle, int maxBackgroundCompactions);
213-
private native int maxBackgroundCompactions(long handle);
214+
private native int maxBackgroundCompactions(long handle);
214215

215216
long nativeHandle_;
216217
}

java/rocksjni/options.cc

+17-11
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jboolean Java_org_rocksdb_Options_createIfMissing(
6565
*/
6666
void Java_org_rocksdb_Options_setWriteBufferSize(
6767
JNIEnv* env, jobject jobj, jlong jhandle, jint jwrite_buffer_size) {
68-
reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size =
68+
reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size =
6969
static_cast<size_t>(jwrite_buffer_size);
7070
}
7171

@@ -77,7 +77,7 @@ void Java_org_rocksdb_Options_setWriteBufferSize(
7777
*/
7878
jint Java_org_rocksdb_Options_writeBufferSize(
7979
JNIEnv* env, jobject jobj, jlong jhandle) {
80-
return reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size;
80+
return reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size;
8181
}
8282

8383
/*
@@ -87,7 +87,8 @@ jint Java_org_rocksdb_Options_writeBufferSize(
8787
*/
8888
void Java_org_rocksdb_Options_setMaxWriteBufferNumber(
8989
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_write_buffer_number) {
90-
reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number = jmax_write_buffer_number;
90+
reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number =
91+
jmax_write_buffer_number;
9192
}
9293

9394

@@ -98,7 +99,7 @@ void Java_org_rocksdb_Options_setMaxWriteBufferNumber(
9899
*/
99100
jint Java_org_rocksdb_Options_maxWriteBufferNumber(
100101
JNIEnv* env, jobject jobj, jlong jhandle) {
101-
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number;
102+
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number;
102103
}
103104

104105
/*
@@ -108,7 +109,7 @@ jint Java_org_rocksdb_Options_maxWriteBufferNumber(
108109
*/
109110
void Java_org_rocksdb_Options_setBlockSize(
110111
JNIEnv* env, jobject jobj, jlong jhandle, jint jblock_size) {
111-
reinterpret_cast<rocksdb::Options*>(jhandle)->block_size =
112+
reinterpret_cast<rocksdb::Options*>(jhandle)->block_size =
112113
static_cast<size_t>(jblock_size);
113114
}
114115

@@ -119,7 +120,7 @@ void Java_org_rocksdb_Options_setBlockSize(
119120
*/
120121
jint Java_org_rocksdb_Options_blockSize(
121122
JNIEnv* env, jobject jobj, jlong jhandle) {
122-
return reinterpret_cast<rocksdb::Options*>(jhandle)->block_size;
123+
return reinterpret_cast<rocksdb::Options*>(jhandle)->block_size;
123124
}
124125

125126
/*
@@ -128,8 +129,10 @@ jint Java_org_rocksdb_Options_blockSize(
128129
* Signature: (JZ)V
129130
*/
130131
void Java_org_rocksdb_Options_setDisableSeekCompaction(
131-
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jdisable_seek_compaction) {
132-
reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction = jdisable_seek_compaction;
132+
JNIEnv* env, jobject jobj, jlong jhandle,
133+
jboolean jdisable_seek_compaction) {
134+
reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction =
135+
jdisable_seek_compaction;
133136
}
134137

135138
/*
@@ -148,8 +151,10 @@ jboolean Java_org_rocksdb_Options_disableSeekCompaction(
148151
* Signature: (JI)V
149152
*/
150153
void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
151-
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_background_compactions) {
152-
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions = jmax_background_compactions;
154+
JNIEnv* env, jobject jobj, jlong jhandle,
155+
jint jmax_background_compactions) {
156+
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions =
157+
jmax_background_compactions;
153158
}
154159

155160
/*
@@ -159,7 +164,8 @@ void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
159164
*/
160165
jint Java_org_rocksdb_Options_maxBackgroundCompactions(
161166
JNIEnv* env, jobject jobj, jlong jhandle) {
162-
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions;
167+
return
168+
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions;
163169
}
164170

165171

0 commit comments

Comments
 (0)