@Test public void add() throws KitDBException { String head = "add0"; ZSet set = db.getzSet(); int num = 10 * 10000; try { for (int i = 0; i < num; i++) { set.add(head, ("hello world" + i).getBytes(), i); } for (int i = 0; i < num; i++) { Assert.assertTrue(set.contains(head, ("hello world" + i).getBytes())); long score = set.score(head, ("hello world" + i).getBytes()); Assert.assertEquals(i, score); } Assert.assertEquals(num, set.size(head)); } finally { set.delete(head); } try { JoinFuture<String> joinFuture = JoinFuture.build(executorService, String.class); for (int i = 0; i < num; i++) { int fj = i; joinFuture.add(args -> { try { set.add(head, ("hello world" + fj).getBytes(), fj); } catch (Exception e) { e.printStackTrace(); } return ""; }); } joinFuture.join(); for (int i = 0; i < num; i++) { Assert.assertTrue(set.contains(head, ("hello world" + i).getBytes())); long score = set.score(head, ("hello world" + i).getBytes()); Assert.assertEquals(i, score); } Assert.assertEquals(num, set.size(head)); } finally { set.delete(head); } }
public void add(String key, byte[] v, long score) throws KitDBException { addMayTTL(key, -1, new Entry(score, v)); }
ZSet extends RCollection { public void add(String key, byte[] v, long score) throws KitDBException { addMayTTL(key, -1, new Entry(score, v)); } }
ZSet extends RCollection { public void add(String key, byte[] v, long score) throws KitDBException { addMayTTL(key, -1, new Entry(score, v)); } protected  ZSet(DB db); }
ZSet extends RCollection { public void add(String key, byte[] v, long score) throws KitDBException { addMayTTL(key, -1, new Entry(score, v)); } protected  ZSet(DB db); void add(String key, byte[] v, long score); void add(String key, List<Entry> entryList); void addMayTTL(String key, int ttl, byte[] v, long score); boolean contains(String key, byte[] value); List<Entry> range(String key, long start, long end, int limit); List<Entry> rangeDel(String key, long start, long end, int limit); @Override @SuppressWarnings("unchecked") RIterator<ZSet> iterator(String key); void remove(String key, byte[]... vs); List<Long> score(String key, byte[]... vs); Long score(String key, byte[] v); @Override void delete(String key); @Override KeyIterator getKeyIterator(); void deleteFast(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); }
ZSet extends RCollection { public void add(String key, byte[] v, long score) throws KitDBException { addMayTTL(key, -1, new Entry(score, v)); } protected  ZSet(DB db); void add(String key, byte[] v, long score); void add(String key, List<Entry> entryList); void addMayTTL(String key, int ttl, byte[] v, long score); boolean contains(String key, byte[] value); List<Entry> range(String key, long start, long end, int limit); List<Entry> rangeDel(String key, long start, long end, int limit); @Override @SuppressWarnings("unchecked") RIterator<ZSet> iterator(String key); void remove(String key, byte[]... vs); List<Long> score(String key, byte[]... vs); Long score(String key, byte[] v); @Override void delete(String key); @Override KeyIterator getKeyIterator(); void deleteFast(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); static String HEAD; static byte[] HEAD_B; static byte[] HEAD_SCORE_B; static byte[] HEAD_V_B; }