Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexNumberRangeQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexNumberRangeQuery()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(1, 1), add(2, 2), add(3, 3), add(4, 4), add(5, Double.NaN)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(1, 1), Add(2, 2), Add(3, 3), Add(4, 4), Add(5, Double.NaN)
            });

            IndexReader reader = _accessor.newReader();

            LongIterator rangeTwoThree = reader.Query(range(PROP_ID, 2, true, 3, true));

            assertThat(PrimitiveLongCollections.asArray(rangeTwoThree), LongArrayMatcher.Of(2, 3));

            LongIterator infiniteMaxRange = reader.Query(range(PROP_ID, 2, true, long.MaxValue, true));

            assertThat(PrimitiveLongCollections.asArray(infiniteMaxRange), LongArrayMatcher.Of(2, 3, 4));

            LongIterator infiniteMinRange = reader.Query(range(PROP_ID, long.MinValue, true, 3, true));

            assertThat(PrimitiveLongCollections.asArray(infiniteMinRange), LongArrayMatcher.Of(PROP_ID, 2, 3));

            LongIterator maxNanInterval = reader.Query(range(PROP_ID, 3, true, Double.NaN, true));

            assertThat(PrimitiveLongCollections.asArray(maxNanInterval), LongArrayMatcher.Of(3, 4, 5));

            LongIterator minNanInterval = reader.Query(range(PROP_ID, Double.NaN, true, 5, true));

            assertThat(PrimitiveLongCollections.asArray(minNanInterval), LongArrayMatcher.EmptyArrayMatcher());

            LongIterator nanInterval = reader.Query(range(PROP_ID, Double.NaN, true, Double.NaN, true));

            assertThat(PrimitiveLongCollections.asArray(nanInterval), LongArrayMatcher.Of(5));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MultipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults()
        {
            // WHEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(nodeId, value)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(_nodeId, _value)
            });
            IndexReader firstReader = _accessor.newReader();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(nodeId2, value2)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(_nodeId2, _value2)
            });
            IndexReader secondReader = _accessor.newReader();

            // THEN
            assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(firstReader.Query(exact(PROP_ID, _value))));
            assertEquals(asSet(), PrimitiveLongCollections.toSet(firstReader.Query(exact(PROP_ID, _value2))));
            assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(secondReader.Query(exact(PROP_ID, _value))));
            assertEquals(asSet(_nodeId2), PrimitiveLongCollections.toSet(secondReader.Query(exact(PROP_ID, _value2))));
            firstReader.Close();
            secondReader.Close();
        }
 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 shouldApplyUpdatesIdempotently() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyUpdatesIdempotently()
        {
            // GIVEN
            IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.Value propertyValue = org.neo4j.values.storable.Values.of("value1");
            Value propertyValue = Values.of("value1");

            WithPopulator(IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024)), p =>
            {
                long nodeId = 1;

                // update using populator...
                IndexEntryUpdate <SchemaDescriptor> update = add(nodeId, Descriptor.schema(), propertyValue);
                p.add(singletonList(update));
                // ...is the same as update using updater
                using (IndexUpdater updater = p.newPopulatingUpdater((node, propertyId) => propertyValue))
                {
                    updater.Process(update);
                }
            });

            // THEN
            using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, indexSamplingConfig))
            {
                using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader()))
                {
                    int          propertyKeyId = Descriptor.schema().PropertyId;
                    LongIterator nodes         = reader.Query(IndexQuery.exact(propertyKeyId, propertyValue));
                    assertEquals(asSet(1L), PrimitiveLongCollections.toSet(nodes));
                }
            }
        }
