]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | |
6 | package org.rocksdb; | |
7 | ||
f67539c2 TL |
8 | import java.nio.ByteBuffer; |
9 | ||
7c673cae FG |
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 | |
11fdf7f2 | 23 | public void put(byte[] key, byte[] value) throws RocksDBException { |
7c673cae FG |
24 | put(nativeHandle_, key, key.length, value, value.length); |
25 | } | |
26 | ||
27 | @Override | |
28 | public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, | |
11fdf7f2 | 29 | byte[] value) throws RocksDBException { |
7c673cae FG |
30 | put(nativeHandle_, key, key.length, value, value.length, |
31 | columnFamilyHandle.nativeHandle_); | |
32 | } | |
33 | ||
34 | @Override | |
11fdf7f2 | 35 | public void merge(byte[] key, byte[] value) throws RocksDBException { |
7c673cae FG |
36 | merge(nativeHandle_, key, key.length, value, value.length); |
37 | } | |
38 | ||
39 | @Override | |
40 | public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, | |
11fdf7f2 | 41 | byte[] value) throws RocksDBException { |
7c673cae FG |
42 | merge(nativeHandle_, key, key.length, value, value.length, |
43 | columnFamilyHandle.nativeHandle_); | |
44 | } | |
45 | ||
46 | @Override | |
1e59de90 | 47 | public void put(final ByteBuffer key, final ByteBuffer value) throws RocksDBException { |
f67539c2 TL |
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 | |
1e59de90 TL |
56 | public void put(ColumnFamilyHandle columnFamilyHandle, final ByteBuffer key, |
57 | final ByteBuffer value) throws RocksDBException { | |
f67539c2 TL |
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 | ||
7c673cae | 65 | @Override |
11fdf7f2 TL |
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 | ||
1e59de90 TL |
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 | } | |
11fdf7f2 TL |
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 { | |
7c673cae FG |
104 | deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length); |
105 | } | |
106 | ||
107 | @Override | |
11fdf7f2 TL |
108 | public void deleteRange(ColumnFamilyHandle columnFamilyHandle, |
109 | byte[] beginKey, byte[] endKey) throws RocksDBException { | |
7c673cae FG |
110 | deleteRange(nativeHandle_, beginKey, beginKey.length, endKey, endKey.length, |
111 | columnFamilyHandle.nativeHandle_); | |
112 | } | |
113 | ||
114 | @Override | |
11fdf7f2 | 115 | public void putLogData(byte[] blob) throws RocksDBException { |
7c673cae FG |
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 | ||
11fdf7f2 TL |
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 | ||
7c673cae FG |
149 | abstract int count0(final long handle); |
150 | ||
151 | abstract void put(final long handle, final byte[] key, final int keyLen, | |
11fdf7f2 | 152 | final byte[] value, final int valueLen) throws RocksDBException; |
7c673cae FG |
153 | |
154 | abstract void put(final long handle, final byte[] key, final int keyLen, | |
11fdf7f2 TL |
155 | final byte[] value, final int valueLen, final long cfHandle) |
156 | throws RocksDBException; | |
7c673cae | 157 | |
f67539c2 TL |
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 | ||
7c673cae | 162 | abstract void merge(final long handle, final byte[] key, final int keyLen, |
11fdf7f2 | 163 | final byte[] value, final int valueLen) throws RocksDBException; |
7c673cae FG |
164 | |
165 | abstract void merge(final long handle, final byte[] key, final int keyLen, | |
11fdf7f2 TL |
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; | |
7c673cae | 174 | |
1e59de90 TL |
175 | abstract void singleDelete(final long handle, final byte[] key, final int keyLen) |
176 | throws RocksDBException; | |
7c673cae | 177 | |
1e59de90 TL |
178 | abstract void singleDelete(final long handle, final byte[] key, final int keyLen, |
179 | final long cfHandle) throws RocksDBException; | |
7c673cae | 180 | |
1e59de90 | 181 | abstract void deleteDirect(final long handle, final ByteBuffer key, final int keyOffset, |
f67539c2 TL |
182 | final int keyLength, final long cfHandle) throws RocksDBException; |
183 | ||
7c673cae | 184 | abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen, |
11fdf7f2 | 185 | final byte[] endKey, final int endKeyLen) throws RocksDBException; |
7c673cae FG |
186 | |
187 | abstract void deleteRange(final long handle, final byte[] beginKey, final int beginKeyLen, | |
11fdf7f2 | 188 | final byte[] endKey, final int endKeyLen, final long cfHandle) throws RocksDBException; |
7c673cae FG |
189 | |
190 | abstract void putLogData(final long handle, final byte[] blob, | |
11fdf7f2 | 191 | final int blobLen) throws RocksDBException; |
7c673cae FG |
192 | |
193 | abstract void clear0(final long handle); | |
194 | ||
195 | abstract void setSavePoint0(final long handle); | |
196 | ||
197 | abstract void rollbackToSavePoint0(final long handle); | |
11fdf7f2 TL |
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); | |
7c673cae | 204 | } |