]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/AbstractWriteBatch.java
update ceph source to reef 18.1.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 public void put(final ByteBuffer key, final ByteBuffer value) throws RocksDBException {
48 assert key.isDirect() && value.isDirect();
49 putDirect(nativeHandle_, key, key.position(), key.remaining(), value, value.position(),
50 value.remaining(), 0);
51 key.position(key.limit());
52 value.position(value.limit());
53 }
54
55 @Override
56 public void put(ColumnFamilyHandle columnFamilyHandle, final ByteBuffer key,
57 final ByteBuffer value) throws RocksDBException {
58 assert key.isDirect() && value.isDirect();
59 putDirect(nativeHandle_, key, key.position(), key.remaining(), value, value.position(),
60 value.remaining(), columnFamilyHandle.nativeHandle_);
61 key.position(key.limit());
62 value.position(value.limit());
63 }
64
65 @Override
66 public void delete(byte[] key) throws RocksDBException {
67 delete(nativeHandle_, key, key.length);
68 }
69
70 @Override
71 public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key)
72 throws RocksDBException {
73 delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
74 }
75
76 @Override
77 public void delete(final ByteBuffer key) throws RocksDBException {
78 deleteDirect(nativeHandle_, key, key.position(), key.remaining(), 0);
79 key.position(key.limit());
80 }
81
82 @Override
83 public void delete(ColumnFamilyHandle columnFamilyHandle, final ByteBuffer key)
84 throws RocksDBException {
85 deleteDirect(
86 nativeHandle_, key, key.position(), key.remaining(), columnFamilyHandle.nativeHandle_);
87 key.position(key.limit());
88 }
89
90 @Override
91 public void singleDelete(byte[] key) throws RocksDBException {
92 singleDelete(nativeHandle_, key, key.length);
93 }
94
95 @Override
96 public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key)
97 throws RocksDBException {
98 singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
99 }
100
101 @Override
102 public void deleteRange(byte[] beginKey, byte[] endKey)
103 throws RocksDBException {
104 deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length);
105 }
106
107 @Override
108 public void deleteRange(ColumnFamilyHandle columnFamilyHandle,
109 byte[] beginKey, byte[] endKey) throws RocksDBException {
110 deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length,
111 columnFamilyHandle.nativeHandle_);
112 }
113
114 @Override
115 public void putLogData(byte[] blob) throws RocksDBException {
116 putLogData(nativeHandle_, blob, blob.length);
117 }
118
119 @Override
120 public void clear() {
121 clear0(nativeHandle_);
122 }
123
124 @Override
125 public void setSavePoint() {
126 setSavePoint0(nativeHandle_);
127 }
128
129 @Override
130 public void rollbackToSavePoint() throws RocksDBException {
131 rollbackToSavePoint0(nativeHandle_);
132 }
133
134 @Override
135 public void popSavePoint() throws RocksDBException {
136 popSavePoint(nativeHandle_);
137 }
138
139 @Override
140 public void setMaxBytes(final long maxBytes) {
141 setMaxBytes(nativeHandle_, maxBytes);
142 }
143
144 @Override
145 public WriteBatch getWriteBatch() {
146 return getWriteBatch(nativeHandle_);
147 }
148
149 abstract int count0(final long handle);
150
151 abstract void put(final long handle, final byte[] key, final int keyLen,
152 final byte[] value, final int valueLen) throws RocksDBException;
153
154 abstract void put(final long handle, final byte[] key, final int keyLen,
155 final byte[] value, final int valueLen, final long cfHandle)
156 throws RocksDBException;
157
158 abstract void putDirect(final long handle, final ByteBuffer key, final int keyOffset,
159 final int keyLength, final ByteBuffer value, final int valueOffset, final int valueLength,
160 final long cfHandle) throws RocksDBException;
161
162 abstract void merge(final long handle, final byte[] key, final int keyLen,
163 final byte[] value, final int valueLen) throws RocksDBException;
164
165 abstract void merge(final long handle, final byte[] key, final int keyLen,
166 final byte[] value, final int valueLen, final long cfHandle)
167 throws RocksDBException;
168
169 abstract void delete(final long handle, final byte[] key,
170 final int keyLen) throws RocksDBException;
171
172 abstract void delete(final long handle, final byte[] key,
173 final int keyLen, final long cfHandle) throws RocksDBException;
174
175 abstract void singleDelete(final long handle, final byte[] key, final int keyLen)
176 throws RocksDBException;
177
178 abstract void singleDelete(final long handle, final byte[] key, final int keyLen,
179 final long cfHandle) throws RocksDBException;
180
181 abstract void deleteDirect(final long handle, final ByteBuffer key, final int keyOffset,
182 final int keyLength, final long cfHandle) throws RocksDBException;
183
184 abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen,
185 final byte[] endKey, final int endKeyLen) throws RocksDBException;
186
187 abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen,
188 final byte[] endKey, final int endKeyLen, final long cfHandle) throws RocksDBException;
189
190 abstract void putLogData(final long handle, final byte[] blob,
191 final int blobLen) throws RocksDBException;
192
193 abstract void clear0(final long handle);
194
195 abstract void setSavePoint0(final long handle);
196
197 abstract void rollbackToSavePoint0(final long handle);
198
199 abstract void popSavePoint(final long handle) throws RocksDBException;
200
201 abstract void setMaxBytes(final long handle, long maxBytes);
202
203 abstract WriteBatch getWriteBatch(final long handle);
204 }