| | |
| | | */ |
| | | private boolean trusted; |
| | | |
| | | /** |
| | | * A flag to indicate if a rebuild process is running on this index. |
| | | * During the rebuild process, we assume that no entryIDSets are |
| | | * accurate and return an undefined set on all read operations. |
| | | * However all write operations will succeed. The rebuildRunning |
| | | * flag overrides all behaviors of the trusted flag. |
| | | */ |
| | | private boolean rebuildRunning; |
| | | |
| | | private final ImportIDSet newImportIDSet; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | else if (trusted) |
| | | { |
| | | if (deletedIDs != null && trusted && !rebuildRunning) |
| | | if (deletedIDs != null) |
| | | { |
| | | logIndexCorruptError(txn, key); |
| | | } |
| | | |
| | | if ((rebuildRunning || trusted) && isNotNullOrEmpty(addedIDs)) |
| | | if (isNotNullOrEmpty(addedIDs)) |
| | | { |
| | | data.setData(addedIDs.toDatabase()); |
| | | |
| | |
| | | return delete(txn, key); |
| | | } |
| | | } |
| | | else |
| | | else if (trusted) |
| | | { |
| | | if (deletedIDs != null && trusted && !rebuildRunning) |
| | | if (deletedIDs != null) |
| | | { |
| | | logIndexCorruptError(txn, key); |
| | | } |
| | | |
| | | if ((rebuildRunning || trusted) && isNotNullOrEmpty(addedIDs)) |
| | | if (isNotNullOrEmpty(addedIDs)) |
| | | { |
| | | data.setData(addedIDs.toDatabase()); |
| | | return insert(txn, key, data); |
| | | } |
| | | return OperationStatus.SUCCESS; |
| | | } |
| | | return OperationStatus.SUCCESS; |
| | | } |
| | | |
| | | private EntryIDSet computeEntryIDList(DatabaseEntry key, DatabaseEntry data, EntryIDSet deletedIDs, |
| | |
| | | public ConditionResult containsID(Transaction txn, DatabaseEntry key, EntryID entryID) |
| | | throws DatabaseException |
| | | { |
| | | if(rebuildRunning) |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | | |
| | | OperationStatus status = read(txn, key, data, LockMode.DEFAULT); |
| | |
| | | */ |
| | | public EntryIDSet readKey(DatabaseEntry key, Transaction txn, LockMode lockMode) |
| | | { |
| | | if(rebuildRunning) |
| | | { |
| | | return new EntryIDSet(); |
| | | } |
| | | |
| | | try |
| | | { |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | |
| | | public EntryIDSet readRange(byte[] lower, byte[] upper, |
| | | boolean lowerIncluded, boolean upperIncluded) |
| | | { |
| | | LockMode lockMode = LockMode.DEFAULT; |
| | | |
| | | // If this index is not trusted, then just return an undefined |
| | | // id set. |
| | | if(rebuildRunning || !trusted) |
| | | // If this index is not trusted, then just return an undefined id set. |
| | | if (!trusted) |
| | | { |
| | | return new EntryIDSet(); |
| | | } |
| | |
| | | { |
| | | // Total number of IDs found so far. |
| | | int totalIDCount = 0; |
| | | LockMode lockMode = LockMode.DEFAULT; |
| | | |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | | DatabaseEntry key; |
| | |
| | | */ |
| | | public synchronized boolean isRebuildRunning() |
| | | { |
| | | return rebuildRunning; |
| | | } |
| | | |
| | | /** |
| | | * Set the rebuild status of this index. |
| | | * @param rebuildRunning True if a rebuild process on this index |
| | | * is running or False otherwise. |
| | | */ |
| | | public synchronized void setRebuildStatus(boolean rebuildRunning) |
| | | { |
| | | this.rebuildRunning = rebuildRunning; |
| | | return false; // FIXME inline? |
| | | } |
| | | |
| | | /** |