Пример #5
0
        public virtual void SampleIndexes(IndexSamplingMode mode)
        {
            IndexMap indexMap = _indexMapSnapshotProvider.indexMapSnapshot();

            _jobQueue.addAll(!mode.sampleOnlyIfUpdated, PrimitiveLongCollections.toIterator(indexMap.IndexIds()));
            ScheduleSampling(mode, indexMap);
        }
        /* ALL = FALSE */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReportAllFromSingleIterator()
        public virtual void MustReportAllFromSingleIterator()
        {
            // given
            long[] expected = new long[] { 0L, 1L, long.MaxValue };
            IList <PrimitiveLongResourceIterator> iterators = Collections.singletonList(iterator(null, expected));

            // when
            CompositeLabelScanValueIterator iterator = new CompositeLabelScanValueIterator(iterators, false);

            // then
            assertArrayEquals(expected, PrimitiveLongCollections.asArray(iterator));
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rangeSeekByPrefixOverPartitions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RangeSeekByPrefixOverPartitions()
        {
            PartitionedIndexReader indexReader = CreatePartitionedReaderFromReaders();

            IndexQuery.StringPrefixPredicate query = IndexQuery.stringPrefix(1, stringValue("prefix"));
            when(_indexReader1.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 1));
            when(_indexReader2.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 2));
            when(_indexReader3.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 3));

            LongSet results = PrimitiveLongCollections.asSet(indexReader.Query(query));

            VerifyResult(results);
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scanOverPartitions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScanOverPartitions()
        {
            PartitionedIndexReader indexReader = CreatePartitionedReaderFromReaders();

            IndexQuery.ExistsPredicate query = IndexQuery.exists(1);
            when(_indexReader1.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 1));
            when(_indexReader2.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 2));
            when(_indexReader3.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 3));

            LongSet results = PrimitiveLongCollections.asSet(indexReader.Query(query));

            VerifyResult(results);
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canAddNewData() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanAddNewData()
        {
            // WHEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(_nodeId, _value), Add(_nodeId2, _value2)
            });
            IndexReader reader = _accessor.newReader();

            // THEN
            assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(reader.Query(exact(PROP_ID, _value))));
            reader.Close();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void iterateOverLabeledNodeIds()
        public virtual void IterateOverLabeledNodeIds()
        {
            PrimitiveLongResourceIterator labeledNodes = PrimitiveLongResourceCollections.iterator(null, 1, 2, 4, 8);

            when(_nodeStore.HighId).thenReturn(15L);
            int[] labelIds = new int[] { 1, 2 };
            when(_labelScanReader.nodesWithAnyOfLabels(labelIds)).thenReturn(labeledNodes);

            LabelScanViewNodeStoreScan <Exception> storeScan  = GetLabelScanViewStoreScan(labelIds);
            PrimitiveLongResourceIterator          idIterator = storeScan.EntityIdIterator;
            IList <long> visitedNodeIds = PrimitiveLongCollections.asList(idIterator);

            assertThat(visitedNodeIds, Matchers.hasSize(4));
            assertThat(visitedNodeIds, Matchers.hasItems(1L, 2L, 4L, 8L));
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rangeSeekByStringOverPartitions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RangeSeekByStringOverPartitions()
        {
            PartitionedIndexReader indexReader = CreatePartitionedReaderFromReaders();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> query = org.neo4j.internal.kernel.api.IndexQuery.range(1, "a", false, "b", true);
            IndexQuery.RangePredicate <object> query = IndexQuery.range(1, "a", false, "b", true);
            when(_indexReader1.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 1));
            when(_indexReader2.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 2));
            when(_indexReader3.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 3));

            LongSet results = PrimitiveLongCollections.asSet(indexReader.Query(query));

            VerifyResult(results);
        }
Пример #12
0
        private static void AssertQueryResultsMatch(ScoreEntityIterator result, long[] ids)
        {
            PrimitiveLongSet set = PrimitiveLongCollections.setOf(ids);

            while (result.MoveNext())
            {
                long next = result.Current.entityId();
                assertTrue(format("Result returned node id %d, expected one of %s", next, Arrays.ToString(ids)), set.Remove(next));
            }
            if (!set.Empty)
            {
                IList <long> list = new List <long>();
                set.VisitKeys(k => !list.Add(k));
                fail("Number of results differ from expected. " + set.Size() + " IDs were not found in the result: " + list);
            }
        }
