JoinForwardCursor(Transaction txn, CursorConfig config, boolean doKeys) throws DatabaseException { this.doKeys = doKeys; try { cursors = new Cursor[conditions.size()]; for (int i = 0; i < cursors.length; i += 1) { Condition cond = conditions.get(i); Cursor cursor = cond.openCursor(txn, config); if (cursor == null) { /* Leave joinCursor null. */ doClose(null); return; } cursors[i] = cursor; } joinCursor = primary.getDatabase().join(cursors, null); } catch (DatabaseException e) { /* doClose will throw e. */ doClose(e); } }
SecondaryIndex secIndex = secIndexMap.get(secName); if (secIndex != null) { Database db = secIndex.getDatabase(); firstException = closeDb(db, firstException); firstException =
/** * Adds a secondary key condition to the equality join. Only entities * having the given key value in the given secondary index will be returned * by the join operation. * * @param index the secondary index containing the given key value. * * @param key the key value to match during the join. * * @param <SK> the secondary key class. */ public <SK> void addCondition(SecondaryIndex<SK, PK, E> index, SK key) { /* Make key entry. */ DatabaseEntry keyEntry = new DatabaseEntry(); index.getKeyBinding().objectToEntry(key, keyEntry); /* Use keys database if available. */ Database db = index.getKeysDatabase(); if (db == null) { db = index.getDatabase(); } /* Add condition. */ conditions.add(new Condition(db, keyEntry)); }
firstException = closeDb(index.getDatabase(), firstException); firstException = closeDb(index.getKeysDatabase(), firstException);
<SK> SubIndex(SecondaryIndex<SK, PK, E> secIndex, EntityBinding entityBinding, SK key) throws DatabaseException { this.secIndex = secIndex; db = secIndex.getDatabase(); transactional = secIndex.transactional; sortedDups = secIndex.sortedDups; locking = DbCompat.getInitializeLocking(db.getEnvironment().getConfig()); Environment env = db.getEnvironment(); concurrentDB = DbCompat.getInitializeCDB(env.getConfig()); keyObject = key; keyEntry = new DatabaseEntry(); secIndex.keyBinding.objectToEntry(key, keyEntry); singleKeyRange = secIndex.emptyRange.subRange(keyEntry); PrimaryIndex<PK, E> priIndex = secIndex.getPrimaryIndex(); pkeyBinding = priIndex.keyBinding; emptyPKeyRange = priIndex.emptyRange; this.entityBinding = entityBinding; keyAdapter = new PrimaryKeyValueAdapter<PK> (priIndex.keyClass, priIndex.keyBinding); entityAdapter = secIndex.entityAdapter; }