Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleLabelsForManyNodes()
        public virtual void ShouldHandleLabelsForManyNodes()
        {
            // GIVEN a really weird scenario where we have 5000 different labels
            int             highLabelId = 1_000;
            NodeLabelsCache cache       = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, highLabelId, 1_000_000);

            NodeLabelsCache.Client client = cache.NewClient();
            int numberOfNodes             = 100_000;

            int[][] expectedLabels = new int[numberOfNodes][];
            for (int i = 0; i < numberOfNodes; i++)
            {
                int[] labels = RandomLabels(_random.Next(30) + 1, highLabelId);
                expectedLabels[i] = labels;
                cache.Put(i, AsLongArray(labels));
            }

            // THEN
            int[] forceCreationOfNewIntArray = new int[0];
            for (int i = 0; i < numberOfNodes; i++)
            {
                int[] labels = cache.Get(client, i, forceCreationOfNewIntArray);
                assertArrayEquals("For node " + i, expectedLabels[i], labels);
            }
        }
Ejemplo n.º 2
0
 internal LabelGetter(NodeLabelsCache cache, int[][] expectedLabels, int numberOfNodes)
 {
     this.Cache          = cache;
     this.Client         = cache.NewClient();
     this.ExpectedLabels = expectedLabels;
     this.NumberOfNodes  = numberOfNodes;
 }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnEmptyArrayForNodeWithNoLabelsAndNoLabelsWhatsoever()
        public virtual void ShouldReturnEmptyArrayForNodeWithNoLabelsAndNoLabelsWhatsoever()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 0);

            NodeLabelsCache.Client client = cache.NewClient();

            // WHEN
            int[] target = new int[3];
            cache.Get(client, 0, target);

            // THEN
            assertEquals(-1, target[0]);
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCacheSmallSetOfLabelsPerNode()
        public virtual void ShouldCacheSmallSetOfLabelsPerNode()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 5, CHUNK_SIZE);

            NodeLabelsCache.Client client = cache.NewClient();
            long nodeId = 0;

            // WHEN
            cache.Put(nodeId, new long[] { 1, 2, 3 });

            // THEN
            int[] readLabels = new int[3];
            cache.Get(client, nodeId, readLabels);
            assertArrayEquals(new int[] { 1, 2, 3 }, readLabels);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleLargeAmountOfLabelsPerNode()
        public virtual void ShouldHandleLargeAmountOfLabelsPerNode()
        {
            // GIVEN
            int             highLabelId = 1000;
            NodeLabelsCache cache       = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, highLabelId, CHUNK_SIZE);

            NodeLabelsCache.Client client = cache.NewClient();
            long nodeId = 0;

            // WHEN
            int[] labels = RandomLabels(200, 1000);
            cache.Put(nodeId, AsLongArray(labels));

            // THEN
            int[] readLabels = new int[labels.Length];
            cache.Get(client, nodeId, readLabels);
            assertArrayEquals(labels, readLabels);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEndTargetArrayWithMinusOne()
        public virtual void ShouldEndTargetArrayWithMinusOne()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 10);

            NodeLabelsCache.Client client = cache.NewClient();
            cache.Put(10, new long[] { 5, 6, 7, 8 });

            // WHEN
            int[] target = new int[20];
            assertSame(target, cache.Get(client, 10, target));
            assertEquals(5, target[0]);
            assertEquals(6, target[1]);
            assertEquals(7, target[2]);
            assertEquals(8, target[3]);

            // THEN
            assertEquals(-1, target[4]);
        }