MCPcopy Create free account
hub / github.com/bytedance/terarkdb / write

Method write

java/src/test/java/org/rocksdb/RocksDBTest.java:129–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127 }
128
129 @Test
130 public void write() throws RocksDBException {
131 try (final StringAppendOperator stringAppendOperator = new StringAppendOperator();
132 final Options options = new Options()
133 .setMergeOperator(stringAppendOperator)
134 .setCreateIfMissing(true);
135 final RocksDB db = RocksDB.open(options,
136 dbFolder.getRoot().getAbsolutePath());
137 final WriteOptions opts = new WriteOptions()) {
138
139 try (final WriteBatch wb1 = new WriteBatch()) {
140 wb1.put("key1".getBytes(), "aa".getBytes());
141 wb1.merge("key1".getBytes(), "bb".getBytes());
142
143 try (final WriteBatch wb2 = new WriteBatch()) {
144 wb2.put("key2".getBytes(), "xx".getBytes());
145 wb2.merge("key2".getBytes(), "yy".getBytes());
146 db.write(opts, wb1);
147 db.write(opts, wb2);
148 }
149 }
150
151 assertThat(db.get("key1".getBytes())).isEqualTo(
152 "aa,bb".getBytes());
153 assertThat(db.get("key2".getBytes())).isEqualTo(
154 "xx,yy".getBytes());
155 }
156 }
157
158 @Test
159 public void getWithOutValue() throws RocksDBException {

Callers 7

callMethod · 0.45
writeBatchMethod · 0.45
deleteRangeMethod · 0.45
deleteRangeMethod · 0.45

Calls 6

openMethod · 0.95
setCreateIfMissingMethod · 0.65
setMergeOperatorMethod · 0.65
putMethod · 0.65
mergeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected