@Test public void get() throws Exception { RKv kv = db.getrKv(); String head = "getA"; kv.delPrefix(head); }
public Map<String, byte[]> get(List<String> keys) throws KitDBException { Map<String, byte[]> map = null; try (CloseLock ignored = checkClose()) { DAssert.notEmpty(keys, ErrorType.EMPTY, "keys is empty"); byte[][] keybs = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) { keybs[i] = getKey(keys.get(i)); } List<byte[]> vKeys = new ArrayList<>(keybs.length); for (byte[] key : keybs) { vKeys.add(ArrayKits.addAll(HEAD_TTL, key)); vKeys.add(ArrayKits.addAll(HEAD_B, key)); } vKeys.addAll(vKeys); Map<String, byte[]> resMap = transMap(multiGet(vKeys, SstColumnFamily.DEFAULT)); map = new HashMap<>(keybs.length); for (byte[] key : keybs) { byte[] ttl_bs = resMap.get(new String(ArrayKits.addAll(HEAD_TTL, key))); if (ttl_bs == null) { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } else { int time = ArrayKits.bytesToInt(ttl_bs, 0); if ((System.currentTimeMillis() / 1000) - time <= 0) { map.put(new String(key, charset), null); } else { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } } } } return map; }
RKv extends RBase { public Map<String, byte[]> get(List<String> keys) throws KitDBException { Map<String, byte[]> map = null; try (CloseLock ignored = checkClose()) { DAssert.notEmpty(keys, ErrorType.EMPTY, "keys is empty"); byte[][] keybs = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) { keybs[i] = getKey(keys.get(i)); } List<byte[]> vKeys = new ArrayList<>(keybs.length); for (byte[] key : keybs) { vKeys.add(ArrayKits.addAll(HEAD_TTL, key)); vKeys.add(ArrayKits.addAll(HEAD_B, key)); } vKeys.addAll(vKeys); Map<String, byte[]> resMap = transMap(multiGet(vKeys, SstColumnFamily.DEFAULT)); map = new HashMap<>(keybs.length); for (byte[] key : keybs) { byte[] ttl_bs = resMap.get(new String(ArrayKits.addAll(HEAD_TTL, key))); if (ttl_bs == null) { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } else { int time = ArrayKits.bytesToInt(ttl_bs, 0); if ((System.currentTimeMillis() / 1000) - time <= 0) { map.put(new String(key, charset), null); } else { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } } } } return map; } }
RKv extends RBase { public Map<String, byte[]> get(List<String> keys) throws KitDBException { Map<String, byte[]> map = null; try (CloseLock ignored = checkClose()) { DAssert.notEmpty(keys, ErrorType.EMPTY, "keys is empty"); byte[][] keybs = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) { keybs[i] = getKey(keys.get(i)); } List<byte[]> vKeys = new ArrayList<>(keybs.length); for (byte[] key : keybs) { vKeys.add(ArrayKits.addAll(HEAD_TTL, key)); vKeys.add(ArrayKits.addAll(HEAD_B, key)); } vKeys.addAll(vKeys); Map<String, byte[]> resMap = transMap(multiGet(vKeys, SstColumnFamily.DEFAULT)); map = new HashMap<>(keybs.length); for (byte[] key : keybs) { byte[] ttl_bs = resMap.get(new String(ArrayKits.addAll(HEAD_TTL, key))); if (ttl_bs == null) { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } else { int time = ArrayKits.bytesToInt(ttl_bs, 0); if ((System.currentTimeMillis() / 1000) - time <= 0) { map.put(new String(key, charset), null); } else { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } } } } return map; } protected  RKv(DB db); }
RKv extends RBase { public Map<String, byte[]> get(List<String> keys) throws KitDBException { Map<String, byte[]> map = null; try (CloseLock ignored = checkClose()) { DAssert.notEmpty(keys, ErrorType.EMPTY, "keys is empty"); byte[][] keybs = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) { keybs[i] = getKey(keys.get(i)); } List<byte[]> vKeys = new ArrayList<>(keybs.length); for (byte[] key : keybs) { vKeys.add(ArrayKits.addAll(HEAD_TTL, key)); vKeys.add(ArrayKits.addAll(HEAD_B, key)); } vKeys.addAll(vKeys); Map<String, byte[]> resMap = transMap(multiGet(vKeys, SstColumnFamily.DEFAULT)); map = new HashMap<>(keybs.length); for (byte[] key : keybs) { byte[] ttl_bs = resMap.get(new String(ArrayKits.addAll(HEAD_TTL, key))); if (ttl_bs == null) { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } else { int time = ArrayKits.bytesToInt(ttl_bs, 0); if ((System.currentTimeMillis() / 1000) - time <= 0) { map.put(new String(key, charset), null); } else { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } } } } return map; } protected  RKv(DB db); void set(String key, byte[] value); long incr(String key, int step, int ttl); long incr(String key, int step); void set(Map<String, byte[]> map); void set(Map<String, byte[]> map, int ttl); void set(String key, byte[] value, int ttl); void ttl(String key, int ttl); Map<String, byte[]> get(List<String> keys); byte[] get(String key); byte[] getNoTTL(String key); void del(String key); void delPrefix(String key_); List<String> keys(String key_, int start, int limit); }
RKv extends RBase { public Map<String, byte[]> get(List<String> keys) throws KitDBException { Map<String, byte[]> map = null; try (CloseLock ignored = checkClose()) { DAssert.notEmpty(keys, ErrorType.EMPTY, "keys is empty"); byte[][] keybs = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) { keybs[i] = getKey(keys.get(i)); } List<byte[]> vKeys = new ArrayList<>(keybs.length); for (byte[] key : keybs) { vKeys.add(ArrayKits.addAll(HEAD_TTL, key)); vKeys.add(ArrayKits.addAll(HEAD_B, key)); } vKeys.addAll(vKeys); Map<String, byte[]> resMap = transMap(multiGet(vKeys, SstColumnFamily.DEFAULT)); map = new HashMap<>(keybs.length); for (byte[] key : keybs) { byte[] ttl_bs = resMap.get(new String(ArrayKits.addAll(HEAD_TTL, key))); if (ttl_bs == null) { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } else { int time = ArrayKits.bytesToInt(ttl_bs, 0); if ((System.currentTimeMillis() / 1000) - time <= 0) { map.put(new String(key, charset), null); } else { map.put(new String(key, charset), resMap.get(new String((ArrayKits.addAll(HEAD_B, key))))); } } } } return map; } protected  RKv(DB db); void set(String key, byte[] value); long incr(String key, int step, int ttl); long incr(String key, int step); void set(Map<String, byte[]> map); void set(Map<String, byte[]> map, int ttl); void set(String key, byte[] value, int ttl); void ttl(String key, int ttl); Map<String, byte[]> get(List<String> keys); byte[] get(String key); byte[] getNoTTL(String key); void del(String key); void delPrefix(String key_); List<String> keys(String key_, int start, int limit); final static String HEAD; final static byte[] HEAD_TTL; final static byte[] HEAD_B; }