private static void AssertRanges(AllEntriesLabelScanReader reader, Labels[] data)
        {
            IEnumerator <NodeLabelRange> iterator = reader.GetEnumerator();
            long highestRangeId = highestRangeId(data);

            for (long rangeId = 0; rangeId <= highestRangeId; rangeId++)
            {
                SortedDictionary <long, IList <long> > expected = RangeOf(data, rangeId);
                if (expected != null)
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue("Was expecting range " + expected, iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    NodeLabelRange range = iterator.next();

                    assertEquals(rangeId, range.Id());
                    foreach (KeyValuePair <long, IList <long> > expectedEntry in expected.SetOfKeyValuePairs())
                    {
                        long[] labels = range.Labels(expectedEntry.Key);
                        assertArrayEquals(asArray(expectedEntry.Value.GetEnumerator()), labels);
                    }
                }
                // else there was nothing in this range
            }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldScanMultipleRanges()
        public virtual void ShouldScanMultipleRanges()
        {
            // GIVEN
            int  labelId1 = 1;
            int  labelId2 = 2;
            long nodeId1  = 10;
            long nodeId2  = 1280;

            Start(new IList <NodeLabelUpdate> {
                labelChanges(nodeId1, _noLabels, new long[] { labelId1 }), labelChanges(nodeId2, _noLabels, new long[] { labelId1, labelId2 })
            });

            // WHEN
            BoundedIterable <NodeLabelRange> reader   = _store.allNodeLabelRanges();
            IEnumerator <NodeLabelRange>     iterator = reader.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            NodeLabelRange range1 = iterator.next();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            NodeLabelRange range2 = iterator.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());

            // THEN
            assertArrayEquals(new long[] { nodeId1 }, ReducedNodes(range1));
            assertArrayEquals(new long[] { nodeId2 }, ReducedNodes(range2));

            assertArrayEquals(new long[] { labelId1 }, Sorted(range1.Labels(nodeId1)));

            assertArrayEquals(new long[] { labelId1, labelId2 }, Sorted(range2.Labels(nodeId2)));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldScanSingleRange()
        public virtual void ShouldScanSingleRange()
        {
            // GIVEN
            int  labelId1 = 1;
            int  labelId2 = 2;
            long nodeId1  = 10;
            long nodeId2  = 11;

            Start(new IList <NodeLabelUpdate> {
                labelChanges(nodeId1, _noLabels, new long[] { labelId1 }), labelChanges(nodeId2, _noLabels, new long[] { labelId1, labelId2 })
            });

            // WHEN
            BoundedIterable <NodeLabelRange> reader = _store.allNodeLabelRanges();
            NodeLabelRange range = single(reader.GetEnumerator());

            // THEN
            assertArrayEquals(new long[] { nodeId1, nodeId2 }, ReducedNodes(range));

            assertArrayEquals(new long[] { labelId1 }, Sorted(range.Labels(nodeId1)));
            assertArrayEquals(new long[] { labelId1, labelId2 }, Sorted(range.Labels(nodeId2)));
        }
        private long[] ReducedNodes(NodeLabelRange range)
        {
            long[] nodes  = range.Nodes();
            long[] result = new long[nodes.Length];
            int    cursor = 0;

            foreach (long node in nodes)
            {
                if (range.Labels(node).Length > 0)
                {
                    result[cursor++] = node;
                }
            }
            return(Arrays.copyOf(result, cursor));
        }
Exemple #5
0
        private static void AssertRanges(IEnumerator <NodeLabelRange> iterator, int[] expectedRanges)
        {
            for (int expectedRangeId = 0; expectedRangeId < expectedRanges.Length; expectedRangeId++)
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue(iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                NodeLabelRange actualRange = iterator.next();
                assertEquals(expectedRangeId, actualRange.Id());
                int  expectedRange = expectedRanges[expectedRangeId];
                long baseNodeId    = expectedRangeId * RANGE_SIZE;
                for (int i = 0; i < RANGE_SIZE; i++)
                {
                    long   nodeId           = baseNodeId + i;
                    long[] expectedLabelIds = (expectedRange & (1 << i)) == 0 ? EMPTY_LONG_ARRAY : _labelIds;
                    assertArrayEquals(expectedLabelIds, actualRange.Labels(nodeId));
                    assertEquals(nodeId, actualRange.Nodes()[i]);
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());
        }