]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/AbstractWriteBatch.java
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / AbstractWriteBatch.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5
6 package org.rocksdb;
7
8 import java.nio.ByteBuffer;
9
10 public abstract class AbstractWriteBatch extends RocksObject
11 implements WriteBatchInterface {
12
13 protected AbstractWriteBatch(final long nativeHandle) {
14 super(nativeHandle);
15 }
16
17 @Override
18 public int count() {
19 return count0(nativeHandle_);
20 }
21
22 @Override
23 public void put(byte[] key, byte[] value) throws RocksDBException {
24 put(nativeHandle_, key, key.length, value, value.length);
25 }
26
27 @Override
28 public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key,
29 byte[] value) throws RocksDBException {
30 put(nativeHandle_, key, key.length, value, value.length,
31 columnFamilyHandle.nativeHandle_);
32 }
33
34 @Override
35 public void merge(byte[] key, byte[] value) throws RocksDBException {
36 merge(nativeHandle_, key, key.length, value, value.length);
37 }
38
39 @Override
40 public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key,
41 byte[] value) throws RocksDBException {
42 merge(nativeHandle_, key, key.length, value, value.length,
43 columnFamilyHandle.nativeHandle_);
44 }
45
46 @Override
47 @Deprecated
48 public void remove(byte[] key) throws RocksDBException {
49 delete(nativeHandle_, key, key.length);
50 }
51
52 @Override
53 @Deprecated
54 public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key)
55 throws RocksDBException {
56 delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
57 }
58
59 public void put(ByteBuffer key, ByteBuffer value) throws RocksDBException {
60 assert key.isDirect() && value.isDirect();
61 putDirect(nativeHandle_, key, key.position(), key.remaining(), value, value.position(),
62 value.remaining(), 0);
63 key.position(key.limit());
64 value.position(value.limit());
65 }
66
67 @Override
68 public void put(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, ByteBuffer value)
69 throws RocksDBException {
70 assert key.isDirect() && value.isDirect();
71 putDirect(nativeHandle_, key, key.position(), key.remaining(), value, value.position(),
72 value.remaining(), columnFamilyHandle.nativeHandle_);
73 key.position(key.limit());
74 value.position(value.limit());
75 }
76
77 @Override
78 public void delete(byte[] key) throws RocksDBException {
79 delete(nativeHandle_, key, key.length);
80 }
81
82 @Override
83 public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key)
84 throws RocksDBException {
85 delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
86 }
87
88
89 @Override
90 public void singleDelete(byte[] key) throws RocksDBException {
91 singleDelete(nativeHandle_, key, key.length);
92 }
93
94 @Override
95 public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key)
96 throws RocksDBException {
97 singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
98 }
99
100 @Override
101 public void deleteRange(byte[] beginKey, byte[] endKey)
102 throws RocksDBException {
103 deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length);
104 }
105
106 @Override
107 public void deleteRange(ColumnFamilyHandle columnFamilyHandle,
108 byte[] beginKey, byte[] endKey) throws RocksDBException {
109 deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length,
110 columnFamilyHandle.nativeHandle_);
111 }
112
113 public void remove(ByteBuffer key) throws RocksDBException {
114 removeDirect(nativeHandle_, key, key.position(), key.remaining(), 0);
115 key.position(key.limit());
116 }
117
118 @Override
119 public void remove(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key)
120 throws RocksDBException {
121 removeDirect(
122 nativeHandle_, key, key.position(), key.remaining(), columnFamilyHandle.nativeHandle_);
123 key.position(key.limit());
124 }
125
126 @Override
127 public void putLogData(byte[] blob) throws RocksDBException {
128 putLogData(nativeHandle_, blob, blob.length);
129 }
130
131 @Override
132 public void clear() {
133 clear0(nativeHandle_);
134 }
135
136 @Override
137 public void setSavePoint() {
138 setSavePoint0(nativeHandle_);
139 }
140
141 @Override
142 public void rollbackToSavePoint() throws RocksDBException {
143 rollbackToSavePoint0(nativeHandle_);
144 }
145
146 @Override
147 public void popSavePoint() throws RocksDBException {
148 popSavePoint(nativeHandle_);
149 }
150
151 @Override
152 public void setMaxBytes(final long maxBytes) {
153 setMaxBytes(nativeHandle_, maxBytes);
154 }
155
156 @Override
157 public WriteBatch getWriteBatch() {
158 return getWriteBatch(nativeHandle_);
159 }
160
161 abstract int count0(final long handle);
162
163 abstract void put(final long handle, final byte[] key, final int keyLen,
164 final byte[] value, final int valueLen) throws RocksDBException;
165
166 abstract void put(final long handle, final byte[] key, final int keyLen,
167 final byte[] value, final int valueLen, final long cfHandle)
168 throws RocksDBException;
169
170 abstract void putDirect(final long handle, final ByteBuffer key, final int keyOffset,
171 final int keyLength, final ByteBuffer value, final int valueOffset, final int valueLength,
172 final long cfHandle) throws RocksDBException;
173
174 abstract void merge(final long handle, final byte[] key, final int keyLen,
175 final byte[] value, final int valueLen) throws RocksDBException;
176
177 abstract void merge(final long handle, final byte[] key, final int keyLen,
178 final byte[] value, final int valueLen, final long cfHandle)
179 throws RocksDBException;
180
181 abstract void delete(final long handle, final byte[] key,
182 final int keyLen) throws RocksDBException;
183
184 abstract void delete(final long handle, final byte[] key,
185 final int keyLen, final long cfHandle) throws RocksDBException;
186
187 abstract void singleDelete(final long handle, final byte[] key,
188 final int keyLen) throws RocksDBException;
189
190 abstract void singleDelete(final long handle, final byte[] key,
191 final int keyLen, final long cfHandle) throws RocksDBException;
192
193 abstract void removeDirect(final long handle, final ByteBuffer key, final int keyOffset,
194 final int keyLength, final long cfHandle) throws RocksDBException;
195
196 abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen,
197 final byte[] endKey, final int endKeyLen) throws RocksDBException;
198
199 abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen,
200 final byte[] endKey, final int endKeyLen, final long cfHandle) throws RocksDBException;
201
202 abstract void putLogData(final long handle, final byte[] blob,
203 final int blobLen) throws RocksDBException;
204
205 abstract void clear0(final long handle);
206
207 abstract void setSavePoint0(final long handle);
208
209 abstract void rollbackToSavePoint0(final long handle);
210
211 abstract void popSavePoint(final long handle) throws RocksDBException;
212
213 abstract void setMaxBytes(final long handle, long maxBytes);
214
215 abstract WriteBatch getWriteBatch(final long handle);
216 }