Пример #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addUpdates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AddUpdates()
        {
            _populator = NewPopulator();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "aaa"), add(2, schemaDescriptor, "bbb"), add(3, schemaDescriptor, "ccc"));
            IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, _schemaDescriptor, "aaa"), add(2, _schemaDescriptor, "bbb"), add(3, _schemaDescriptor, "ccc"));

            _populator.add(updates);

            _index.maybeRefreshBlocking();
            using (IndexReader reader = _index.IndexReader)
            {
                LongIterator allEntities = reader.Query(IndexQuery.exists(1));
                assertArrayEquals(new long[] { 1, 2, 3 }, PrimitiveLongCollections.asArray(allEntities));
            }
        }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexReaderShouldSupportScan() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexReaderShouldSupportScan()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(nodeId, values), add(nodeId2, values2)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(_nodeId, _values), Add(_nodeId2, _values2)
            });
            IndexReader reader = _accessor.newReader();

            // WHEN
            LongIterator results = reader.Query(IndexQuery.exists(PROP_ID1), IndexQuery.exists(PROP_ID2));

            // THEN
            assertEquals(asSet(_nodeId, _nodeId2), PrimitiveLongCollections.toSet(results));
            assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(reader.Query(exact(PROP_ID1, _values[0]), exact(PROP_ID2, _values[1]))));
            reader.Close();
        }
Пример #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexStringRangeQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexStringRangeQuery()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(PROP_ID, "A"), add(2, "B"), add(3, "C"), add(4, "")));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(PROP_ID, "A"), Add(2, "B"), Add(3, "C"), Add(4, "")
            });

            IndexReader reader = _accessor.newReader();

            LongIterator rangeFromBInclusive = reader.Query(range(PROP_ID, "B", true, null, false));

            assertThat(PrimitiveLongCollections.asArray(rangeFromBInclusive), LongArrayMatcher.Of(2, 3));

            LongIterator rangeFromANonInclusive = reader.Query(range(PROP_ID, "A", false, null, false));

            assertThat(PrimitiveLongCollections.asArray(rangeFromANonInclusive), LongArrayMatcher.Of(2, 3));

            LongIterator emptyLowInclusive = reader.Query(range(PROP_ID, "", true, null, false));

            assertThat(PrimitiveLongCollections.asArray(emptyLowInclusive), LongArrayMatcher.Of(PROP_ID, 2, 3, 4));

            LongIterator emptyUpperNonInclusive = reader.Query(range(PROP_ID, "B", true, "", false));

            assertThat(PrimitiveLongCollections.asArray(emptyUpperNonInclusive), LongArrayMatcher.EmptyArrayMatcher());

            LongIterator emptyInterval = reader.Query(range(PROP_ID, "", true, "", true));

            assertThat(PrimitiveLongCollections.asArray(emptyInterval), LongArrayMatcher.Of(4));

            LongIterator emptyAllNonInclusive = reader.Query(range(PROP_ID, "", false, null, false));

            assertThat(PrimitiveLongCollections.asArray(emptyAllNonInclusive), LongArrayMatcher.Of(PROP_ID, 2, 3));

            LongIterator nullNonInclusive = reader.Query(range(PROP_ID, ( string )null, false, null, false));

            assertThat(PrimitiveLongCollections.asArray(nullNonInclusive), LongArrayMatcher.Of(PROP_ID, 2, 3, 4));

            LongIterator nullInclusive = reader.Query(range(PROP_ID, ( string )null, false, null, false));

            assertThat(PrimitiveLongCollections.asArray(nullInclusive), LongArrayMatcher.Of(PROP_ID, 2, 3, 4));
        }
