]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/java/src/main/java/org/rocksdb/IngestExternalFileOptions.java
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / IngestExternalFileOptions.java
index 7343691817b0431c2746efd60ed8e2eb7c85dcdd..a6a308daa3c0811b496d90d5eac039a60295eb91 100644 (file)
@@ -7,7 +7,8 @@ package org.rocksdb;
 import java.util.List;
 
 /**
- * IngestExternalFileOptions is used by {@link RocksDB#ingestExternalFile(ColumnFamilyHandle, List, IngestExternalFileOptions)}
+ * IngestExternalFileOptions is used by
+ * {@link RocksDB#ingestExternalFile(ColumnFamilyHandle, List, IngestExternalFileOptions)}.
  */
 public class IngestExternalFileOptions extends RocksObject {
 
@@ -41,9 +42,12 @@ public class IngestExternalFileOptions extends RocksObject {
    * Can be set to true to move the files instead of copying them.
    *
    * @param moveFiles true if files should be moved instead of copied
+   *
+   * @return the reference to the current IngestExternalFileOptions.
    */
-  public void setMoveFiles(final boolean moveFiles) {
+  public IngestExternalFileOptions setMoveFiles(final boolean moveFiles) {
     setMoveFiles(nativeHandle_, moveFiles);
+    return this;
   }
 
   /**
@@ -61,9 +65,13 @@ public class IngestExternalFileOptions extends RocksObject {
    * that where created before the file was ingested.
    *
    * @param snapshotConsistency true if snapshot consistency is required
+   *
+   * @return the reference to the current IngestExternalFileOptions.
    */
-  public void setSnapshotConsistency(final boolean snapshotConsistency) {
+  public IngestExternalFileOptions setSnapshotConsistency(
+      final boolean snapshotConsistency) {
     setSnapshotConsistency(nativeHandle_, snapshotConsistency);
+    return this;
   }
 
   /**
@@ -81,9 +89,13 @@ public class IngestExternalFileOptions extends RocksObject {
    * will fail if the file key range overlaps with existing keys or tombstones in the DB.
    *
    * @param allowGlobalSeqNo true if global seq numbers are required
+   *
+   * @return the reference to the current IngestExternalFileOptions.
    */
-  public void setAllowGlobalSeqNo(final boolean allowGlobalSeqNo) {
+  public IngestExternalFileOptions setAllowGlobalSeqNo(
+      final boolean allowGlobalSeqNo) {
     setAllowGlobalSeqNo(nativeHandle_, allowGlobalSeqNo);
+    return this;
   }
 
   /**
@@ -101,15 +113,100 @@ public class IngestExternalFileOptions extends RocksObject {
    * (memtable flush required), IngestExternalFile will fail.
    *
    * @param allowBlockingFlush true if blocking flushes are allowed
+   *
+   * @return the reference to the current IngestExternalFileOptions.
    */
-  public void setAllowBlockingFlush(final boolean allowBlockingFlush) {
+  public IngestExternalFileOptions setAllowBlockingFlush(
+      final boolean allowBlockingFlush) {
     setAllowBlockingFlush(nativeHandle_, allowBlockingFlush);
+    return this;
+  }
+
+  /**
+   * Returns true if duplicate keys in the file being ingested are
+   * to be skipped rather than overwriting existing data under that key.
+   *
+   * @return true if duplicate keys in the file being ingested are to be
+   *     skipped, false otherwise.
+   */
+  public boolean ingestBehind() {
+    return ingestBehind(nativeHandle_);
+  }
+
+  /**
+   * Set to true if you would like duplicate keys in the file being ingested
+   * to be skipped rather than overwriting existing data under that key.
+   *
+   * Usecase: back-fill of some historical data in the database without
+   * over-writing existing newer version of data.
+   *
+   * This option could only be used if the DB has been running
+   * with DBOptions#allowIngestBehind() == true since the dawn of time.
+   *
+   * All files will be ingested at the bottommost level with seqno=0.
+   *
+   * Default: false
+   *
+   * @param ingestBehind true if you would like duplicate keys in the file being
+   *     ingested to be skipped.
+   *
+   * @return the reference to the current IngestExternalFileOptions.
+   */
+  public IngestExternalFileOptions setIngestBehind(final boolean ingestBehind) {
+    setIngestBehind(nativeHandle_, ingestBehind);
+    return this;
+  }
+
+  /**
+   * Returns true write if the global_seqno is written to a given offset
+   * in the external SST file for backward compatibility.
+   *
+   * See {@link #setWriteGlobalSeqno(boolean)}.
+   *
+   * @return true if the global_seqno is written to a given offset,
+   *     false otherwise.
+   */
+  public boolean writeGlobalSeqno() {
+    return writeGlobalSeqno(nativeHandle_);
+  }
+
+  /**
+   * Set to true if you would like to write the global_seqno to a given offset
+   * in the external SST file for backward compatibility.
+   *
+   * Older versions of RocksDB write the global_seqno to a given offset within
+   * the ingested SST files, and new versions of RocksDB do not.
+   *
+   * If you ingest an external SST using new version of RocksDB and would like
+   * to be able to downgrade to an older version of RocksDB, you should set
+   * {@link #writeGlobalSeqno()} to true.
+   *
+   * If your service is just starting to use the new RocksDB, we recommend that
+   * you set this option to false, which brings two benefits:
+   *    1. No extra random write for global_seqno during ingestion.
+   *    2. Without writing external SST file, it's possible to do checksum.
+   *
+   * We have a plan to set this option to false by default in the future.
+   *
+   * Default: true
+   *
+   * @param writeGlobalSeqno true to write the gloal_seqno to a given offset,
+   *     false otherwise
+   *
+   * @return the reference to the current IngestExternalFileOptions.
+   */
+  public IngestExternalFileOptions setWriteGlobalSeqno(
+      final boolean writeGlobalSeqno) {
+    setWriteGlobalSeqno(nativeHandle_, writeGlobalSeqno);
+    return this;
   }
 
   private native static long newIngestExternalFileOptions();
   private native static long newIngestExternalFileOptions(
       final boolean moveFiles, final boolean snapshotConsistency,
       final boolean allowGlobalSeqNo, final boolean allowBlockingFlush);
+  @Override protected final native void disposeInternal(final long handle);
+
   private native boolean moveFiles(final long handle);
   private native void setMoveFiles(final long handle, final boolean move_files);
   private native boolean snapshotConsistency(final long handle);
@@ -121,5 +218,10 @@ public class IngestExternalFileOptions extends RocksObject {
   private native boolean allowBlockingFlush(final long handle);
   private native void setAllowBlockingFlush(final long handle,
       final boolean allowBlockingFlush);
-  @Override protected final native void disposeInternal(final long handle);
+  private native boolean ingestBehind(final long handle);
+  private native void setIngestBehind(final long handle,
+      final boolean ingestBehind);
+  private native boolean writeGlobalSeqno(final long handle);
+  private native void setWriteGlobalSeqno(final long handle,
+      final boolean writeGlobalSeqNo);
 }