Exemple #1
0
        /// <summary>
        /// Get a <seealso cref="BatchInserter"/> given a store directory.
        /// </summary>
        /// <param name="databaseDirectory"> directory where particular neo4j database is located </param>
        /// <returns> a new <seealso cref="BatchInserter"/> </returns>
        /// <exception cref="IOException"> if there is an IO error </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static BatchInserter inserter(java.io.File databaseDirectory) throws java.io.IOException
        public static BatchInserter Inserter(File databaseDirectory)
        {
            DefaultFileSystemAbstraction fileSystem = CreateFileSystem();
            BatchInserter batchInserter             = Inserter(databaseDirectory, fileSystem, stringMap());

            return(new FileSystemClosingBatchInserter(batchInserter, ( IndexConfigStoreProvider )batchInserter, fileSystem));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenPopulatingWithNonUniquePoints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowWhenPopulatingWithNonUniquePoints()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);
            PointValue    point    = Values.pointValue(CoordinateReferenceSystem.WGS84, 0.0, 0.0);

            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.CreateDeferredConstraint(TestLabels.LABEL_ONE).assertPropertyIsUnique("prop").create();
            inserter.Shutdown();

            GraphDatabaseService db = GraphDatabaseService(config);

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    IEnumerator <IndexDefinition> indexes = Db.schema().Indexes.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(indexes.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    IndexDefinition index = indexes.next();
                    Org.Neo4j.Graphdb.schema.Schema_IndexState indexState = Db.schema().getIndexState(index);
                    assertEquals(Org.Neo4j.Graphdb.schema.Schema_IndexState.Failed, indexState);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertFalse(indexes.hasNext());
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #3
0
        private static void CreateEndCloseIndexProvider(BatchInserter inserter)
        {
            LuceneBatchInserterIndexProviderNewImpl provider = new LuceneBatchInserterIndexProviderNewImpl(inserter);

            provider.Shutdown();
            inserter.Shutdown();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateIndexWithUniquePointsThatCollideOnSpaceFillingCurve() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateIndexWithUniquePointsThatCollideOnSpaceFillingCurve()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);
            Pair <PointValue, PointValue> collidingPoints = SpatialIndexValueTestUtil.pointsWithSameValueOnSpaceFillingCurve(config);

            inserter.createNode(MapUtil.map("prop", collidingPoints.First()), TestLabels.LABEL_ONE);
            inserter.createNode(MapUtil.map("prop", collidingPoints.Other()), TestLabels.LABEL_ONE);
            inserter.CreateDeferredConstraint(TestLabels.LABEL_ONE).assertPropertyIsUnique("prop").create();
            inserter.Shutdown();

            GraphDatabaseService db = GraphDatabaseService(config);

            try
            {
                AwaitIndexesOnline(db);
                using (Transaction tx = Db.beginTx())
                {
                    AssertSingleCorrectHit(db, collidingPoints.First());
                    AssertSingleCorrectHit(db, collidingPoints.Other());
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void batchInserterShouldUseConfiguredIndexProvider() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BatchInserterShouldUseConfiguredIndexProvider()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);

            inserter.CreateDeferredSchemaIndex(TestLabels.LABEL_ONE).on("key").create();
            inserter.Shutdown();
            GraphDatabaseService db = GraphDatabaseService(config);

            AwaitIndexesOnline(db);
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    DependencyResolver             dependencyResolver             = (( GraphDatabaseAPI )db).DependencyResolver;
                    ThreadToStatementContextBridge threadToStatementContextBridge = dependencyResolver.ResolveDependency(typeof(ThreadToStatementContextBridge));
                    KernelTransaction kernelTransaction = threadToStatementContextBridge.GetKernelTransactionBoundToThisThread(true);
                    TokenRead         tokenRead         = kernelTransaction.TokenRead();
                    SchemaRead        schemaRead        = kernelTransaction.SchemaRead();
                    int            labelId    = tokenRead.NodeLabel(TestLabels.LABEL_ONE.name());
                    int            propertyId = tokenRead.PropertyKey("key");
                    IndexReference index      = schemaRead.Index(labelId, propertyId);
                    assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderKey()));
                    assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderVersion()));
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void lazyLoadWithinWriteTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LazyLoadWithinWriteTransaction()
        {
            // Given
            FileSystemAbstraction fileSystem = Fs.get();
            BatchInserter         inserter   = BatchInserters.inserter(TestDirectory.databaseDir(), fileSystem);
            int  count  = 3000;
            long nodeId = inserter.CreateNode(MapWithManyProperties(count));

            inserter.Shutdown();

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(fileSystem).newImpermanentDatabase(TestDirectory.databaseDir());

            // When
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode();
                    Node node = Db.getNodeById(nodeId);

                    // Then
                    assertEquals(count, Iterables.count(node.PropertyKeys));
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static BatchInserter inserter(java.io.File databaseDirectory, java.util.Map<String,String> config) throws java.io.IOException
        public static BatchInserter Inserter(File databaseDirectory, IDictionary <string, string> config)
        {
            DefaultFileSystemAbstraction fileSystem = CreateFileSystem();
            BatchInserter inserter = inserter(databaseDirectory, fileSystem, config, LoadKernelExtension());

            return(new FileSystemClosingBatchInserter(inserter, ( IndexConfigStoreProvider )inserter, fileSystem));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHonorsPassedInParams() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestHonorsPassedInParams()
        {
            BatchInserter inserter  = BatchInserters.inserter(_testDirectory.databaseDir(), _fileSystemRule.get(), stringMap(GraphDatabaseSettings.pagecache_memory.name(), "280K"));
            NeoStores     neoStores = ReflectionUtil.getPrivateField(inserter, "neoStores", typeof(NeoStores));
            PageCache     pageCache = ReflectionUtil.getPrivateField(neoStores, "pageCache", typeof(PageCache));

            inserter.Shutdown();
            long mappedMemoryTotalSize = MuninnPageCache.memoryRequiredForPages(pageCache.MaxCachedPages());

            assertThat("memory mapped config is active", mappedMemoryTotalSize, @is(allOf(greaterThan(kibiBytes(270)), lessThan(kibiBytes(290)))));
        }
Exemple #9
0
 public LuceneBatchInserterIndexProviderNewImpl(BatchInserter inserter)
 {
     this._inserter           = inserter;
     this.IndexStore          = (( IndexConfigStoreProvider )inserter).IndexStore;
     this._relationshipLookup = id =>
     {
         // TODO too may objects allocated here
         BatchRelationship rel = inserter.GetRelationshipById(id);
         return(new EntityId_RelationshipData(id, rel.StartNode, rel.EndNode));
     };
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreatesStoreLockFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestCreatesStoreLockFile()
        {
            // Given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            // When
            BatchInserter inserter = BatchInserters.inserter(databaseLayout.DatabaseDirectory(), _fileSystemRule.get());

            // Then
            assertThat(databaseLayout.StoreLayout.storeLockFile().exists(), equalTo(true));
            inserter.Shutdown();
        }
Exemple #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void closeFileSystemOnShutdown() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CloseFileSystemOnShutdown()
        {
            BatchInserter                  batchInserter       = mock(typeof(BatchInserter));
            IndexConfigStoreProvider       configStoreProvider = mock(typeof(IndexConfigStoreProvider));
            FileSystemAbstraction          fileSystem          = mock(typeof(FileSystemAbstraction));
            FileSystemClosingBatchInserter inserter            = new FileSystemClosingBatchInserter(batchInserter, configStoreProvider, fileSystem);

            inserter.Shutdown();

            InOrder verificationOrder = inOrder(batchInserter, fileSystem);

            verificationOrder.verify(batchInserter).shutdown();
            verificationOrder.verify(fileSystem).close();
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInsertDifferentTypesOfThings() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInsertDifferentTypesOfThings()
        {
            // GIVEN
            BatchInserter inserter = BatchInserters.Inserter(Directory.databaseDir(), FileSystemRule.get(), stringMap(GraphDatabaseSettings.log_queries.name(), "true", GraphDatabaseSettings.record_format.name(), RecordFormat, GraphDatabaseSettings.log_queries_filename.name(), Directory.file("query.log").AbsolutePath));
            long          node1Id;
            long          node2Id;
            long          relationshipId;

            try
            {
                // WHEN
                node1Id = inserter.createNode(SomeProperties(1), Enum.GetValues(typeof(Labels)));
                node2Id = node1Id + 10;
                inserter.createNode(node2Id, SomeProperties(2), Enum.GetValues(typeof(Labels)));
                relationshipId = inserter.CreateRelationship(node1Id, node2Id, MyRelTypes.TEST, SomeProperties(3));
                inserter.CreateDeferredSchemaIndex(Labels.One).on("key").create();
                inserter.CreateDeferredConstraint(Labels.Two).assertPropertyIsUnique("key").create();
            }
            finally
            {
                inserter.Shutdown();
            }

            // THEN
            GraphDatabaseService db = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Directory.databaseDir()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Node node1 = Db.getNodeById(node1Id);
                    Node node2 = Db.getNodeById(node2Id);
                    assertEquals(SomeProperties(1), node1.AllProperties);
                    assertEquals(SomeProperties(2), node2.AllProperties);
                    assertEquals(relationshipId, single(node1.Relationships).Id);
                    assertEquals(relationshipId, single(node2.Relationships).Id);
                    assertEquals(SomeProperties(3), single(node1.Relationships).AllProperties);
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void explicitIndexPopulationWithBunchOfFields()
        internal virtual void ExplicitIndexPopulationWithBunchOfFields()
        {
            assertTimeout(ofMillis(TEST_TIMEOUT), () =>
            {
                BatchInserter batchNode = BatchInserters.inserter(_directory.databaseDir());
                LuceneBatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(batchNode);
                try
                {
                    BatchInserterIndex batchIndex = provider.nodeIndex("node_auto_index", stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"));

                    IDictionary <string, object> properties = IntStream.range(0, 2000).mapToObj(i => Pair.of(Convert.ToString(i), randomAlphabetic(200))).collect(toMap(Pair.first, Pair.other));

                    long node = batchNode.createNode(properties, Label.label("NODE"));
                    batchIndex.add(node, properties);
                }
                finally
                {
                    provider.shutdown();
                    batchNode.shutdown();
                }
            });
        }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void insertIntoExistingDatabase() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void InsertIntoExistingDatabase()
        {
            File storeDir = Directory.databaseDir();

            GraphDatabaseService db = NewDb(storeDir, RecordFormat);

            try
            {
                CreateThreeNodes(db);
            }
            finally
            {
                Db.shutdown();
            }

            BatchInserter inserter = BatchInserters.Inserter(Directory.databaseDir(), FileSystemRule.get());

            try
            {
                long start = inserter.createNode(SomeProperties(5), Labels.One);
                long end   = inserter.createNode(SomeProperties(5), Labels.One);
                inserter.CreateRelationship(start, end, MyRelTypes.TEST, SomeProperties(5));
            }
            finally
            {
                inserter.Shutdown();
            }

            db = NewDb(storeDir, RecordFormat);
            try
            {
                VerifyNodeCount(db, 4);
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #15
0
 private static void VerifyInserterFileSystemClose(BatchInserter inserter)
 {
     assertThat("Expect specific implementation that will do required cleanups.", inserter, @is(instanceOf(typeof(FileSystemClosingBatchInserter))));
     inserter.Shutdown();
 }
Exemple #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldStartBatchInserterWithRealIndexProvider() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldStartBatchInserterWithRealIndexProvider()
        {
            BatchInserter inserter = inserter(_testDirectory.databaseDir(), Config, KernelExtensions);

            inserter.Shutdown();
        }
Exemple #17
0
 public LuceneBatchInserterIndexProvider(BatchInserter inserter)
 {
     _provider = new LuceneBatchInserterIndexProviderNewImpl(inserter);
 }
Exemple #18
0
 public void FlushBatch()
 => BatchInserter?.Flush();
Exemple #19
0
 private static void VerifyProvidedFileSystemOpenAfterShutdown(BatchInserter inserter, EphemeralFileSystemAbstraction fileSystemAbstraction)
 {
     inserter.Shutdown();
     assertFalse(fileSystemAbstraction.Closed);
 }
Exemple #20
0
 public FileSystemClosingBatchInserter(BatchInserter @delegate, IndexConfigStoreProvider configStoreProvider, FileSystemAbstraction fileSystem)
 {
     this.@delegate            = @delegate;
     this._configStoreProvider = configStoreProvider;
     this._fileSystem          = fileSystem;
 }