]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/java/src/main/java/org/rocksdb/IngestExternalFileOptions.java
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / IngestExternalFileOptions.java
CommitLineData
11fdf7f2
TL
1package org.rocksdb;
2// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
3// This source code is licensed under both the GPLv2 (found in the
4// COPYING file in the root directory) and Apache 2.0 License
5// (found in the LICENSE.Apache file in the root directory).
6
7import java.util.List;
8
9/**
494da23a
TL
10 * IngestExternalFileOptions is used by
11 * {@link RocksDB#ingestExternalFile(ColumnFamilyHandle, List, IngestExternalFileOptions)}.
11fdf7f2
TL
12 */
13public class IngestExternalFileOptions extends RocksObject {
14
15 public IngestExternalFileOptions() {
16 super(newIngestExternalFileOptions());
17 }
18
19 /**
20 * @param moveFiles {@link #setMoveFiles(boolean)}
21 * @param snapshotConsistency {@link #setSnapshotConsistency(boolean)}
22 * @param allowGlobalSeqNo {@link #setAllowGlobalSeqNo(boolean)}
23 * @param allowBlockingFlush {@link #setAllowBlockingFlush(boolean)}
24 */
25 public IngestExternalFileOptions(final boolean moveFiles,
26 final boolean snapshotConsistency, final boolean allowGlobalSeqNo,
27 final boolean allowBlockingFlush) {
28 super(newIngestExternalFileOptions(moveFiles, snapshotConsistency,
29 allowGlobalSeqNo, allowBlockingFlush));
30 }
31
32 /**
33 * Can be set to true to move the files instead of copying them.
34 *
35 * @return true if files will be moved
36 */
37 public boolean moveFiles() {
38 return moveFiles(nativeHandle_);
39 }
40
41 /**
42 * Can be set to true to move the files instead of copying them.
43 *
44 * @param moveFiles true if files should be moved instead of copied
494da23a
TL
45 *
46 * @return the reference to the current IngestExternalFileOptions.
11fdf7f2 47 */
494da23a 48 public IngestExternalFileOptions setMoveFiles(final boolean moveFiles) {
11fdf7f2 49 setMoveFiles(nativeHandle_, moveFiles);
494da23a 50 return this;
11fdf7f2
TL
51 }
52
53 /**
54 * If set to false, an ingested file keys could appear in existing snapshots
55 * that where created before the file was ingested.
56 *
57 * @return true if snapshot consistency is assured
58 */
59 public boolean snapshotConsistency() {
60 return snapshotConsistency(nativeHandle_);
61 }
62
63 /**
64 * If set to false, an ingested file keys could appear in existing snapshots
65 * that where created before the file was ingested.
66 *
67 * @param snapshotConsistency true if snapshot consistency is required
494da23a
TL
68 *
69 * @return the reference to the current IngestExternalFileOptions.
11fdf7f2 70 */
494da23a
TL
71 public IngestExternalFileOptions setSnapshotConsistency(
72 final boolean snapshotConsistency) {
11fdf7f2 73 setSnapshotConsistency(nativeHandle_, snapshotConsistency);
494da23a 74 return this;
11fdf7f2
TL
75 }
76
77 /**
78 * If set to false, {@link RocksDB#ingestExternalFile(ColumnFamilyHandle, List, IngestExternalFileOptions)}
79 * will fail if the file key range overlaps with existing keys or tombstones in the DB.
80 *
81 * @return true if global seq numbers are assured
82 */
83 public boolean allowGlobalSeqNo() {
84 return allowGlobalSeqNo(nativeHandle_);
85 }
86
87 /**
88 * If set to false, {@link RocksDB#ingestExternalFile(ColumnFamilyHandle, List, IngestExternalFileOptions)}
89 * will fail if the file key range overlaps with existing keys or tombstones in the DB.
90 *
91 * @param allowGlobalSeqNo true if global seq numbers are required
494da23a
TL
92 *
93 * @return the reference to the current IngestExternalFileOptions.
11fdf7f2 94 */
494da23a
TL
95 public IngestExternalFileOptions setAllowGlobalSeqNo(
96 final boolean allowGlobalSeqNo) {
11fdf7f2 97 setAllowGlobalSeqNo(nativeHandle_, allowGlobalSeqNo);
494da23a 98 return this;
11fdf7f2
TL
99 }
100
101 /**
102 * If set to false and the file key range overlaps with the memtable key range
103 * (memtable flush required), IngestExternalFile will fail.
104 *
105 * @return true if blocking flushes may occur
106 */
107 public boolean allowBlockingFlush() {
108 return allowBlockingFlush(nativeHandle_);
109 }
110
111 /**
112 * If set to false and the file key range overlaps with the memtable key range
113 * (memtable flush required), IngestExternalFile will fail.
114 *
115 * @param allowBlockingFlush true if blocking flushes are allowed
494da23a
TL
116 *
117 * @return the reference to the current IngestExternalFileOptions.
11fdf7f2 118 */
494da23a
TL
119 public IngestExternalFileOptions setAllowBlockingFlush(
120 final boolean allowBlockingFlush) {
11fdf7f2 121 setAllowBlockingFlush(nativeHandle_, allowBlockingFlush);
494da23a
TL
122 return this;
123 }
124
125 /**
126 * Returns true if duplicate keys in the file being ingested are
127 * to be skipped rather than overwriting existing data under that key.
128 *
129 * @return true if duplicate keys in the file being ingested are to be
130 * skipped, false otherwise.
131 */
132 public boolean ingestBehind() {
133 return ingestBehind(nativeHandle_);
134 }
135
136 /**
137 * Set to true if you would like duplicate keys in the file being ingested
138 * to be skipped rather than overwriting existing data under that key.
139 *
140 * Usecase: back-fill of some historical data in the database without
141 * over-writing existing newer version of data.
142 *
143 * This option could only be used if the DB has been running
144 * with DBOptions#allowIngestBehind() == true since the dawn of time.
145 *
146 * All files will be ingested at the bottommost level with seqno=0.
147 *
148 * Default: false
149 *
150 * @param ingestBehind true if you would like duplicate keys in the file being
151 * ingested to be skipped.
152 *
153 * @return the reference to the current IngestExternalFileOptions.
154 */
155 public IngestExternalFileOptions setIngestBehind(final boolean ingestBehind) {
156 setIngestBehind(nativeHandle_, ingestBehind);
157 return this;
158 }
159
160 /**
161 * Returns true write if the global_seqno is written to a given offset
162 * in the external SST file for backward compatibility.
163 *
164 * See {@link #setWriteGlobalSeqno(boolean)}.
165 *
166 * @return true if the global_seqno is written to a given offset,
167 * false otherwise.
168 */
169 public boolean writeGlobalSeqno() {
170 return writeGlobalSeqno(nativeHandle_);
171 }
172
173 /**
174 * Set to true if you would like to write the global_seqno to a given offset
175 * in the external SST file for backward compatibility.
176 *
177 * Older versions of RocksDB write the global_seqno to a given offset within
178 * the ingested SST files, and new versions of RocksDB do not.
179 *
180 * If you ingest an external SST using new version of RocksDB and would like
181 * to be able to downgrade to an older version of RocksDB, you should set
182 * {@link #writeGlobalSeqno()} to true.
183 *
184 * If your service is just starting to use the new RocksDB, we recommend that
185 * you set this option to false, which brings two benefits:
186 * 1. No extra random write for global_seqno during ingestion.
187 * 2. Without writing external SST file, it's possible to do checksum.
188 *
189 * We have a plan to set this option to false by default in the future.
190 *
191 * Default: true
192 *
193 * @param writeGlobalSeqno true to write the gloal_seqno to a given offset,
194 * false otherwise
195 *
196 * @return the reference to the current IngestExternalFileOptions.
197 */
198 public IngestExternalFileOptions setWriteGlobalSeqno(
199 final boolean writeGlobalSeqno) {
200 setWriteGlobalSeqno(nativeHandle_, writeGlobalSeqno);
201 return this;
11fdf7f2
TL
202 }
203
204 private native static long newIngestExternalFileOptions();
205 private native static long newIngestExternalFileOptions(
206 final boolean moveFiles, final boolean snapshotConsistency,
207 final boolean allowGlobalSeqNo, final boolean allowBlockingFlush);
494da23a
TL
208 @Override protected final native void disposeInternal(final long handle);
209
11fdf7f2
TL
210 private native boolean moveFiles(final long handle);
211 private native void setMoveFiles(final long handle, final boolean move_files);
212 private native boolean snapshotConsistency(final long handle);
213 private native void setSnapshotConsistency(final long handle,
214 final boolean snapshotConsistency);
215 private native boolean allowGlobalSeqNo(final long handle);
216 private native void setAllowGlobalSeqNo(final long handle,
217 final boolean allowGloablSeqNo);
218 private native boolean allowBlockingFlush(final long handle);
219 private native void setAllowBlockingFlush(final long handle,
220 final boolean allowBlockingFlush);
494da23a
TL
221 private native boolean ingestBehind(final long handle);
222 private native void setIngestBehind(final long handle,
223 final boolean ingestBehind);
224 private native boolean writeGlobalSeqno(final long handle);
225 private native void setWriteGlobalSeqno(final long handle,
226 final boolean writeGlobalSeqNo);
11fdf7f2 227}