Package org.rocksdb
Class WriteOptions
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.AbstractImmutableNativeReference
-
- org.rocksdb.RocksObject
-
- org.rocksdb.WriteOptions
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class WriteOptions extends RocksObject
Options that control write operations. Note that developers should call WriteOptions.dispose() to release the c++ side memory before a WriteOptions instance runs out of scope.
-
-
Field Summary
-
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_
-
Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_
-
-
Constructor Summary
Constructors Constructor Description WriteOptions()Construct WriteOptions instance.WriteOptions(WriteOptions other)Copy constructor for WriteOptions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandisableWAL()If true, writes will not first go to the write ahead log, and the write may got lost after a crash.protected voiddisposeInternal(long handle)booleanignoreMissingColumnFamilies()If true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error).booleanlowPri()Returns true if this write request is of lower priority if compaction is behind.booleannoSlowdown()If true and we need to wait or sleep for the write request, fails immediately withStatus.Code.Incomplete.WriteOptionssetDisableWAL(boolean flag)If true, writes will not first go to the write ahead log, and the write may got lost after a crash.WriteOptionssetIgnoreMissingColumnFamilies(boolean ignoreMissingColumnFamilies)If true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error).WriteOptionssetLowPri(boolean lowPri)If true, this write request is of lower priority if compaction is behind.WriteOptionssetNoSlowdown(boolean noSlowdown)If true and we need to wait or sleep for the write request, fails immediately withStatus.Code.Incomplete.WriteOptionssetSync(boolean flag)If true, the write will be flushed from the operating system buffer cache (by calling WritableFile::Sync()) before the write is considered complete.booleansync()If true, the write will be flushed from the operating system buffer cache (by calling WritableFile::Sync()) before the write is considered complete.-
Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandle
-
Methods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Constructor Detail
-
WriteOptions
public WriteOptions()
Construct WriteOptions instance.
-
WriteOptions
public WriteOptions(WriteOptions other)
Copy constructor for WriteOptions. NOTE: This does a shallow copy, which means comparator, merge_operator, compaction_filter, compaction_filter_factory and other pointers will be cloned!- Parameters:
other- The ColumnFamilyOptions to copy.
-
-
Method Detail
-
setSync
public WriteOptions setSync(boolean flag)
If true, the write will be flushed from the operating system buffer cache (by calling WritableFile::Sync()) before the write is considered complete. If this flag is true, writes will be slower. If this flag is false, and the machine crashes, some recent writes may be lost. Note that if it is just the process that crashes (i.e., the machine does not reboot), no writes will be lost even if sync==false. In other words, a DB write with sync==false has similar crash semantics as the "write()" system call. A DB write with sync==true has similar crash semantics to a "write()" system call followed by "fdatasync()". Default: false- Parameters:
flag- a boolean flag to indicate whether a write should be synchronized.- Returns:
- the instance of the current WriteOptions.
-
sync
public boolean sync()
If true, the write will be flushed from the operating system buffer cache (by calling WritableFile::Sync()) before the write is considered complete. If this flag is true, writes will be slower. If this flag is false, and the machine crashes, some recent writes may be lost. Note that if it is just the process that crashes (i.e., the machine does not reboot), no writes will be lost even if sync==false. In other words, a DB write with sync==false has similar crash semantics as the "write()" system call. A DB write with sync==true has similar crash semantics to a "write()" system call followed by "fdatasync()".- Returns:
- boolean value indicating if sync is active.
-
setDisableWAL
public WriteOptions setDisableWAL(boolean flag)
If true, writes will not first go to the write ahead log, and the write may got lost after a crash. The backup engine relies on write-ahead logs to back up the memtable, so if you disable write-ahead logs, you must create backups with flush_before_backup=true to avoid losing unflushed memtable data.- Parameters:
flag- a boolean flag to specify whether to disable write-ahead-log on writes.- Returns:
- the instance of the current WriteOptions.
-
disableWAL
public boolean disableWAL()
If true, writes will not first go to the write ahead log, and the write may got lost after a crash. The backup engine relies on write-ahead logs to back up the memtable, so if you disable write-ahead logs, you must create backups with flush_before_backup=true to avoid losing unflushed memtable data.- Returns:
- boolean value indicating if WAL is disabled.
-
setIgnoreMissingColumnFamilies
public WriteOptions setIgnoreMissingColumnFamilies(boolean ignoreMissingColumnFamilies)
If true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error). If there are multiple writes in a WriteBatch, other writes will succeed. Default: false- Parameters:
ignoreMissingColumnFamilies- true to ignore writes to column families which don't exist- Returns:
- the instance of the current WriteOptions.
-
ignoreMissingColumnFamilies
public boolean ignoreMissingColumnFamilies()
If true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error). If there are multiple writes in a WriteBatch, other writes will succeed. Default: false- Returns:
- true if writes to column families which don't exist are ignored
-
setNoSlowdown
public WriteOptions setNoSlowdown(boolean noSlowdown)
If true and we need to wait or sleep for the write request, fails immediately withStatus.Code.Incomplete.- Parameters:
noSlowdown- true to fail write requests if we need to wait or sleep- Returns:
- the instance of the current WriteOptions.
-
noSlowdown
public boolean noSlowdown()
If true and we need to wait or sleep for the write request, fails immediately withStatus.Code.Incomplete.- Returns:
- true when write requests are failed if we need to wait or sleep
-
setLowPri
public WriteOptions setLowPri(boolean lowPri)
If true, this write request is of lower priority if compaction is behind. In this case that,noSlowdown()== true, the request will be cancelled immediately withStatus.Code.Incompletereturned. Otherwise, it will be slowed down. The slowdown value is determined by RocksDB to guarantee it introduces minimum impacts to high priority writes. Default: false- Parameters:
lowPri- true if the write request should be of lower priority than compactions which are behind.- Returns:
- the instance of the current WriteOptions.
-
lowPri
public boolean lowPri()
Returns true if this write request is of lower priority if compaction is behind. SeesetLowPri(boolean).- Returns:
- true if this write request is of lower priority, false otherwise.
-
disposeInternal
protected final void disposeInternal(long handle)
- Specified by:
disposeInternalin classRocksObject
-
-