@Test public void remove() throws KitDBException { String head = "remove0"; RSet set = db.getSet(); int num = 10 * 10000; try { for (int i = 0; i < num; i++) { set.add(head, ("hello world" + i).getBytes()); } for (int i = 0; i < num; i++) { set.remove(head, ("hello world" + i).getBytes()); Assert.assertEquals(num - (i + 1), set.size(head)); } for (int i = 0; i < num; i++) { Assert.assertTrue(!set.contains(head, ("hello world" + i).getBytes())); } } finally { set.delete(head); } }
public void remove(String key, byte[]... values) throws KitDBException { checkTxStart(); try (CloseLock ignored = checkClose()) { DAssert.notEmpty(values, ErrorType.EMPTY, "values is empty"); LockEntity lockEntity = lock(key); try { byte[] key_b = getKey(key); MetaV metaV = getMeta(key_b); if (metaV == null) { checkTxCommit(); return; } List<byte[]> dels = new ArrayList<>(); for (byte[] v : values) { SData sData = new SData(key_b.length, key_b, metaV.getVersion(), v); SDataD sDataD = sData.convertBytes(); byte[] scoreD = getDB(sDataD.toBytes(), SstColumnFamily.DEFAULT); if (scoreD != null) { dels.add(sDataD.toBytes()); } } start(); removeDo(metaV, dels); putDB(key_b, metaV.convertMetaBytes().toBytes(), SstColumnFamily.META); commit(); } catch (Exception e) { unlock(lockEntity); release(); } checkTxCommit(); } catch (KitDBException e) { checkTxRollBack(); throw e; } }
RSet extends RCollection { public void remove(String key, byte[]... values) throws KitDBException { checkTxStart(); try (CloseLock ignored = checkClose()) { DAssert.notEmpty(values, ErrorType.EMPTY, "values is empty"); LockEntity lockEntity = lock(key); try { byte[] key_b = getKey(key); MetaV metaV = getMeta(key_b); if (metaV == null) { checkTxCommit(); return; } List<byte[]> dels = new ArrayList<>(); for (byte[] v : values) { SData sData = new SData(key_b.length, key_b, metaV.getVersion(), v); SDataD sDataD = sData.convertBytes(); byte[] scoreD = getDB(sDataD.toBytes(), SstColumnFamily.DEFAULT); if (scoreD != null) { dels.add(sDataD.toBytes()); } } start(); removeDo(metaV, dels); putDB(key_b, metaV.convertMetaBytes().toBytes(), SstColumnFamily.META); commit(); } catch (Exception e) { unlock(lockEntity); release(); } checkTxCommit(); } catch (KitDBException e) { checkTxRollBack(); throw e; } } }
RSet extends RCollection { public void remove(String key, byte[]... values) throws KitDBException { checkTxStart(); try (CloseLock ignored = checkClose()) { DAssert.notEmpty(values, ErrorType.EMPTY, "values is empty"); LockEntity lockEntity = lock(key); try { byte[] key_b = getKey(key); MetaV metaV = getMeta(key_b); if (metaV == null) { checkTxCommit(); return; } List<byte[]> dels = new ArrayList<>(); for (byte[] v : values) { SData sData = new SData(key_b.length, key_b, metaV.getVersion(), v); SDataD sDataD = sData.convertBytes(); byte[] scoreD = getDB(sDataD.toBytes(), SstColumnFamily.DEFAULT); if (scoreD != null) { dels.add(sDataD.toBytes()); } } start(); removeDo(metaV, dels); putDB(key_b, metaV.convertMetaBytes().toBytes(), SstColumnFamily.META); commit(); } catch (Exception e) { unlock(lockEntity); release(); } checkTxCommit(); } catch (KitDBException e) { checkTxRollBack(); throw e; } } protected  RSet(DB db); }
RSet extends RCollection { public void remove(String key, byte[]... values) throws KitDBException { checkTxStart(); try (CloseLock ignored = checkClose()) { DAssert.notEmpty(values, ErrorType.EMPTY, "values is empty"); LockEntity lockEntity = lock(key); try { byte[] key_b = getKey(key); MetaV metaV = getMeta(key_b); if (metaV == null) { checkTxCommit(); return; } List<byte[]> dels = new ArrayList<>(); for (byte[] v : values) { SData sData = new SData(key_b.length, key_b, metaV.getVersion(), v); SDataD sDataD = sData.convertBytes(); byte[] scoreD = getDB(sDataD.toBytes(), SstColumnFamily.DEFAULT); if (scoreD != null) { dels.add(sDataD.toBytes()); } } start(); removeDo(metaV, dels); putDB(key_b, metaV.convertMetaBytes().toBytes(), SstColumnFamily.META); commit(); } catch (Exception e) { unlock(lockEntity); release(); } checkTxCommit(); } catch (KitDBException e) { checkTxRollBack(); throw e; } } protected  RSet(DB db); List<byte[]> pop(String key, int num); void remove(String key, byte[]... values); boolean contains(String key, byte[] value); void addMayTTL(String key, int ttl, byte[]... values); void add(String key, byte[]... values); @Override void delete(String key); @Override KeyIterator getKeyIterator(); void deleteFast(String key); @Override @SuppressWarnings("unchecked") RIterator<RSet> iterator(String key); @Override int getTtl(String key); @Override void delTtl(String key); @Override void ttl(String key, int ttl); @Override boolean isExist(String key); @Override int size(String key); @Override Entry getEntry(RocksIterator iterator); }
RSet extends RCollection { public void remove(String key, byte[]... values) throws KitDBException { checkTxStart(); try (CloseLock ignored = checkClose()) { DAssert.notEmpty(values, ErrorType.EMPTY, "values is empty"); LockEntity lockEntity = lock(key); try { byte[] key_b = getKey(key); MetaV metaV = getMeta(key_b); if (metaV == null) { checkTxCommit(); return; } List<byte[]> dels = new ArrayList<>(); for (byte[] v : values) { SData sData = new SData(key_b.length, key_b, metaV.getVersion(), v); SDataD sDataD = sData.convertBytes(); byte[] scoreD = getDB(sDataD.toBytes(), SstColumnFamily.DEFAULT); if (scoreD != null) { dels.add(sDataD.toBytes()); } } start(); removeDo(metaV, dels); putDB(key_b, metaV.convertMetaBytes().toBytes(), SstColumnFamily.META); commit(); } catch (Exception e) { unlock(lockEntity); release(); } checkTxCommit(); } catch (KitDBException e) { checkTxRollBack(); throw e; } } protected  RSet(DB db); List<byte[]> pop(String key, int num); void remove(String key, byte[]... values); boolean contains(String key, byte[] value); void addMayTTL(String key, int ttl, byte[]... values); void add(String key, byte[]... values); @Override void delete(String key); @Override KeyIterator getKeyIterator(); void deleteFast(String key); @Override @SuppressWarnings("unchecked") RIterator<RSet> iterator(String key); @Override int getTtl(String key); @Override void delTtl(String key); @Override void ttl(String key, int ttl); @Override boolean isExist(String key); @Override int size(String key); @Override Entry getEntry(RocksIterator iterator); final static String HEAD; final static byte[] HEAD_B; final static byte[] HEAD_V_B; }