Beispiel #1
0
 /**
  * Check that a record entry exists in the entry tree.
  *
  * @param txn a non null transaction
  * @param entryID The entry ID which forms the key.
  * @return True if an entry with entryID exists
  * @throws StorageRuntimeException If an error occurs in the storage.
  */
 public boolean containsEntryID(ReadableTransaction txn, EntryID entryID) {
   checkNotNull(txn, "txn must not be null");
   checkNotNull(entryID, "entryID must not be null");
   try (final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) {
     return cursor.positionToKey(entryID.toByteString());
   }
 }
Beispiel #2
0
 @Override
 void open0(WriteableTransaction txn) throws StorageRuntimeException {
   // Make sure the tree is there and readable, even if the storage is READ_ONLY.
   // Would be nice if there were a better way...
   try (final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) {
     cursor.next();
   }
 }
 @Override
 public KO getKey() {
   if (cachedTransformedKey == null) {
     try {
       cachedTransformedKey = keyTransformer.apply(input.getKey());
     } catch (Exception e) {
       throw new TransformationException(e, input.getKey(), input.getValue());
     }
   }
   return cachedTransformedKey;
 }
 @Override
 public VO getValue() {
   if (cachedTransformedValue == null) {
     try {
       cachedTransformedValue = valueTransformer.transform(input.getKey(), input.getValue());
     } catch (Exception e) {
       throw new TransformationException(e, input.getKey(), input.getValue());
     }
   }
   return cachedTransformedValue;
 }
 @Override
 public void close() {
   input.close();
 }
 @Override
 public boolean isDefined() {
   return input.isDefined();
 }
 @Override
 public boolean positionToIndex(int index) {
   return input.positionToIndex(index);
 }
 @Override
 public boolean positionToLastKey() {
   clearCache();
   return input.positionToLastKey();
 }
 @Override
 public boolean positionToKeyOrNext(final ByteSequence key) {
   clearCache();
   return input.positionToKeyOrNext(key);
 }
 @Override
 public boolean next() {
   clearCache();
   return input.next();
 }