private static AddedWithValuesAndRemoved IndexUpdatesWithValuesScanAndFilter(ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery filter, IndexOrder indexOrder) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> updates = getUpdates(txState, descriptor, indexOrder); IDictionary <ValueTuple, ? extends LongDiffSets> updates = GetUpdates(txState, descriptor, indexOrder); if (updates == null) { return(_emptyAddedAndRemovedWithValues); } MutableList <NodeWithPropertyValues> added = Lists.mutable.empty(); MutableLongSet removed = LongSets.mutable.empty(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : updates.entrySet()) foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in updates.SetOfKeyValuePairs()) { ValueTuple key = entry.Key; if (filter == null || filter.AcceptsValue(key.OnlyValue)) { Value[] values = key.Values; LongDiffSets diffSet = entry.Value; diffSet.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, values))); removed.addAll(diffSet.Removed); } } return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("resource") @Override public void createCommands(java.util.Collection<org.neo4j.storageengine.api.StorageCommand> commands, org.neo4j.storageengine.api.txstate.ReadableTransactionState txState, org.neo4j.storageengine.api.StorageReader storageReader, org.neo4j.storageengine.api.lock.ResourceLocker locks, long lastTransactionIdWhenStarted, org.neo4j.storageengine.api.txstate.TxStateVisitor_Decorator additionalTxStateVisitor) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.schema.CreateConstraintFailureException, org.neo4j.internal.kernel.api.exceptions.schema.ConstraintValidationException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public override void CreateCommands(ICollection <StorageCommand> commands, ReadableTransactionState txState, StorageReader storageReader, ResourceLocker locks, long lastTransactionIdWhenStarted, Org.Neo4j.Storageengine.Api.txstate.TxStateVisitor_Decorator additionalTxStateVisitor) { if (txState != null) { // We can make this cast here because we expected that the storageReader passed in here comes from // this storage engine itself, anything else is considered a bug. And we do know the inner workings // of the storage statements that we create. RecordStorageCommandCreationContext creationContext = (( RecordStorageReader )storageReader).CommandCreationContext; TransactionRecordState recordState = creationContext.CreateTransactionRecordState(_integrityValidator, lastTransactionIdWhenStarted, locks); // Visit transaction state and populate these record state objects TxStateVisitor txStateVisitor = new TransactionToRecordStateVisitor(recordState, _schemaState, _schemaStorage, _constraintSemantics); CountsRecordState countsRecordState = new CountsRecordState(); txStateVisitor = additionalTxStateVisitor.apply(txStateVisitor); txStateVisitor = new TransactionCountingStateVisitor(txStateVisitor, storageReader, txState, countsRecordState); using (TxStateVisitor visitor = txStateVisitor) { txState.Accept(visitor); } // Convert record state into commands recordState.ExtractCommands(commands); countsRecordState.ExtractCommands(commands); } }
// PREFIX internal static AddedAndRemoved IndexUpdatesForRangeSeekByPrefix(ReadableTransactionState txState, IndexDescriptor descriptor, TextValue prefix, IndexOrder indexOrder) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.NavigableMap<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema()); NavigableMap <ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.GetSortedIndexUpdates(descriptor.Schema()); if (sortedUpdates == null) { return(_emptyAddedAndRemoved); } ValueTuple floor = ValueTuple.of(prefix); MutableLongList added = LongLists.mutable.empty(); MutableLongSet removed = LongSets.mutable.empty(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : sortedUpdates.subMap(floor, MAX_STRING_TUPLE).entrySet()) foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in sortedUpdates.subMap(floor, _maxStringTuple).entrySet()) { ValueTuple key = entry.Key; if ((( TextValue )key.OnlyValue).startsWith(prefix)) { LongDiffSets diffSets = entry.Value; added.addAll(diffSets.Added); removed.addAll(diffSets.Removed); } else { break; } } return(new AddedAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Collection<org.junit.jupiter.api.DynamicTest> rangeTests() internal virtual ICollection <DynamicTest> RangeTests() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, 510).withAdded(43L, 520).withAdded(44L, 550).withAdded(45L, 500).withAdded(46L, 530).withAdded(47L, 560).withAdded(48L, 540).build(); ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, 510).withAdded(43L, 520).withAdded(44L, 550).withAdded(45L, 500).withAdded(46L, 530).withAdded(47L, 560).withAdded(48L, 540).build(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Collection<org.junit.jupiter.api.DynamicTest> tests = new java.util.ArrayList<>(); ICollection <DynamicTest> tests = new List <DynamicTest>(); tests.addAll(RangeTest(state, Values.of(510), true, Values.of(550), true, NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550))); tests.addAll(RangeTest(state, Values.of(510), true, Values.of(550), false, NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540))); tests.addAll(RangeTest(state, Values.of(510), false, Values.of(550), true, NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550))); tests.addAll(RangeTest(state, Values.of(510), false, Values.of(550), false, NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540))); tests.addAll(RangeTest(state, null, false, Values.of(550), true, NodeWithPropertyValues(45L, 500), NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550))); tests.addAll(RangeTest(state, null, true, Values.of(550), true, NodeWithPropertyValues(45L, 500), NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550))); tests.addAll(RangeTest(state, null, false, Values.of(550), false, NodeWithPropertyValues(45L, 500), NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540))); tests.addAll(RangeTest(state, null, true, Values.of(550), false, NodeWithPropertyValues(45L, 500), NodeWithPropertyValues(42L, 510), NodeWithPropertyValues(43L, 520), NodeWithPropertyValues(46L, 530), NodeWithPropertyValues(48L, 540))); tests.addAll(RangeTest(state, Values.of(540), true, null, true, NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550), NodeWithPropertyValues(47L, 560))); tests.addAll(RangeTest(state, Values.of(540), true, null, false, NodeWithPropertyValues(48L, 540), NodeWithPropertyValues(44L, 550), NodeWithPropertyValues(47L, 560))); tests.addAll(RangeTest(state, Values.of(540), false, null, true, NodeWithPropertyValues(44L, 550), NodeWithPropertyValues(47L, 560))); tests.addAll(RangeTest(state, Values.of(540), false, null, false, NodeWithPropertyValues(44L, 550), NodeWithPropertyValues(47L, 560))); tests.addAll(RangeTest(state, Values.of(560), false, Values.of(800), true)); return(tests); }
public override TransactionHandlerState BeforeCommit(ReadableTransactionState state, KernelTransaction transaction, StorageReader storageReader) { // The iterator grabs a snapshot of our list of handlers IEnumerator <TransactionEventHandler> handlers = _transactionEventHandlers.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (!handlers.hasNext()) { // Use 'null' as a signal that no event handlers were registered at beforeCommit time return(null); } TransactionData txData = state == null ? EMPTY_DATA : new TxStateTransactionDataSnapshot(state, _proxySpi, storageReader, transaction); TransactionHandlerState handlerStates = new TransactionHandlerState(txData); while (handlers.MoveNext()) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.graphdb.event.TransactionEventHandler<?> handler = handlers.Current; TransactionEventHandler <object> handler = handlers.Current; try { handlerStates.Add(handler).State = handler.BeforeCommit(txData); } catch (Exception t) { handlerStates.Failed(t); } } return(handlerStates); }
// SUFFIX internal static AddedAndRemoved IndexUpdatesForSuffixOrContains(ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery query, IndexOrder indexOrder) { if (descriptor.Schema().PropertyIds.Length != 1) { throw new System.InvalidOperationException("Suffix and contains queries are only supported for single property queries"); } return(IndexUpdatesForScanAndFilter(txState, descriptor, query, indexOrder)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSeekWhenThereAreManyEntriesWithTheSameValues() internal virtual void ShouldSeekWhenThereAreManyEntriesWithTheSameValues() { // GIVEN (note that 44 has the same properties as 43) ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "42value1", "42value2").withAdded(43L, "43value1", "43value2").withAdded(44L, "43value1", "43value2").build(); // WHEN AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("43value1", "43value2")); // THEN outerInstance.AssertContains(changes.Added, 43L, 44L); }
public TxStateTransactionDataSnapshot(ReadableTransactionState state, EmbeddedProxySPI proxySpi, StorageReader storageReader, KernelTransaction transaction) { this._state = state; this._proxySpi = proxySpi; this._store = storageReader; this._transaction = transaction; // Load changes that require store access eagerly, because we won't have access to the after-state // after the tx has been committed. TakeSnapshot(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSeekWhenThereAreNewNumberNodes() internal virtual void ShouldSeekWhenThereAreNewNumberNodes() { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, 42001.0, 42002.0).withAdded(43L, 43001.0, 43002.0).build(); // WHEN AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(43001.0, 43002.0)); // THEN outerInstance.AssertContains(changes.Added, 43L); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public void afterRollback(org.neo4j.storageengine.api.txstate.ReadableTransactionState state, org.neo4j.kernel.api.KernelTransaction tx, TransactionHooksState hooksState) public virtual void AfterRollback(ReadableTransactionState state, KernelTransaction tx, TransactionHooksState hooksState) { if (hooksState == null) { return; } foreach (Pair <TransactionHook, TransactionHook_Outcome> hookAndOutcome in hooksState.HooksWithOutcome()) { hookAndOutcome.First().afterRollback(state, tx, hookAndOutcome.Other()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSeekInComplexMix() internal virtual void ShouldSeekInComplexMix() { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(10L, "hi", 3).withAdded(11L, 9L, 33L).withAdded(12L, "sneaker", false).withAdded(13L, new int[] { 10, 100 }, "array-buddy").withAdded(14L, 40.1, 40.2).build(); // THEN outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("hi", 3)).Added, 10L); outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(9L, 33L)).Added, 11L); outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("sneaker", false)).Added, 12L); outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(new int[] { 10, 100 }, "array-buddy")).Added, 13L); outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(40.1, 40.2)).Added, 14L); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public void afterCommit(org.neo4j.storageengine.api.txstate.ReadableTransactionState state, org.neo4j.kernel.api.KernelTransaction tx, TransactionHooksState hooksState) public virtual void AfterCommit(ReadableTransactionState state, KernelTransaction tx, TransactionHooksState hooksState) { if (hooksState == null) { return; } foreach (Pair <TransactionHook, TransactionHook_Outcome> hookAndOutcome in hooksState.HooksWithOutcome()) { TransactionHook hook = hookAndOutcome.First(); TransactionHook_Outcome outcome = hookAndOutcome.Other(); hook.afterCommit(state, tx, outcome); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForSeekWhenThereAreNewNodes() internal virtual void ShouldComputeIndexUpdatesForSeekWhenThereAreNewNodes() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build(); ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "foo").withAdded(43L, "bar").build(); // WHEN AddedAndRemoved changes = indexUpdatesForSeek(state, _index, ValueTuple.of("bar")); // THEN AssertContains(changes.Added, 43L); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSeekOnAnEmptyTxState() internal virtual void ShouldSeekOnAnEmptyTxState() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class); ReadableTransactionState state = Mockito.mock(typeof(ReadableTransactionState)); // WHEN AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("43value1", "43value2")); // THEN assertTrue(changes.Empty); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public void afterRollback(org.neo4j.storageengine.api.txstate.ReadableTransactionState state, org.neo4j.kernel.api.KernelTransaction transaction, TransactionHandlerState handlerState) public override void AfterRollback(ReadableTransactionState state, KernelTransaction transaction, TransactionHandlerState handlerState) { if (handlerState == null) { // For legacy reasons, we don't call transaction handlers on implicit rollback. return; } foreach (HandlerAndState handlerAndState in handlerState.States) { handlerAndState.Handler.afterRollback(handlerState.TxData, handlerAndState.StateConflict); } }
private DynamicTest RangeTest(ReadableTransactionState state, IndexOrder indexOrder, Value lo, bool includeLo, Value hi, bool includeHi, params NodeWithPropertyValues[] expected) { return(DynamicTest.dynamicTest(string.Format("range seek: lo={0} (incl: {1}), hi={2} (incl: {3})", lo, includeLo, hi, includeHi), () => { // Internal production code relies on null for unbounded, and cannot cope with NO_VALUE in this case Debug.Assert(lo != NO_VALUE); Debug.Assert(hi != NO_VALUE); AddedAndRemoved changes = indexUpdatesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder); AssertContains(indexOrder, changes, changesWithValues, expected); })); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByPrefixWhenThereAreNonStringNodes() internal virtual void ShouldComputeIndexUpdatesForRangeSeekByPrefixWhenThereAreNonStringNodes() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "barry").withAdded(44L, 101L).withAdded(43L, "bar").build(); ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "barry").withAdded(44L, 101L).withAdded(43L, "bar").build(); // WHEN AddedAndRemoved changes = TxStateIndexChanges.IndexUpdatesForRangeSeekByPrefix(state, outerInstance.index, stringValue("bar"), IndexOrder.NONE); // THEN outerInstance.AssertContainsInOrder(changes.Added, 43L, 42L); }
// SEEK internal static AddedAndRemoved IndexUpdatesForSeek(ReadableTransactionState txState, IndexDescriptor descriptor, ValueTuple values) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.eclipse.collections.impl.UnmodifiableMap<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> updates = txState.getIndexUpdates(descriptor.schema()); UnmodifiableMap <ValueTuple, ? extends LongDiffSets> updates = txState.GetIndexUpdates(descriptor.Schema()); if (updates != null) { LongDiffSets indexUpdatesForSeek = updates.get(values); return(indexUpdatesForSeek == null ? _emptyAddedAndRemoved : new AddedAndRemoved(LongLists.mutable.ofAll(indexUpdatesForSeek.Added), indexUpdatesForSeek.Removed)); } return(_emptyAddedAndRemoved); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByPrefixWhenThereAreNoMatchingNodes() internal virtual void ShouldComputeIndexUpdatesForRangeSeekByPrefixWhenThereAreNoMatchingNodes() { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "value42").withAdded(43L, "value43").build(); // WHEN AddedAndRemoved changes = indexUpdatesForRangeSeekByPrefix(state, outerInstance.index, stringValue("eulav"), IndexOrder.NONE); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeekByPrefix(state, outerInstance.index, stringValue("eulav"), IndexOrder.NONE); // THEN assertTrue(changes.Added.Empty); assertFalse(changesWithValues.Added.GetEnumerator().hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldScanWhenThereAreNewNodes() internal virtual void ShouldScanWhenThereAreNewNodes() { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "42value1", "42value2").withAdded(43L, "43value1", "43value2").build(); // WHEN AddedAndRemoved changes = indexUpdatesForScan(state, CompositeIndexConflict, IndexOrder.NONE); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, CompositeIndexConflict, IndexOrder.NONE); // THEN outerInstance.AssertContains(changes.Added, 42L, 43L); outerInstance.AssertContains(changesWithValues.Added, NodeWithPropertyValues(42L, "42value1", "42value2"), NodeWithPropertyValues(43L, "43value1", "43value2")); }
internal virtual void AssertRangeSeekByPrefixForOrder(IndexOrder indexOrder) { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(40L, "Aaron").withAdded(41L, "Agatha").withAdded(42L, "Andreas").withAdded(43L, "Barbarella").withAdded(44L, "Andrea").withAdded(45L, "Aristotle").withAdded(46L, "Barbara").withAdded(47L, "Andy").withAdded(48L, "Cinderella").withAdded(49L, "Andromeda").build(); // WHEN AddedAndRemoved changes = indexUpdatesForRangeSeekByPrefix(state, outerInstance.index, stringValue("And"), indexOrder); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeekByPrefix(state, outerInstance.index, stringValue("And"), indexOrder); NodeWithPropertyValues[] expected = new NodeWithPropertyValues[] { NodeWithPropertyValues(44L, "Andrea"), NodeWithPropertyValues(42L, "Andreas"), NodeWithPropertyValues(49L, "Andromeda"), NodeWithPropertyValues(47L, "Andy") }; // THEN outerInstance.AssertContains(indexOrder, changes, changesWithValues, expected); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByContainsWhenThereArePartiallyMatchingNewNodes() internal virtual void ShouldComputeIndexUpdatesForRangeSeekByContainsWhenThereArePartiallyMatchingNewNodes() { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(40L, "Aaron").withAdded(41L, "Agatha").withAdded(42L, "Andreas").withAdded(43L, "Andrea").withAdded(44L, "Aristotle").withAdded(45L, "Barbara").withAdded(46L, "Barbarella").withAdded(47L, "Cinderella").build(); // WHEN IndexQuery.StringContainsPredicate indexQuery = IndexQuery.stringContains(outerInstance.index.Schema().PropertyId, stringValue("arbar")); AddedAndRemoved changes = indexUpdatesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE); // THEN outerInstance.AssertContains(changes.Added, 45L, 46L); outerInstance.AssertContains(changesWithValues.Added, NodeWithPropertyValues(45L, "Barbara"), NodeWithPropertyValues(46L, "Barbarella")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public void afterCommit(org.neo4j.storageengine.api.txstate.ReadableTransactionState state, org.neo4j.kernel.api.KernelTransaction transaction, TransactionHandlerState handlerState) public override void AfterCommit(ReadableTransactionState state, KernelTransaction transaction, TransactionHandlerState handlerState) { if (handlerState == null) { // As per beforeCommit, 'null' means no handlers were registered in time for this transaction to // observe them. return; } foreach (HandlerAndState handlerAndState in handlerState.States) { handlerAndState.Handler.afterCommit(handlerState.TxData, handlerAndState.StateConflict); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForScanOnAnEmptyTxState() internal virtual void ShouldComputeIndexUpdatesForScanOnAnEmptyTxState() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class); ReadableTransactionState state = Mockito.mock(typeof(ReadableTransactionState)); // WHEN AddedAndRemoved changes = indexUpdatesForScan(state, _index, IndexOrder.NONE); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, _index, IndexOrder.NONE); // THEN assertTrue(changes.Empty); assertTrue(changesWithValues.Empty); }
internal virtual void AssertRangeSeekByContainsForOrder(IndexOrder indexOrder) { // GIVEN ReadableTransactionState state = (new TxStateBuilder()).WithAdded(40L, "Smashing").withAdded(41L, "Bashley").withAdded(42L, "Crasch").withAdded(43L, "Mayonnaise").withAdded(44L, "Seashell").withAdded(45L, "Ton").withAdded(46L, "The Flash").withAdded(47L, "Strayhound").withAdded(48L, "Trashy").withAdded(49L, "Andromeda").build(); // WHEN IndexQuery indexQuery = IndexQuery.stringContains(outerInstance.index.Schema().PropertyId, stringValue("ash")); AddedAndRemoved changes = indexUpdatesForSuffixOrContains(state, outerInstance.index, indexQuery, indexOrder); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForSuffixOrContains(state, outerInstance.index, indexQuery, indexOrder); NodeWithPropertyValues[] expected = new NodeWithPropertyValues[] { NodeWithPropertyValues(41L, "Bashley"), NodeWithPropertyValues(44L, "Seashell"), NodeWithPropertyValues(40L, "Smashing"), NodeWithPropertyValues(46L, "The Flash"), NodeWithPropertyValues(48L, "Trashy") }; // THEN outerInstance.AssertContains(indexOrder, changes, changesWithValues, expected); }
public virtual TransactionHooksState BeforeCommit(ReadableTransactionState state, KernelTransaction tx, StorageReader storageReader) { if (Hooks.Count == 0) { return(null); } TransactionHooksState hookState = new TransactionHooksState(); foreach (TransactionHook hook in Hooks) { TransactionHook_Outcome outcome = hook.beforeCommit(state, tx, storageReader); hookState.Add(hook, outcome); } return(hookState); }
internal virtual ReadableTransactionState Build() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState mock = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class); ReadableTransactionState mock = Mockito.mock(typeof(ReadableTransactionState)); doReturn(new UnmodifiableMap <>(Updates)).when(mock).getIndexUpdates(any(typeof(SchemaDescriptor))); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.TreeMap<org.neo4j.values.storable.ValueTuple, org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSetsImpl> sortedMap = new java.util.TreeMap<>(org.neo4j.values.storable.ValueTuple.COMPARATOR); SortedDictionary <ValueTuple, MutableLongDiffSetsImpl> sortedMap = new SortedDictionary <ValueTuple, MutableLongDiffSetsImpl>(ValueTuple.COMPARATOR); //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method: sortedMap.putAll(Updates); doReturn(sortedMap).when(mock).getSortedIndexUpdates(any(typeof(SchemaDescriptor))); return(mock); }
private void AssertScanWithOrder(IndexOrder indexOrder) { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(40L, "Aaron").withAdded(41L, "Agatha").withAdded(42L, "Andreas").withAdded(43L, "Barbarella").withAdded(44L, "Andrea").withAdded(45L, "Aristotle").withAdded(46L, "Barbara").withAdded(47L, "Cinderella").build(); ReadableTransactionState state = (new TxStateBuilder()).WithAdded(40L, "Aaron").withAdded(41L, "Agatha").withAdded(42L, "Andreas").withAdded(43L, "Barbarella").withAdded(44L, "Andrea").withAdded(45L, "Aristotle").withAdded(46L, "Barbara").withAdded(47L, "Cinderella").build(); // WHEN AddedAndRemoved changes = indexUpdatesForScan(state, _index, indexOrder); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, _index, indexOrder); NodeWithPropertyValues[] expectedNodesWithValues = new NodeWithPropertyValues[] { NodeWithPropertyValues(40L, "Aaron"), NodeWithPropertyValues(41L, "Agatha"), NodeWithPropertyValues(44L, "Andrea"), NodeWithPropertyValues(42L, "Andreas"), NodeWithPropertyValues(45L, "Aristotle"), NodeWithPropertyValues(46L, "Barbara"), NodeWithPropertyValues(43L, "Barbarella"), NodeWithPropertyValues(47L, "Cinderella") }; // THEN AssertContains(indexOrder, changes, changesWithValues, expectedNodesWithValues); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByContainsWhenThereAreNoMatchingNodes() internal virtual void ShouldComputeIndexUpdatesForRangeSeekByContainsWhenThereAreNoMatchingNodes() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build(); ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "foo").withAdded(43L, "bar").build(); // WHEN IndexQuery.StringContainsPredicate indexQuery = IndexQuery.stringContains(outerInstance.index.Schema().PropertyId, stringValue("eulav")); AddedAndRemoved changes = indexUpdatesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE); // THEN assertTrue(changes.Added.Empty); assertFalse(changesWithValues.Added.GetEnumerator().hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") private org.neo4j.storageengine.api.StorageEngine mockedStorageEngine() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: private StorageEngine MockedStorageEngine() { StorageEngine storageEngine = mock(typeof(StorageEngine)); doAnswer(invocation => { ICollection <StorageCommand> target = invocation.getArgument(0); ReadableTransactionState txState = invocation.getArgument(1); txState.accept(new AdapterAnonymousInnerClass(this, target)); return(null); }).when(storageEngine).createCommands(anyCollection(), any(typeof(ReadableTransactionState)), any(typeof(StorageReader)), any(typeof(ResourceLocker)), anyLong(), any(typeof(TxStateVisitor.Decorator))); StorageReader readLayer = mock(typeof(StorageReader)); when(storageEngine.NewReader()).thenReturn(readLayer); return(storageEngine); }