Пример #16
0
//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 mustReportAllFromNonOverlappingMultipleIterators()
        public virtual void MustReportAllFromNonOverlappingMultipleIterators()
        {
            // given
            AtomicInteger closeCounter = new AtomicInteger();

            long[] firstIter  = new long[] { 0L, 2L, long.MaxValue };
            long[] secondIter = new long[] { 1L, 3L };
            long[] expected   = new long[] { 0L, 1L, 2L, 3L, long.MaxValue };
            IList <PrimitiveLongResourceIterator> iterators = AsMutableList(iterator(closeCounter.incrementAndGet, firstIter), iterator(closeCounter.incrementAndGet, secondIter));

            // when
            CompositeLabelScanValueIterator iterator = new CompositeLabelScanValueIterator(iterators, false);

            // then
            assertArrayEquals(expected, PrimitiveLongCollections.asArray(iterator));

            // when
            iterator.Close();

            // then
            assertEquals("expected close count", 2, closeCounter.get());
        }
Пример #18
0
//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);
        }
Пример #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canChangeExistingData() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanChangeExistingData()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(add(nodeId, values)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Add(_nodeId, _values)
            });

            // WHEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: updateAndCommit(asList(change(nodeId, values, values2)));
            UpdateAndCommit(new IList <IndexEntryUpdate <object> > {
                Change(_nodeId, _values, _values2)
            });
            IndexReader reader = _accessor.newReader();

            // THEN
            assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(reader.Query(exact(PROP_ID1, _values2[0]), exact(PROP_ID2, _values2[1]))));
            assertEquals(emptySet(), PrimitiveLongCollections.toSet(reader.Query(exact(PROP_ID1, _values[0]), exact(PROP_ID2, _values[1]))));
            reader.Close();
        }
Пример #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustCombineResultFromExistsPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustCombineResultFromExistsPredicate()
        {
            // given
            IndexQuery.ExistsPredicate exists = IndexQuery.exists(PROP_KEY);
            long lastId = 0;

            foreach (IndexReader aliveReader in _aliveReaders)
            {
                when(aliveReader.Query(exists)).thenReturn(PrimitiveLongResourceCollections.iterator(null, lastId++, lastId++));
            }

            // when
            LongIterator result = _fusionIndexReader.query(exists);

            // then

            LongSet resultSet = PrimitiveLongCollections.asSet(result);

            for (long i = 0L; i < lastId; i++)
            {
                assertTrue("Expected to contain " + i + ", but was " + resultSet, resultSet.contains(i));
            }
        }
        /* ALL = TRUE */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustOnlyReportValuesReportedByAll()
        public virtual void MustOnlyReportValuesReportedByAll()
        {
            // given
            AtomicInteger closeCounter = new AtomicInteger();

            long[] firstIter  = new long[] { 0L, long.MaxValue };
            long[] secondIter = new long[] { 0L, 1L, long.MaxValue };
            long[] thirdIter  = new long[] { 0L, 1L, 2L, long.MaxValue };
            long[] expected   = new long[] { 0L, long.MaxValue };
            IList <PrimitiveLongResourceIterator> iterators = AsMutableList(iterator(closeCounter.incrementAndGet, firstIter), iterator(closeCounter.incrementAndGet, secondIter), iterator(closeCounter.incrementAndGet, thirdIter));

            // when
            CompositeLabelScanValueIterator iterator = new CompositeLabelScanValueIterator(iterators, true);

            // then
            assertArrayEquals(expected, PrimitiveLongCollections.asArray(iterator));

            // when
            iterator.Close();

            // then
            assertEquals("expected close count", 3, closeCounter.get());
        }
