//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetRelationshipsByTypeAndDirection() public virtual void ShouldGetRelationshipsByTypeAndDirection() { RelationshipChangesForNode changes = new RelationshipChangesForNode(RelationshipChangesForNode.DiffStrategy.Add); const int type = 2; const int decoyType = 666; changes.AddRelationship(1, type, INCOMING); changes.AddRelationship(2, type, OUTGOING); changes.AddRelationship(3, type, OUTGOING); changes.AddRelationship(4, type, LOOP); changes.AddRelationship(5, type, LOOP); changes.AddRelationship(6, type, LOOP); changes.AddRelationship(10, decoyType, INCOMING); changes.AddRelationship(11, decoyType, OUTGOING); changes.AddRelationship(12, decoyType, LOOP); LongIterator rawIncoming = changes.GetRelationships(RelationshipDirection.INCOMING, type); assertThat(PrimitiveLongCollections.asArray(rawIncoming), Ids(1)); LongIterator rawOutgoing = changes.GetRelationships(RelationshipDirection.OUTGOING, type); assertThat(PrimitiveLongCollections.asArray(rawOutgoing), Ids(2, 3)); LongIterator rawLoops = changes.GetRelationships(RelationshipDirection.LOOP, type); assertThat(PrimitiveLongCollections.asArray(rawLoops), Ids(4, 5, 6)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void frozenIterator() internal virtual void FrozenIterator() { _set.addAll(1, 2, 3, 100, 200, 300); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator iter1 = set.freeze().longIterator(); LongIterator iter1 = _set.freeze().longIterator(); _set.removeAll(1, 100); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator iter2 = set.freeze().longIterator(); LongIterator iter2 = _set.freeze().longIterator(); _set.removeAll(2, 200); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.LongSet values1 = drain(iter1); LongSet values1 = Drain(iter1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.LongSet values2 = drain(iter2); LongSet values2 = Drain(iter2); assertEquals(newSetWith(1, 2, 3, 100, 200, 300), values1); assertEquals(newSetWith(2, 3, 200, 300), values2); }
/// <summary> /// NodeCursor should only see changes that are there from the beginning /// otherwise it will not be stable. /// </summary> private bool HasChanges() { switch (_hasChanges) { case Org.Neo4j.Kernel.Impl.Newapi.HasChanges.Maybe: bool changes = _read.hasTxStateWithChanges(); if (changes) { if (_single != NO_ID) { _addedNodes = _read.txState().nodeIsAddedInThisTx(_single) ? LongSets.immutable.of(_single).longIterator() : ImmutableEmptyLongIterator.INSTANCE; } else { _addedNodes = _read.txState().addedAndRemovedNodes().Added.freeze().longIterator(); } _hasChanges = HasChanges.Yes; } else { _hasChanges = HasChanges.No; } return(changes); case Org.Neo4j.Kernel.Impl.Newapi.HasChanges.Yes: return(true); case Org.Neo4j.Kernel.Impl.Newapi.HasChanges.No: return(false); default: throw new System.InvalidOperationException("Style guide, why are you making me do this"); } }
private void Exhaust(LongIterator iterator) { while (iterator.hasNext()) { iterator.next(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void tailBeforeHeadCorrectIteration() internal virtual void TailBeforeHeadCorrectIteration() { PrimitiveLongArrayQueue queue = CreateQueue(); for (int i = 0; i < 14; i++) { queue.Enqueue(i); } for (int i = 0; i < 10; i++) { assertEquals(i, queue.Dequeue()); } for (int i = 14; i < 24; i++) { queue.Enqueue(i); } assertEquals(14, queue.Size()); LongIterator iterator = queue.LongIterator(); for (int j = 10; j < 24; j++) { assertTrue(iterator.hasNext()); assertEquals(j, iterator.next()); } assertFalse(iterator.hasNext()); }
internal virtual void Single(long reference, Read read) { _storeCursor.single(reference); this._read = read; this._single = reference; this._hasChanges = HasChanges.Maybe; this._addedNodes = ImmutableEmptyLongIterator.INSTANCE; }
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint: //ORIGINAL LINE: Scan(RecordStore<R> store, boolean forward, final System.Predicate<? super R>... filters) //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: internal Scan( RecordStore<R> store, bool forward, params System.Predicate<object>[] filters ) { this.Filters = filters; this.Ids = new StoreIdIterator( store, forward ); this.Store = store; this.Cursor = store.OpenPageCursorForReading( 0 ); this.Record = store.NewRecord(); }
internal virtual void Scan(int type, Read read) { StoreCursor.scan(type); this._type = type; this._single = NO_ID; Init(read); this._addedRelationships = ImmutableEmptyLongIterator.INSTANCE; }
internal virtual void Scan(Read read) { _storeCursor.scan(); this._read = read; this._single = NO_ID; this._hasChanges = HasChanges.Maybe; this._addedNodes = ImmutableEmptyLongIterator.INSTANCE; }
internal virtual void Single(long reference, Read read) { StoreCursor.single(reference); _type = -1; this._single = reference; Init(read); this._addedRelationships = ImmutableEmptyLongIterator.INSTANCE; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void augmentDiffSetWithExternalElements() public virtual void AugmentDiffSetWithExternalElements() { MutableLongDiffSets diffSet = CreateDiffSet(); diffSet.AddAll(newSetWith(9L, 10L, 11L)); diffSet.RemoveAll(newSetWith(1L, 2L)); LongIterator augmentedIterator = diffSet.Augment(iterator(5L, 6L)); assertEquals(asSet(5L, 6L, 9L, 10L, 11L), toSet(augmentedIterator)); }
protected internal override void CollectAddedTxStateSnapshot() { if (Single) { _addedRelationships = Read.txState().relationshipIsAddedInThisTx(_single) ? LongHashSet.newSetWith(_single).longIterator() : ImmutableEmptyLongIterator.INSTANCE; } else { _addedRelationships = Read.txState().addedAndRemovedRelationships().Added.longIterator(); } }
private static LongSet Drain(LongIterator iter) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet result = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(); MutableLongSet result = new LongHashSet(); while (iter.hasNext()) { result.add(iter.next()); } return(result); }
public override void Scan(IndexProgressor progressor, bool providesLabels, int label) { base.Initialize(progressor); if (_read.hasTxStateWithChanges()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.LongDiffSets changes = read.txState().nodesWithLabelChanged(label); LongDiffSets changes = _read.txState().nodesWithLabelChanged(label); _added = changes.Augment(ImmutableEmptyLongIterator.INSTANCE); _removed = mergeToSet(_read.txState().addedAndRemovedNodes().Removed, changes.Removed); } }
public override void Close() { if (!Closed) { _read = null; _hasChanges = HasChanges.Maybe; _addedNodes = ImmutableEmptyLongIterator.INSTANCE; _storeCursor.reset(); _pool.accept(this); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void frozenIteratorFailsWhenParentSetIsClosed() internal virtual void FrozenIteratorFailsWhenParentSetIsClosed() { _set.addAll(1, 2, 3, 100, 200, 300); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator iter = set.freeze().longIterator(); LongIterator iter = _set.freeze().longIterator(); _set.close(); assertThrows(typeof(ConcurrentModificationException), iter.hasNext); assertThrows(typeof(ConcurrentModificationException), iter.next); }
/// <summary> /// Store all types that was added in the transaction for the current node /// </summary> private void CheckTxStateForUpdates() { if (_read.hasTxStateWithChanges()) { NodeState nodeState = _read.txState().getNodeState(_storeCursor.OwningNode); LongIterator addedRelationships = nodeState.AddedRelationships; while (addedRelationships.hasNext()) { RelationshipState relationshipState = _read.txState().getRelationshipState(addedRelationships.next()); relationshipState.Accept((relationshipId, typeId, startNodeId, endNodeId) => _txTypes.add(typeId)); } } }
private void AssertIds(RecordIdIterator ids, params long[][] expectedIds) { foreach (long[] expectedArray in expectedIds) { LongIterator iterator = ids.NextBatch(); assertNotNull(iterator); foreach (long expectedId in expectedArray) { assertEquals(expectedId, iterator.next()); } assertFalse(iterator.hasNext()); } assertNull(ids.NextBatch()); }
public override LongIterator NextBatch() { if (StartId >= HighExcluded) { return(null); } long endId = min(HighExcluded, FindRoofId(StartId)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator result = range(startId, endId - 1); LongIterator result = range(StartId, endId - 1); StartId = endId; return(result); }
public override LongIterator NextBatch() { if (EndId <= LowIncluded) { return(null); } long startId = FindFloorId(EndId); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator result = range(startId, endId - 1); LongIterator result = range(startId, EndId - 1); EndId = max(LowIncluded, startId); return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnAllNodesWithLabel() public virtual void ShouldReturnAllNodesWithLabel() { // GIVEN Node node1 = CreateLabeledNode(Db, map("name", "First", "age", 1L), Label1); Node node2 = CreateLabeledNode(Db, map("type", "Node", "count", 10), Label1, Label2); int labelId1 = LabelId(Label1); int labelId2 = LabelId(Label2); // WHEN LongIterator nodesForLabel1 = StorageReader.nodesGetForLabel(labelId1); LongIterator nodesForLabel2 = StorageReader.nodesGetForLabel(labelId2); // THEN assertEquals(asSet(node1.Id, node2.Id), PrimitiveLongCollections.toSet(nodesForLabel1)); assertEquals(asSet(node2.Id), PrimitiveLongCollections.toSet(nodesForLabel2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetRelationships() public virtual void ShouldGetRelationships() { RelationshipChangesForNode changes = new RelationshipChangesForNode(RelationshipChangesForNode.DiffStrategy.Add); const int type = 2; changes.AddRelationship(1, type, INCOMING); changes.AddRelationship(2, type, OUTGOING); changes.AddRelationship(3, type, OUTGOING); changes.AddRelationship(4, type, LOOP); changes.AddRelationship(5, type, LOOP); changes.AddRelationship(6, type, LOOP); LongIterator rawRelationships = changes.Relationships; assertThat(PrimitiveLongCollections.asArray(rawRelationships), Ids(1, 2, 3, 4, 5, 6)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProvidePopulatorThatAcceptsDuplicateEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProvidePopulatorThatAcceptsDuplicateEntries() { // when IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults()); WithPopulator(IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024)), p => p.add(Arrays.asList(add(1, Descriptor.schema(), "v1", "v2"), add(2, Descriptor.schema(), "v1", "v2")))); // then using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, indexSamplingConfig)) { using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader())) { LongIterator nodes = reader.Query(IndexQuery.exact(1, "v1"), IndexQuery.exact(1, "v2")); assertEquals(asSet(1L, 2L), PrimitiveLongCollections.toSet(nodes)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldFindMultipleNodesInEachRange() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindMultipleNodesInEachRange() { // GIVEN GBPTree <LabelScanKey, LabelScanValue> index = mock(typeof(GBPTree)); RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor = mock(typeof(RawCursor)); when(cursor.Next()).thenReturn(true, true, true, false); when(cursor.get()).thenReturn(Hit(0, 0b1000_1000__1100_0010L), Hit(1, 0b0000_0010__0000_1000L), Hit(3, 0b0010_0000__1010_0001L), null); when(index.Seek(any(typeof(LabelScanKey)), any(typeof(LabelScanKey)))).thenReturn(cursor); using (NativeLabelScanReader reader = new NativeLabelScanReader(index)) { // WHEN LongIterator iterator = reader.NodesWithLabel(LABEL_ID); // THEN assertArrayEquals(new long[] { 1, 6, 7, 11, 15, 64 + 3, 64 + 9, 192 + 0, 192 + 5, 192 + 7, 192 + 13 }, asArray(iterator)); } }
/// <summary> /// used by the consistency checker /// </summary> public static LongIterator ExactIndexMatches(NodePropertyAccessor accessor, LongIterator indexedNodeIds, params IndexQuery[] predicates) { if (!indexedNodeIds.hasNext()) { return(indexedNodeIds); } //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: IndexQuery[] filteredPredicates = java.util.predicates.Where(LookupFilter.isNumericOrGeometricPredicate).ToArray(IndexQuery[] ::new); if (filteredPredicates.Length > 0) { System.Func <long, bool> combinedPredicate = nodeId => { try { foreach (IndexQuery predicate in filteredPredicates) { int propertyKeyId = predicate.propertyKeyId(); Value value = accessor.GetNodePropertyValue(nodeId, propertyKeyId); if (!predicate.acceptsValue(value)) { return(false); } } return(true); } catch (EntityNotFoundException) { return(false); // The node has been deleted but was still reported from the index. CC will catch // this through other mechanism (NodeInUseWithCorrectLabelsCheck), so we can // silently ignore here } }; return(PrimitiveLongCollections.filter(indexedNodeIds, combinedPredicate)); } return(indexedNodeIds); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSupportMultipleOpenCursorsConcurrently() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSupportMultipleOpenCursorsConcurrently() { // GIVEN GBPTree <LabelScanKey, LabelScanValue> index = mock(typeof(GBPTree)); RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor1 = mock(typeof(RawCursor)); when(cursor1.Next()).thenReturn(false); RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor2 = mock(typeof(RawCursor)); when(cursor2.Next()).thenReturn(false); when(index.Seek(any(typeof(LabelScanKey)), any(typeof(LabelScanKey)))).thenReturn(cursor1, cursor2); // WHEN using (NativeLabelScanReader reader = new NativeLabelScanReader(index)) { // first check test invariants verify(cursor1, never()).close(); verify(cursor2, never()).close(); LongIterator first = reader.NodesWithLabel(LABEL_ID); LongIterator second = reader.NodesWithLabel(LABEL_ID); // getting the second iterator should not have closed the first one verify(cursor1, never()).close(); verify(cursor2, never()).close(); // exhausting the first one should have closed only the first one Exhaust(first); verify(cursor1, times(1)).close(); verify(cursor2, never()).close(); // exhausting the second one should close it Exhaust(second); verify(cursor1, times(1)).close(); verify(cursor2, times(1)).close(); } }
public DeleteDuplicateNodesStage(Configuration config, LongIterator duplicateNodeIds, BatchingNeoStores neoStore, DataImporter.Monitor storeMonitor) : base("DEDUP", null, config, 0) { Add(new DeleteDuplicateNodesStep(Control(), config, duplicateNodeIds, neoStore.NodeStore, neoStore.PropertyStore, storeMonitor)); }
public override LongIterator Augment(LongIterator source) { return(DiffApplyingPrimitiveLongIterator.Augment(source, _added, _removed)); }