//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); }
private SchemaRead SchemaWithIndexes(params IndexReference[] indexes) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.internal.kernel.api.SchemaRead schemaRead = mock(org.neo4j.internal.kernel.api.SchemaRead.class); SchemaRead schemaRead = mock(typeof(SchemaRead)); when(schemaRead.IndexesGetAll()).thenReturn(Iterators.iterator(indexes)); return(schemaRead); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void showIndices(DbStructureVisitor visitor, org.neo4j.kernel.api.KernelTransaction ktx, org.neo4j.internal.kernel.api.TokenNameLookup nameLookup) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private void ShowIndices(DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup) { SchemaRead schemaRead = ktx.SchemaRead(); foreach (IndexReference reference in loop(sortByType(schemaRead.IndexesGetAll()))) { string userDescription = reference.Schema().userDescription(nameLookup); double uniqueValuesPercentage = schemaRead.IndexUniqueValuesSelectivity(reference); long size = schemaRead.IndexSize(reference); visitor.VisitIndex(( IndexDescriptor )reference, userDescription, uniqueValuesPercentage, size); } }
/// <summary> /// For each index, await a resampling event unless it has zero pending updates. /// </summary> /// <param name="schemaRead"> backing schema read </param> /// <param name="timeout"> timeout in seconds. If this limit is passed, a TimeoutException is thrown. </param> /// <exception cref="TimeoutException"> if all indexes are not resampled within the timeout. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void awaitResampling(org.neo4j.internal.kernel.api.SchemaRead schemaRead, long timeout) throws java.util.concurrent.TimeoutException public static void AwaitResampling(SchemaRead schemaRead, long timeout) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Iterator<org.neo4j.internal.kernel.api.IndexReference> indexes = schemaRead.indexesGetAll(); IEnumerator <IndexReference> indexes = schemaRead.IndexesGetAll(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.register.Register_DoubleLongRegister register = org.neo4j.register.Registers.newDoubleLongRegister(); Org.Neo4j.Register.Register_DoubleLongRegister register = Registers.newDoubleLongRegister(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long t0 = System.currentTimeMillis(); long t0 = DateTimeHelper.CurrentUnixTimeMillis(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long timeoutMillis = 1000 * timeout; long timeoutMillis = 1000 * timeout; while (indexes.MoveNext()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.internal.kernel.api.IndexReference index = indexes.Current; IndexReference index = indexes.Current; try { long readUpdates = readUpdates(index, schemaRead, register); long updateCount = readUpdates; bool hasTimedOut = false; while (updateCount > 0 && updateCount <= readUpdates && !hasTimedOut) { Thread.Sleep(10); hasTimedOut = DateTimeHelper.CurrentUnixTimeMillis() - t0 >= timeoutMillis; updateCount = Math.Max(updateCount, readUpdates); readUpdates = readUpdates(index, schemaRead, register); } if (hasTimedOut) { throw new TimeoutException(string.Format("Indexes were not resampled within {0} {1}", timeout, TimeUnit.SECONDS)); } } catch (InterruptedException e) { Thread.CurrentThread.Interrupt(); throw new Exception(e); } catch (IndexNotFoundKernelException e) { throw new ConcurrentModificationException("Index was dropped while awaiting resampling", e); } } }
public override IEnumerable <IndexDefinition> GetIndexes() { KernelTransaction transaction = _transactionSupplier.get(); SchemaRead schemaRead = transaction.SchemaRead(); using (Statement ignore = transaction.AcquireStatement()) { IList <IndexDefinition> definitions = new List <IndexDefinition>(); IEnumerator <IndexReference> indexes = schemaRead.IndexesGetAll(); AddDefinitions(definitions, transaction.TokenRead(), IndexReference.sortByType(indexes)); return(definitions); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldListAll() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListAll() { // given SchemaWrite schemaWrite = SchemaWriteInNewTransaction(); IndexReference index1 = schemaWrite.IndexCreate(_descriptor); IndexReference index2 = (( IndexBackedConstraintDescriptor )schemaWrite.UniquePropertyConstraintCreate(_descriptor2)).ownedIndexDescriptor(); Commit(); // then/when SchemaRead schemaRead = NewTransaction().schemaRead(); IList <IndexReference> indexes = Iterators.asList(schemaRead.IndexesGetAll()); assertThat(indexes, containsInAnyOrder(index1, index2)); Commit(); }
private static IEnumerator <IndexReference> GetAllIndexes(SchemaRead schemaRead) { return(schemaRead.IndexesGetAll()); }