Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {7, 11, 14, 20, 35, 58}) void partitionedIndexPopulation(int affectedNodes) throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PartitionedIndexPopulation(int affectedNodes)
        {
            File rootFolder = new File(_testDir.directory("partitionIndex" + affectedNodes), "uniqueIndex" + affectedNodes);

            using (SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create(_descriptor, Config.defaults()).withFileSystem(_fileSystem).withIndexRootFolder(rootFolder).build())
            {
                uniqueIndex.open();

                // index is empty and not yet exist
                assertEquals(0, uniqueIndex.allDocumentsReader().maxCount());
                assertFalse(uniqueIndex.exists());

                using (LuceneIndexAccessor indexAccessor = new LuceneIndexAccessor(uniqueIndex, _descriptor))
                {
                    GenerateUpdates(indexAccessor, affectedNodes);
                    indexAccessor.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited);

                    // now index is online and should contain updates data
                    assertTrue(uniqueIndex.Online);

                    using (IndexReader indexReader = indexAccessor.NewReader(), IndexSampler indexSampler = indexReader.CreateSampler())
                    {
                        long[] nodes = PrimitiveLongCollections.asArray(indexReader.Query(IndexQuery.exists(1)));
                        assertEquals(affectedNodes, nodes.Length);

                        IndexSample sample = indexSampler.SampleIndex();
                        assertEquals(affectedNodes, sample.IndexSize());
                        assertEquals(affectedNodes, sample.UniqueValues());
                        assertEquals(affectedNodes, sample.SampleSize());
                    }
                }
            }
        }
//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));
        }
Beispiel #3
0
 internal static long[] SortAndDeduplicate(long[] labels)
 {
     if (ArrayUtils.isNotEmpty(labels))
     {
         sort(labels);
         return(PrimitiveLongCollections.deduplicate(labels));
     }
     return(labels);
 }
Beispiel #4
0
 private void AssertNoContentInNativeLabelScanStore(DatabaseLayout databaseLayout)
 {
     using (Lifespan lifespan = new Lifespan())
     {
         NativeLabelScanStore nativeLabelScanStore = GetNativeLabelScanStore(databaseLayout, true);
         lifespan.Add(nativeLabelScanStore);
         using (LabelScanReader labelScanReader = nativeLabelScanStore.NewReader())
         {
             int count = PrimitiveLongCollections.count(labelScanReader.NodesWithLabel(1));
             assertEquals(0, count);
         }
     }
 }
//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));
        }
Beispiel #7
0
//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));
                    }
                }
            }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populateNativeLabelScanIndexDuringMigration() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulateNativeLabelScanIndexDuringMigration()
        {
            Prepare34DatabaseWithNodes();
            _indexMigrator.migrate(_databaseLayout, _migrationLayout, _progressReporter, StandardV3_4.STORE_VERSION, StandardV3_4.STORE_VERSION);
            _indexMigrator.moveMigratedFiles(_migrationLayout, _databaseLayout, StandardV2_3.STORE_VERSION, StandardV3_2.STORE_VERSION);

            using (Lifespan lifespan = new Lifespan())
            {
                NativeLabelScanStore labelScanStore = GetNativeLabelScanStore(_databaseLayout, true);
                lifespan.Add(labelScanStore);
                for (int labelId = 0; labelId < 10; labelId++)
                {
                    using (LabelScanReader labelScanReader = labelScanStore.NewReader())
                    {
                        int nodeCount = PrimitiveLongCollections.count(labelScanReader.NodesWithLabel(labelId));
                        assertEquals(format("Expected to see only one node for label %d but was %d.", labelId, nodeCount), 1, nodeCount);
                    }
                }
            }
        }
Beispiel #9
0
        /// <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);
        }