/** * If the key definitely does not exist in the database, then this method * returns false, else true. * * This check is potentially lighter-weight than invoking DB::Get(). One way * to make this lighter weight is to avoid doing any IOs. * * @param key byte array of a key to search for * @param value StringBuilder instance which is a out parameter if a value is * found in block-cache. * @return boolean value indicating if key does not exist or might exist. */ public boolean keyMayExist(final byte[] key, final StringBuilder value) { return keyMayExist(nativeHandle_, key, 0, key.length, value); }
/** * If the key definitely does not exist in the database, then this method * returns false, else true. * * This check is potentially lighter-weight than invoking DB::Get(). One way * to make this lighter weight is to avoid doing any IOs. * * @param readOptions {@link ReadOptions} instance * @param key byte array of a key to search for * @param value StringBuilder instance which is a out parameter if a value is * found in block-cache. * @return boolean value indicating if key does not exist or might exist. */ public boolean keyMayExist(final ReadOptions readOptions, final byte[] key, final StringBuilder value) { return keyMayExist(nativeHandle_, readOptions.nativeHandle_, key, 0, key.length, value); }
/** * If the key definitely does not exist in the database, then this method * returns false, else true. * * This check is potentially lighter-weight than invoking DB::Get(). One way * to make this lighter weight is to avoid doing any IOs. * * @param columnFamilyHandle {@link ColumnFamilyHandle} instance * @param key byte array of a key to search for * @param value StringBuilder instance which is a out parameter if a value is * found in block-cache. * @return boolean value indicating if key does not exist or might exist. */ public boolean keyMayExist(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final StringBuilder value) { return keyMayExist(nativeHandle_, key, 0, key.length, columnFamilyHandle.nativeHandle_, value); }
/** * If the key definitely does not exist in the database, then this method * returns false, else true. * * This check is potentially lighter-weight than invoking DB::Get(). One way * to make this lighter weight is to avoid doing any IOs. * * @param readOptions {@link ReadOptions} instance * @param columnFamilyHandle {@link ColumnFamilyHandle} instance * @param key byte array of a key to search for * @param value StringBuilder instance which is a out parameter if a value is * found in block-cache. * @return boolean value indicating if key does not exist or might exist. */ public boolean keyMayExist(final ReadOptions readOptions, final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final StringBuilder value) { return keyMayExist(nativeHandle_, readOptions.nativeHandle_, key, 0, key.length, columnFamilyHandle.nativeHandle_, value); }
private boolean exists(RocksDBReference dbRef, ReadOptions readOptions, byte[] key) { int size = RocksDB.NOT_FOUND; if (dbRef.db().keyMayExist(key, new StringBuilder(0))) { try { size = dbRef.db().get(key, NO_DATA); } catch (RocksDBException e) { throw new RuntimeException(e); } } return size != RocksDB.NOT_FOUND; }
private boolean exists(RocksDBReference dbRef, ReadOptions readOptions, byte[] key) { int size = RocksDB.NOT_FOUND; if (dbRef.db().keyMayExist(key, new StringBuilder(0))) { try { size = dbRef.db().get(key, NO_DATA); } catch (RocksDBException e) { throw Throwables.propagate(e); } } return size != RocksDB.NOT_FOUND; }