@Override public void close() throws FailStoreException { db.close(); }
@Override public void open() throws FailStoreException { try { db.init(); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void put(String key, Object value) throws FailStoreException { try { String valueString = JSON.toJSONString(value); db.put(key, valueString); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (db.size() == 0) { return list; } DBIterator<Entry<String, String>> iterator = db.iterator(); while (iterator.hasNext()) { Entry<String, String> entry = iterator.next(); String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; }
@Override public void delete(List<String> keys) throws FailStoreException { if (keys == null || keys.size() == 0) { return; } try { for (String key : keys) { db.remove(key); } } catch (Exception e) { throw new FailStoreException(e); } }
@Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (db.size() == 0) { return list; } DBIterator<Entry<String, String>> iterator = db.iterator(); while (iterator.hasNext()) { Entry<String, String> entry = iterator.next(); String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; }
@Override public void delete(String key) throws FailStoreException { try { db.remove(key); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (db.size() == 0) { return list; } DBIterator<Entry<String, String>> iterator = db.iterator(); while (iterator.hasNext()) { Entry<String, String> entry = iterator.next(); String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; }
@Override public void delete(String key) throws FailStoreException { try { db.remove(key); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void close() throws FailStoreException { db.close(); }
@Override public void put(String key, Object value) throws FailStoreException { try { String valueString = JSON.toJSONString(value); db.put(key, valueString); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void open() throws FailStoreException { try { db.init(); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void delete(List<String> keys) throws FailStoreException { if (keys == null || keys.size() == 0) { return; } try { for (String key : keys) { db.remove(key); } } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void close() throws FailStoreException { db.close(); }
@Override public void put(String key, Object value) throws FailStoreException { try { String valueString = JSON.toJSONString(value); db.put(key, valueString); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void open() throws FailStoreException { try { db.init(); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void delete(String key) throws FailStoreException { try { db.remove(key); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void delete(List<String> keys) throws FailStoreException { if (keys == null || keys.size() == 0) { return; } try { for (String key : keys) { db.remove(key); } } catch (Exception e) { throw new FailStoreException(e); } }