Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverIndexCountsBySamplingThemOnStartup()
        public virtual void ShouldRecoverIndexCountsBySamplingThemOnStartup()
        {
            // given some aliens in a database
            CreateAliens();

            // that have been indexed
            AwaitIndexOnline(IndexAliensBySpecimen());

            // where ALIEN and SPECIMEN are both the first ids of their kind
            IndexDescriptor index   = TestIndexDescriptorFactory.forLabel(LabelId(_alien), PkId(SPECIMEN));
            SchemaStorage   storage = new SchemaStorage(NeoStores().SchemaStore);
            long            indexId = storage.IndexGetForSchema(index).Id;

            // for which we don't have index counts
            ResetIndexCounts(indexId);

            // when we shutdown the database and restart it
            Restart();

            // then we should have re-sampled the index
            CountsTracker tracker = NeoStores().Counts;

            AssertEqualRegisters("Unexpected updates and size for the index", newDoubleLongRegister(0, 32), tracker.IndexUpdatesAndSize(indexId, newDoubleLongRegister()));
            AssertEqualRegisters("Unexpected sampling result", newDoubleLongRegister(16, 32), tracker.IndexSample(indexId, newDoubleLongRegister()));

            // and also
            AssertLogExistsForRecoveryOn(":Alien(specimen)");
        }
 private void InitializeInstanceFields()
 {
     _storeApplier = new NeoStoreBatchTransactionApplier(_neoStores, mock(typeof(CacheAccessBackDoor)), LockService.NO_LOCK_SERVICE);
     _labelScanStoreSynchronizer = new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(_labelScanStore);
     _indexUpdatesSync           = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexes);
     _indexApplier = new IndexBatchTransactionApplier(_indexes, _labelScanStoreSynchronizer, _indexUpdatesSync, mock(typeof(NodeStore)), _neoStores.RelationshipStore, _propertyStore, new IndexActivator(_indexes));
     _rule         = TestIndexDescriptorFactory.forLabel(_labelId, _propertyKey).withId(_id);
 }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp()
        internal virtual void SetUp()
        {
            PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(DirectoryFactory.PERSISTENT, _fileSystem, _testDirectory.directory());
            Config config = Config.defaults();
            IndexSamplingConfig samplingConfig = new IndexSamplingConfig(config);

            _luceneSchemaIndex = new ReadOnlyDatabaseSchemaIndex(indexStorage, TestIndexDescriptorFactory.forLabel(0, 0), samplingConfig, new ReadOnlyIndexPartitionFactory());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTriggerResampling() throws org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException, org.neo4j.internal.kernel.api.exceptions.ProcedureException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTriggerResampling()
        {
            IndexDescriptor index = TestIndexDescriptorFactory.forLabel(123, 456);

            when(_schemaRead.index(anyInt(), any())).thenReturn(index);

            _procedure.resampleIndex(":Person(name)");

            verify(_indexingService).triggerIndexSampling(index.Schema(), IndexSamplingMode.TRIGGER_REBUILD_ALL);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void collectsDbStructure()
        public virtual void CollectsDbStructure()
        {
            // GIVEN
            DbStructureCollector collector = new DbStructureCollector();

            collector.VisitLabel(1, "Person");
            collector.VisitLabel(2, "City");
            collector.VisitPropertyKey(1, "name");
            collector.VisitPropertyKey(2, "income");
            collector.VisitRelationshipType(1, "LIVES_IN");
            collector.VisitRelationshipType(2, "FRIEND");
            collector.VisitIndex(TestIndexDescriptorFactory.uniqueForLabel(1, 1), ":Person(name)", 1.0d, 1L);
            collector.VisitUniqueConstraint(ConstraintDescriptorFactory.uniqueForLabel(2, 1), ":City(name)");
            collector.VisitNodeKeyConstraint(ConstraintDescriptorFactory.nodeKeyForLabel(2, 1), ":City(name)");
            collector.VisitIndex(TestIndexDescriptorFactory.forLabel(2, 2), ":City(income)", 0.2d, 1L);
            collector.VisitAllNodesCount(50);
            collector.VisitNodeCount(1, "Person", 20);
            collector.VisitNodeCount(2, "City", 30);
            collector.VisitRelCount(1, 2, -1, "(:Person)-[:FRIEND]->()", 500);

            // WHEN
            DbStructureLookup lookup = collector.Lookup();

            // THEN
            assertEquals(asList(of(1, "Person"), of(2, "City")), Iterators.asList(lookup.Labels()));
            assertEquals(asList(of(1, "name"), of(2, "income")), Iterators.asList(lookup.Properties()));
            assertEquals(asList(of(1, "LIVES_IN"), of(2, "FRIEND")), Iterators.asList(lookup.RelationshipTypes()));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "Person" }, lookup.KnownUniqueIndices().next().first());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownUniqueIndices().next().other());

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(asList("City"), Iterators.asList(Iterators.map(Pair::first, lookup.KnownNodeKeyConstraints())));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownNodeKeyConstraints().next().other());

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(asList("City"), Iterators.asList(Iterators.map(Pair::first, lookup.KnownUniqueConstraints())));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownUniqueConstraints().next().other());

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(new string[] { "City" }, lookup.KnownIndices().next().first());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "income" }, lookup.KnownIndices().next().other());

            assertEquals(50, lookup.NodesAllCardinality());
            assertEquals(20, lookup.NodesWithLabelCardinality(1));
            assertEquals(30, lookup.NodesWithLabelCardinality(2));
            assertEquals(500, lookup.CardinalityByLabelsAndRelationshipType(1, 2, -1));
            assertEquals(1.0d, lookup.IndexUniqueValueSelectivity(1, 1), 0.01d);
            assertEquals(0.2d, lookup.IndexUniqueValueSelectivity(2, 2), 0.01d);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId() throws org.neo4j.internal.kernel.api.exceptions.ProcedureException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLookUpTheIndexByLabelIdAndPropertyKeyId()
        {
            IndexDescriptor index = TestIndexDescriptorFactory.forLabel(0, 0);

            when(_tokenRead.nodeLabel(anyString())).thenReturn(123);
            when(_tokenRead.propertyKey(anyString())).thenReturn(456);
            when(_schemaRead.index(anyInt(), any())).thenReturn(index);

            _procedure.resampleIndex(":Person(name)");

            verify(_schemaRead).index(123, 456);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLookUpTheCompositeIndexByLabelIdAndPropertyKeyId() throws org.neo4j.internal.kernel.api.exceptions.ProcedureException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLookUpTheCompositeIndexByLabelIdAndPropertyKeyId()
        {
            IndexDescriptor index = TestIndexDescriptorFactory.forLabel(0, 0, 1);

            when(_tokenRead.nodeLabel(anyString())).thenReturn(123);
            when(_tokenRead.propertyKey("name")).thenReturn(0);
            when(_tokenRead.propertyKey("lastName")).thenReturn(1);
            when(_schemaRead.index(123, 0, 1)).thenReturn(index);

            _procedure.resampleIndex(":Person(name, lastName)");

            verify(_schemaRead).index(123, 0, 1);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyThatThereAreExactlyOneIndexEntryPerNodeInTheIndexes(int i, org.neo4j.helpers.collection.Pair<long[],long[]> data) throws Exception
        private void VerifyThatThereAreExactlyOneIndexEntryPerNodeInTheIndexes(int i, Pair <long[], long[]> data)
        {
            Kernel kernel = Db.DependencyResolver.resolveDependency(typeof(Kernel));

            using ([email protected] tx = kernel.BeginTransaction(@implicit, AnonymousContext.read()))
            {
                int            labelAId = tx.TokenRead().nodeLabel(LabelA(i).name());
                int            keyAId   = tx.TokenRead().propertyKey(KeyA(i));
                int            labelBId = tx.TokenRead().nodeLabel(LabelB(i).name());
                int            keyBId   = tx.TokenRead().propertyKey(KeyB(i));
                IndexReference indexA   = TestIndexDescriptorFactory.forLabel(labelAId, keyAId);
                IndexReference indexB   = TestIndexDescriptorFactory.forLabel(labelBId, keyBId);

                for (int j = 0; j < NODES_PER_INDEX; j++)
                {
                    long nodeAId = data.First()[j];
                    assertEquals(1, tx.SchemaRead().nodesCountIndexed(indexA, nodeAId, keyAId, Values.of(nodeAId)));
                    long nodeBId = data.Other()[j];
                    assertEquals(1, tx.SchemaRead().nodesCountIndexed(indexB, nodeBId, keyBId, Values.of(nodeBId)));
                }
            }
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void closeMustCloseAll()
        public virtual void CloseMustCloseAll()
        {
            IndexDescriptor         index      = TestIndexDescriptorFactory.forLabel(1, 2, 3);
            BridgingIndexProgressor progressor = new BridgingIndexProgressor(null, index.Schema().PropertyIds);

            IndexProgressor[] parts = new IndexProgressor[] { mock(typeof(IndexProgressor)), mock(typeof(IndexProgressor)) };

            // Given
            foreach (IndexProgressor part in parts)
            {
                progressor.Initialize(index, part, null, IndexOrder.NONE, false);
            }

            // When
            progressor.Close();

            // Then
            foreach (IndexProgressor part in parts)
            {
                verify(part, times(1)).close();
            }
        }
Exemple #10
0
 public General(IndexProviderCompatibilityTestSuite testSuite) : base(testSuite, TestIndexDescriptorFactory.forLabel(1000, 100, 200))
 {
 }
 protected internal override ValueCreatorUtil <SpatialIndexKey, NativeIndexValue> CreateValueCreatorUtil()
 {
     return(new SpatialValueCreatorUtil(TestIndexDescriptorFactory.forLabel(42, 666).withId(0), ValueCreatorUtil.FRACTION_DUPLICATE_NON_UNIQUE));
 }