()
| 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 { |
no test coverage detected