//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB() public virtual void ShouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB() { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.newGraphDatabase(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); using (Transaction tx = Db.beginTx()) { Db.createNode(Label.label("A")); Db.createNode(Label.label("C")); Node node = Db.createNode(Label.label("D")); Db.createNode(); node.Delete(); tx.Success(); } long lastCommittedTransactionId = GetLastTxId(db); Db.shutdown(); RebuildCounts(lastCommittedTransactionId); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker()); assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1, store.TxId()); assertEquals(3, store.TotalEntriesStored()); assertEquals(3, Get(store, nodeKey(-1))); assertEquals(1, Get(store, nodeKey(0))); assertEquals(1, Get(store, nodeKey(1))); assertEquals(0, Get(store, nodeKey(2))); assertEquals(0, Get(store, nodeKey(3))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenClosingTheDatabase() public virtual void ShouldRotateCountsStoreWhenClosingTheDatabase() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); using (Transaction tx = Db.beginTx()) { Db.createNode(_a); tx.Success(); } // WHEN Db.shutdown(); // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertTrue(_fs.fileExists(BetaStoreFile())); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); // a transaction for creating the label and a transaction for the node assertEquals(BASE_TX_ID + 1 + 1, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); // one for all nodes and one for the created "A" label assertEquals(1 + 1, store.TotalEntriesStored()); assertEquals(1 + 1, AllRecords(store).Count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase() public virtual void ShouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); // WHEN Db.shutdown(); // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertFalse(_fs.fileExists(BetaStoreFile())); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); assertEquals(BASE_TX_ID, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); assertEquals(0, store.TotalEntriesStored()); assertEquals(0, AllRecords(store).Count); } using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); assertEquals(BASE_TX_ID, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); assertEquals(0, store.TotalEntriesStored()); assertEquals(0, AllRecords(store).Count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenRotatingLog() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRotateCountsStoreWhenRotatingLog() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); // WHEN doing a transaction (actually two, the label-mini-tx also counts) using (Transaction tx = Db.beginTx()) { Db.createNode(_b); tx.Success(); } // and rotating the log (which implies flushing) CheckPoint(db); // and creating another node after it using (Transaction tx = Db.beginTx()) { Db.createNode(_c); tx.Success(); } // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertTrue(_fs.fileExists(BetaStoreFile())); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.pagecache.PageCache pageCache = db.getDependencyResolver().resolveDependency(org.neo4j.io.pagecache.PageCache.class); PageCache pageCache = Db.DependencyResolver.resolveDependency(typeof(PageCache)); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(pageCache)); // NOTE since the rotation happens before the second transaction is committed we do not see those changes // in the stats // a transaction for creating the label and a transaction for the node assertEquals(BASE_TX_ID + 1 + 1, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); // one for all nodes and one for the created "B" label assertEquals(1 + 1, store.TotalEntriesStored()); assertEquals(1 + 1, AllRecords(store).Count); } // on the other hand the tracker should read the correct value by merging data on disk and data in memory //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CountsTracker tracker = db.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).testAccessNeoStores().getCounts(); CountsTracker tracker = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().Counts; assertEquals(1 + 1, tracker.NodeCount(-1, newDoubleLongRegister()).readSecond()); int labelId; using (Transaction tx = Db.beginTx()) { KernelTransaction transaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); labelId = transaction.TokenRead().nodeLabel(_c.name()); } assertEquals(1, tracker.NodeCount(labelId, newDoubleLongRegister()).readSecond()); Db.shutdown(); }
private void CheckEmptyCountStore() { using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker()); assertEquals(BASE_TX_ID, store.TxId()); assertEquals(0, store.TotalEntriesStored()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateACountStoreWhenDBContainsDenseNodes() public virtual void ShouldCreateACountStoreWhenDBContainsDenseNodes() { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.setConfig(org.neo4j.graphdb.factory.GraphDatabaseSettings.dense_node_threshold, "2").newGraphDatabase(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.setConfig(GraphDatabaseSettings.dense_node_threshold, "2").newGraphDatabase(); using (Transaction tx = Db.beginTx()) { Node nodeA = Db.createNode(Label.label("A")); Node nodeC = Db.createNode(Label.label("C")); Node nodeD = Db.createNode(Label.label("D")); nodeA.CreateRelationshipTo(nodeA, RelationshipType.withName("TYPE1")); nodeA.CreateRelationshipTo(nodeC, RelationshipType.withName("TYPE2")); nodeA.CreateRelationshipTo(nodeD, RelationshipType.withName("TYPE3")); nodeD.CreateRelationshipTo(nodeC, RelationshipType.withName("TYPE4")); tx.Success(); } long lastCommittedTransactionId = GetLastTxId(db); Db.shutdown(); RebuildCounts(lastCommittedTransactionId); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker()); assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1, store.TxId()); assertEquals(22, store.TotalEntriesStored()); assertEquals(3, Get(store, nodeKey(-1))); assertEquals(1, Get(store, nodeKey(0))); assertEquals(1, Get(store, nodeKey(1))); assertEquals(1, Get(store, nodeKey(2))); assertEquals(0, Get(store, nodeKey(3))); assertEquals(4, Get(store, relationshipKey(-1, -1, -1))); assertEquals(1, Get(store, relationshipKey(-1, 0, -1))); assertEquals(1, Get(store, relationshipKey(-1, 1, -1))); assertEquals(1, Get(store, relationshipKey(-1, 2, -1))); assertEquals(1, Get(store, relationshipKey(-1, 3, -1))); assertEquals(0, Get(store, relationshipKey(-1, 4, -1))); assertEquals(1, Get(store, relationshipKey(-1, 1, 1))); assertEquals(2, Get(store, relationshipKey(-1, -1, 1))); assertEquals(3, Get(store, relationshipKey(0, -1, -1))); } }