private bool VisitIndexAddCommand(IndexCommand command, EntityId entityId) { try { CommitContext context = CommitContext(command); string key = _definitions.getKey(command.KeyId); object value = command.Value; // Below is a check for a null value where such a value is ignored. This may look strange, but the // reason is that there was this bug where adding a null value to an index would be fine and written // into the log as a command, to later fail during application of that command, i.e. here. // There was a fix introduced to throw IllegalArgumentException out to user right away if passing in // null or object that had toString() produce null. Although databases already affected by this would // not be able to recover, which is why this check is here. if (value != null) { context.EnsureWriterInstantiated(); context.IndexType.addToDocument(context.GetDocument(entityId, true).Document, key, value); } } catch (ExplicitIndexNotFoundKernelException) { // Pretend the index never existed. } return(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public boolean visitIndexDeleteCommand(org.neo4j.kernel.impl.index.IndexCommand.DeleteCommand command) throws java.io.IOException public override bool VisitIndexDeleteCommand(IndexCommand.DeleteCommand command) { try { CommitContext context = CommitContext(command); context.Documents.clear(); context.DataSource.deleteIndex(context.Identifier, context.Recovery); } catch (ExplicitIndexNotFoundKernelException) { // Pretend the index never existed. } return(false); }
public override bool VisitIndexRemoveCommand(IndexCommand.RemoveCommand command) { try { CommitContext context = CommitContext(command); string key = _definitions.getKey(command.KeyId); object value = command.Value; context.EnsureWriterInstantiated(); CommitContext.DocumentContext document = context.GetDocument(new IdData(command.EntityId), false); if (document != null) { context.IndexType.removeFromDocument(document.Document, key, value); } } catch (ExplicitIndexNotFoundKernelException) { // Pretend the index never existed. } return(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private CommitContext commitContext(org.neo4j.kernel.impl.index.IndexCommand command) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException private CommitContext CommitContext(IndexCommand command) { IDictionary <string, CommitContext> contextMap = CommitContextMap(command.EntityType); string indexName = _definitions.getIndexName(command.IndexNameId); CommitContext context = contextMap[indexName]; if (context == null) { IndexIdentifier identifier = new IndexIdentifier(IndexEntityType.byId(command.EntityType), indexName); // TODO the fact that we look up index type from config here using the index store // directly should be avoided. But how can we do it in, say recovery? // The `dataSource.getType()` call can throw an exception if the index is concurrently deleted. // To avoid bubbling an exception during commit, we instead ignore the commands related to that index, // and proceed as if the index never existed, and thus cannot accept any modifications. IndexType type = _dataSource.getType(identifier, _recovery); context = new CommitContext(_dataSource, identifier, type, _recovery); contextMap[indexName] = context; } return(context); }