private long[] ReadNodesForLabel(LabelScanStore labelScanStore) { using (LabelScanReader reader = labelScanStore.NewReader()) { return(PrimitiveLongCollections.asArray(reader.NodesWithLabel(_labelId))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void visitOnlyLabeledNodes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void VisitOnlyLabeledNodes() { LabelScanReader labelScanReader = mock(typeof(LabelScanReader)); when(_labelScanStore.newReader()).thenReturn(labelScanReader); when(_nodeLabelRanges.maxCount()).thenReturn(1L); PrimitiveLongResourceIterator labeledNodesIterator = PrimitiveLongResourceCollections.iterator(null, 1, 2, 3, 4, 5, 6, 7, 8); when(_nodeStore.HighestPossibleIdInUse).thenReturn(200L); when(_nodeStore.HighId).thenReturn(20L); when(labelScanReader.NodesWithAnyOfLabels(new int[] { 2, 6 })).thenReturn(labeledNodesIterator); when(_nodeStore.openPageCursorForReading(anyLong())).thenReturn(mock(typeof(PageCursor))); MockLabelNodeCount(_countStore, 2); MockLabelNodeCount(_countStore, 6); DynamicIndexStoreView storeView = DynamicIndexStoreView(); StoreScan <Exception> storeScan = storeView.VisitNodes(new int[] { 2, 6 }, _propertyKeyIdFilter, _propertyUpdateVisitor, _labelUpdateVisitor, false); storeScan.Run(); Mockito.verify(_nodeStore, times(8)).getRecordByCursor(anyLong(), any(typeof(NodeRecord)), any(typeof(RecordLoad)), any(typeof(PageCursor))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFindDecentAmountOfNodesForALabel() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindDecentAmountOfNodesForALabel() { // GIVEN // 16 is the magic number of the page iterator // 32 is the number of nodes in each lucene document const int labelId = 1; int nodeCount = 32 * 16 + 10; Start(); Write(new PrefetchingIteratorAnonymousInnerClass(this, labelId, nodeCount)); // WHEN ISet <long> nodeSet = new SortedSet <long>(); LabelScanReader reader = _store.newReader(); LongIterator nodes = reader.NodesWithLabel(labelId); while (nodes.hasNext()) { nodeSet.Add(nodes.next()); } reader.Close(); // THEN assertEquals("Found gaps in node id range: " + Gaps(nodeSet, nodeCount), nodeCount, nodeSet.Count); }
private void VerifyReads(long[] expected) { using (LabelScanReader reader = _store.newReader()) { for (int i = 0; i < LABEL_COUNT; i++) { long[] actualNodes = asArray(reader.NodesWithLabel(i)); long[] expectedNodes = NodesWithLabel(expected, i); assertArrayEquals(expectedNodes, actualNodes); } } }
private void CloseSchemaResources() { if (_indexReaderFactory != null) { _indexReaderFactory.close(); // we can actually keep this object around } if (_labelScanReader != null) { _labelScanReader.close(); _labelScanReader = null; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void checkLabelScanStoreAccessible(org.neo4j.kernel.api.labelscan.LabelScanStore labelScanStore) throws java.io.IOException private static void CheckLabelScanStoreAccessible(LabelScanStore labelScanStore) { int labelId = 1; using (LabelScanWriter labelScanWriter = labelScanStore.NewWriter()) { labelScanWriter.Write(NodeLabelUpdate.labelChanges(1, new long[] {}, new long[] { labelId })); } using (LabelScanReader labelScanReader = labelScanStore.NewReader()) { assertEquals(1, labelScanReader.NodesWithLabel(labelId).next()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFindNodesWithAllGivenLabels() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindNodesWithAllGivenLabels() { // GIVEN int labelId1 = 3; int labelId2 = 5; int labelId3 = 13; Start(); // WHEN Write(iterator(labelChanges(5, EMPTY_LONG_ARRAY, new long[] { labelId1, labelId2, labelId3 }), labelChanges(8, EMPTY_LONG_ARRAY, new long[] { labelId3 }), labelChanges(3, EMPTY_LONG_ARRAY, new long[] { labelId1 }), labelChanges(6, EMPTY_LONG_ARRAY, new long[] { labelId2 }), labelChanges(1, EMPTY_LONG_ARRAY, new long[] { labelId1 }), labelChanges(7, EMPTY_LONG_ARRAY, new long[] { labelId2 }), labelChanges(4, EMPTY_LONG_ARRAY, new long[] { labelId1, labelId3 }), labelChanges(2, EMPTY_LONG_ARRAY, new long[] { labelId1, labelId2 }), labelChanges(9, EMPTY_LONG_ARRAY, new long[] { labelId3 }))); // THEN using (LabelScanReader reader = _store.newReader()) { assertArrayEquals(new long[] { 2, 5 }, PrimitiveLongCollections.asArray(reader.NodesWithAllLabels(new int[] { labelId1, labelId2 }))); assertArrayEquals(new long[] { 4, 5 }, PrimitiveLongCollections.asArray(reader.NodesWithAllLabels(new int[] { labelId1, labelId3 }))); assertArrayEquals(new long[] { 5 }, PrimitiveLongCollections.asArray(reader.NodesWithAllLabels(new int[] { labelId1, labelId2, labelId3 }))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWorkWithAFullRange() public virtual void ShouldWorkWithAFullRange() { // given long labelId = 0; IList <NodeLabelUpdate> updates = new List <NodeLabelUpdate>(); ISet <long> nodes = new HashSet <long>(); for (int i = 0; i < 34; i++) { updates.Add(NodeLabelUpdate.labelChanges(i, new long[] {}, new long[] { labelId })); nodes.Add(( long )i); } Start(updates); // when LabelScanReader reader = _store.newReader(); ISet <long> nodesWithLabel = PrimitiveLongCollections.toSet(reader.NodesWithLabel(( int )labelId)); // then assertEquals(nodes, nodesWithLabel); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldStartFromGivenId(int sparsity) throws java.io.IOException private void ShouldStartFromGivenId(int sparsity) { // given NativeLabelScanStore store = Life.add(new NativeLabelScanStore(Storage.pageCache(), DatabaseLayout.of(Storage.directory().directory()), Storage.fileSystem(), EMPTY, false, new Monitors(), immediate())); int labelId = 1; int highNodeId = 100_000; BitArray expected = new BitArray(highNodeId); using (LabelScanWriter writer = store.NewWriter()) { int updates = highNodeId / sparsity; for (int i = 0; i < updates; i++) { int nodeId = Random.Next(highNodeId); writer.Write(labelChanges(nodeId, EMPTY_LONG_ARRAY, new long[] { labelId })); expected.Set(nodeId, true); } } // when long fromId = Random.Next(highNodeId); int nextExpectedId = expected.nextSetBit(toIntExact(fromId + 1)); using (LabelScanReader reader = store.NewReader(), PrimitiveLongResourceIterator ids = reader.NodesWithAnyOfLabels(fromId, new int[] { labelId })) { // then while (nextExpectedId != -1) { assertTrue(ids.hasNext()); long nextId = ids.next(); assertEquals(nextExpectedId, toIntExact(nextId)); nextExpectedId = expected.nextSetBit(nextExpectedId + 1); } assertFalse(ids.hasNext()); } }
public override PrimitiveLongResourceIterator NodesGetForLabel(int labelId) { return(LabelScanReader.nodesWithLabel(labelId)); }