Пример #22
0
        public virtual void ShouldDeleteEverythingAboutTheDuplicatedNodes()
        {
            // given
            NeoStores neoStores = _neoStoresRule.builder().build();

            Ids[] ids = new Ids[9];
            DataImporter.Monitor monitor = new DataImporter.Monitor();
            ids[0] = CreateNode(monitor, neoStores, 10, 10);               // node with many properties and many labels
            ids[1] = CreateNode(monitor, neoStores, 10, 1);                // node with many properties and few labels
            ids[2] = CreateNode(monitor, neoStores, 10, 0);                // node with many properties and no labels
            ids[3] = CreateNode(monitor, neoStores, 1, 10);                // node with few properties and many labels
            ids[4] = CreateNode(monitor, neoStores, 1, 1);                 // node with few properties and few labels
            ids[5] = CreateNode(monitor, neoStores, 1, 0);                 // node with few properties and no labels
            ids[6] = CreateNode(monitor, neoStores, 0, 10);                // node with no properties and many labels
            ids[7] = CreateNode(monitor, neoStores, 0, 1);                 // node with no properties and few labels
            ids[8] = CreateNode(monitor, neoStores, 0, 0);                 // node with no properties and no labels

            // when
            long[]             duplicateNodeIds = RandomNodes(ids);
            SimpleStageControl control          = new SimpleStageControl();

            using (DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep(control, Configuration.DEFAULT, PrimitiveLongCollections.iterator(duplicateNodeIds), neoStores.NodeStore, neoStores.PropertyStore, monitor))
            {
                control.Steps(step);
                StartAndAwaitCompletionOf(step);
            }
            control.AssertHealthy();

            // then
            int expectedNodes      = 0;
            int expectedProperties = 0;

            foreach (Ids entity in ids)
            {
                bool expectedToBeInUse = !ArrayUtils.contains(duplicateNodeIds, entity.Node.Id);
                int  stride            = expectedToBeInUse ? 1 : 0;
                expectedNodes += stride;

                // Verify node record
                assertEquals(expectedToBeInUse, neoStores.NodeStore.isInUse(entity.Node.Id));

                // Verify label records
                foreach (DynamicRecord labelRecord in entity.Node.DynamicLabelRecords)
                {
                    assertEquals(expectedToBeInUse, neoStores.NodeStore.DynamicLabelStore.isInUse(labelRecord.Id));
                }

                // Verify property records
                foreach (PropertyRecord propertyRecord in entity.Properties)
                {
                    assertEquals(expectedToBeInUse, neoStores.PropertyStore.isInUse(propertyRecord.Id));
                    foreach (PropertyBlock property in propertyRecord)
                    {
                        // Verify property dynamic value records
                        foreach (DynamicRecord valueRecord in property.ValueRecords)
                        {
                            AbstractDynamicStore valueStore;
                            switch (property.Type)
                            {
                            case STRING:
                                valueStore = neoStores.PropertyStore.StringStore;
                                break;

                            case ARRAY:
                                valueStore = neoStores.PropertyStore.ArrayStore;
                                break;

                            default:
                                throw new System.ArgumentException(propertyRecord + " " + property);
                            }
                            assertEquals(expectedToBeInUse, valueStore.IsInUse(valueRecord.Id));
                        }
                        expectedProperties += stride;
                    }
                }
            }

            assertEquals(expectedNodes, monitor.NodesImported());
            assertEquals(expectedProperties, monitor.PropertiesImported());
        }
//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
                long offset = ValueSet1.Count;

                WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p =>
                {
                    p.add(Updates(ValueSet1, 0));
                    p.add(Updates(ValueSet1, offset));
                });

                // then
                using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, IndexSamplingConfig))
                {
                    using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader()))
                    {
                        int propertyKeyId = Descriptor.schema().PropertyId;
                        foreach (NodeAndValue entry in ValueSet1)
                        {
                            NodeValueIterator nodes = new NodeValueIterator();
                            reader.Query(nodes, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, entry.Value));
                            assertEquals(entry.Value.ToString(), asSet(entry.NodeId, entry.NodeId + offset), PrimitiveLongCollections.toSet(nodes));
                        }
                    }
                }
            }
Пример #24
0
 public override PrimitiveLongIterator Iterator()
 {
     return(PrimitiveLongCollections.emptyIterator());
 }