//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static java.util.List<java.util.Map<String,Object>> indexes(org.neo4j.internal.kernel.api.TokenRead tokens, org.neo4j.internal.kernel.api.SchemaRead schemaRead, Anonymizer anonymizer) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private static IList <IDictionary <string, object> > Indexes(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer) { IList <IDictionary <string, object> > indexes = new List <IDictionary <string, object> >(); SilentTokenNameLookup tokenLookup = new SilentTokenNameLookup(tokens); IEnumerator <IndexReference> iterator = schemaRead.IndexesGetAll(); while (iterator.MoveNext()) { IndexReference index = iterator.Current; IDictionary <string, object> data = new Dictionary <string, object>(); data["labels"] = Map(index.Schema().EntityTokenIds, id => anonymizer.Label(tokenLookup.LabelGetName(id), id)); data["properties"] = Map(index.Schema().PropertyIds, id => anonymizer.PropertyKey(tokenLookup.PropertyKeyGetName(id), id)); Org.Neo4j.Register.Register_DoubleLongRegister register = Registers.newDoubleLongRegister(); schemaRead.IndexUpdatesAndSize(index, register); data["totalSize"] = register.ReadSecond(); data["updatesSinceEstimation"] = register.ReadFirst(); schemaRead.IndexSample(index, register); data["estimatedUniqueSize"] = register.ReadFirst(); indexes.Add(data); } return(indexes); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSampleUniqueIndex() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSampleUniqueIndex() { GraphDatabaseService db = null; long deletedNodes = 0; try { // Given db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(TestDirectory.storeDir()); using (Transaction tx = Db.beginTx()) { Db.schema().constraintFor(_label).assertPropertyIsUnique(_property).create(); tx.Success(); } using (Transaction tx = Db.beginTx()) { for (int i = 0; i < _nodes; i++) { Db.createNode(_label).setProperty(_property, "" + i); tx.Success(); } } using (Transaction tx = Db.beginTx()) { for (int i = 0; i < _nodes; i++) { if (i % 10 == 0) { deletedNodes++; Db.findNode(_label, _property, "" + i).delete(); tx.Success(); } } } } finally { if (db != null) { Db.shutdown(); } } // When TriggerIndexResamplingOnNextStartup(); // Then Register_DoubleLongRegister indexSampleRegister = FetchIndexSamplingValues(db); assertEquals(_nodes - deletedNodes, indexSampleRegister.ReadFirst()); assertEquals(_nodes - deletedNodes, indexSampleRegister.ReadSecond()); Register_DoubleLongRegister indexSizeRegister = FetchIndexSizeValues(db); assertEquals(0, indexSizeRegister.ReadFirst()); assertEquals(_nodes - deletedNodes, indexSizeRegister.ReadSecond()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSampleNotUniqueIndex() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSampleNotUniqueIndex() { GraphDatabaseService db = null; long deletedNodes = 0; try { // Given db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(TestDirectory.storeDir()); IndexDefinition indexDefinition; using (Transaction tx = Db.beginTx()) { indexDefinition = Db.schema().indexFor(_label).on(_property).create(); tx.Success(); } using (Transaction tx = Db.beginTx()) { Db.schema().awaitIndexOnline(indexDefinition, 10, TimeUnit.SECONDS); tx.Success(); } using (Transaction tx = Db.beginTx()) { for (int i = 0; i < _nodes; i++) { Db.createNode(_label).setProperty(_property, _names[i % _names.Length]); tx.Success(); } } using (Transaction tx = Db.beginTx()) { for (int i = 0; i < (_nodes / 10); i++) { using (ResourceIterator <Node> nodes = Db.findNodes(_label, _property, _names[i % _names.Length])) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: nodes.next().delete(); } deletedNodes++; tx.Success(); } } } finally { if (db != null) { Db.shutdown(); } } // When TriggerIndexResamplingOnNextStartup(); // Then // lucene will consider also the delete nodes, native won't Register_DoubleLongRegister register = FetchIndexSamplingValues(db); assertEquals(_names.Length, register.ReadFirst()); assertThat(register.ReadSecond(), allOf(greaterThanOrEqualTo(nodes - deletedNodes), lessThanOrEqualTo(nodes))); // but regardless, the deleted nodes should not be considered in the index size value Register_DoubleLongRegister indexSizeRegister = FetchIndexSizeValues(db); assertEquals(0, indexSizeRegister.ReadFirst()); assertEquals(nodes - deletedNodes, indexSizeRegister.ReadSecond()); }
private static void AssertDoubleLongEquals(int expectedFirst, int expectedSecond, Register_DoubleLongRegister actualValues) { string msg = string.Format("Expected ({0:D},{1:D}) but was ({2:D},{3:D})", expectedFirst, expectedSecond, actualValues.ReadFirst(), actualValues.ReadSecond()); assertTrue(msg, actualValues.HasValues(expectedFirst, expectedSecond)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static long readUpdates(org.neo4j.internal.kernel.api.IndexReference index, org.neo4j.internal.kernel.api.SchemaRead schemaRead, org.neo4j.register.Register_DoubleLongRegister register) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private static long ReadUpdates(IndexReference index, SchemaRead schemaRead, Org.Neo4j.Register.Register_DoubleLongRegister register) { schemaRead.IndexUpdatesAndSize(index, register); return(register.ReadFirst()); }
private void AssertEqualRegisters(string message, Register_DoubleLongRegister expected, Register_DoubleLongRegister actual) { assertEquals(message + " (first part of register)", expected.ReadFirst(), actual.ReadFirst()); assertEquals(message + " (second part of register)", expected.ReadSecond(), actual.ReadSecond()); }
public void visitIndexSample(long indexId, long unique, long size) { Org.Neo4j.Register.Register_DoubleLongRegister output = _tracker.indexSample(indexId, newDoubleLongRegister()); assertEquals("Should be able to read visited state.", output.ReadFirst(), unique); assertEquals("Should be able to read visited state.", output.ReadSecond(), size); }
public void visitIndexStatistics(long indexId, long updates, long size) { Org.Neo4j.Register.Register_DoubleLongRegister output = _tracker.indexUpdatesAndSize(indexId, newDoubleLongRegister()); assertEquals("Should be able to read visited state.", output.ReadFirst(), updates); assertEquals("Should be able to read visited state.", output.ReadSecond(), size); }