/** * Returns an index that maps primary key to entity for the subset of * entities having a given secondary key (duplicates). A sub-index is * convenient when you are interested in working with the subset of * entities having a particular secondary key value. * * <p>When using a {@link Relationship#MANY_TO_ONE MANY_TO_ONE} or {@link * Relationship#MANY_TO_MANY MANY_TO_MANY} secondary key, the sub-index * represents the left (MANY) side of a relationship.</p> * * @param key the secondary key that identifies the entities in the * sub-index. * * @return the sub-index. * * @throws DatabaseException the base class for all BDB exceptions. */ public EntityIndex<PK, E> subIndex(SK key) throws DatabaseException { return new SubIndex(this, entityBinding, key); }
public boolean contains(PK key) throws DatabaseException { return contains(null, key, null); }
public long count(long memoryLimit) throws DatabaseException { return count(); }
public EntityCursor<E> entities(Transaction txn, CursorConfig config) throws DatabaseException { return cursor(txn, null, entityAdapter, config); }
public EntityCursor<PK> keys() throws DatabaseException { return keys(null, null); }
public boolean delete(PK key) throws DatabaseException { return delete(null, key); }
public Map<PK, E> map() { return sortedMap(); }
public OperationResult delete(Transaction txn, PK key, WriteOptions options) throws DatabaseException { return deleteInternal(txn, key, OpWriteOptions.make(options)).jeResult; } /* <!-- end JE only --> */
public E get(Transaction txn, PK key, LockMode lockMode) throws DatabaseException { /* <!-- begin JE only --> */ if (DbCompat.IS_JE) { EntityResult<E> result = get( txn, key, Get.SEARCH, DbInternal.getReadOptions(lockMode)); return result != null ? result.value() : null; } /* <!-- end JE only --> */ DatabaseEntry pkeyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); pkeyBinding.objectToEntry(key, pkeyEntry); OperationStatus status = db.getSearchBoth(txn, keyEntry, pkeyEntry, dataEntry, lockMode); if (status == OperationStatus.SUCCESS) { return (E) entityBinding.entryToObject(pkeyEntry, dataEntry); } else { return null; } }
public EntityCursor<E> entities(Transaction txn, PK fromKey, boolean fromInclusive, PK toKey, boolean toInclusive, CursorConfig config) throws DatabaseException { return cursor(txn, fromKey, fromInclusive, toKey, toInclusive, entityAdapter, config); }
public long count() throws DatabaseException { CursorConfig cursorConfig = locking ? CursorConfig.READ_UNCOMMITTED : null; EntityCursor<PK> cursor = keys(null, cursorConfig); try { if (cursor.next() != null) { return cursor.count(); } else { return 0; } } finally { cursor.close(); } }
public EntityCursor<PK> keys(Transaction txn, PK fromKey, boolean fromInclusive, PK toKey, boolean toInclusive, CursorConfig config) throws DatabaseException { return cursor(txn, fromKey, fromInclusive, toKey, toInclusive, keyAdapter, config); }
public EntityCursor<PK> keys(Transaction txn, CursorConfig config) throws DatabaseException { return cursor(txn, null, keyAdapter, config); }
return cursor(txn, pkeyRange, adapter, config);