//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void showSchema(DbStructureVisitor visitor, org.neo4j.kernel.api.KernelTransaction ktx) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private void ShowSchema(DbStructureVisitor visitor, KernelTransaction ktx) { TokenNameLookup nameLookup = new SilentTokenNameLookup(ktx.TokenRead()); ShowIndices(visitor, ktx, nameLookup); ShowUniqueConstraints(visitor, ktx, nameLookup); }
//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 WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private String userMessage(org.neo4j.internal.kernel.api.exceptions.schema.ConstraintValidationException cause) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private string UserMessage(ConstraintValidationException cause) { using (Transaction tx = newTransaction()) { TokenNameLookup lookup = new SilentTokenNameLookup(tx.TokenRead()); return(cause.GetUserMessage(lookup)); } }
private ConstraintDefinition AsConstraintDefinition(ConstraintDescriptor constraint, TokenRead tokenRead) { // This was turned inside out. Previously a low-level constraint object would reference a public enum type // which made it impossible to break out the low-level component from kernel. There could be a lower level // constraint type introduced to mimic the public ConstraintType, but that would be a duplicate of it // essentially. Checking instanceof here is OKish since the objects it checks here are part of the // internal storage engine API. SilentTokenNameLookup lookup = new SilentTokenNameLookup(tokenRead); if (constraint is NodeExistenceConstraintDescriptor || constraint is NodeKeyConstraintDescriptor || constraint is UniquenessConstraintDescriptor) { SchemaDescriptor schemaDescriptor = constraint.Schema(); int[] entityTokenIds = schemaDescriptor.EntityTokenIds; Label[] labels = new Label[entityTokenIds.Length]; for (int i = 0; i < entityTokenIds.Length; i++) { labels[i] = label(lookup.LabelGetName(entityTokenIds[i])); } //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: string[] propertyKeys = Arrays.stream(schemaDescriptor.PropertyIds).mapToObj(lookup.propertyKeyGetName).toArray(string[] ::new); if (constraint is NodeExistenceConstraintDescriptor) { return(new NodePropertyExistenceConstraintDefinition(_actions, labels[0], propertyKeys)); } else if (constraint is UniquenessConstraintDescriptor) { return(new UniquenessConstraintDefinition(_actions, new IndexDefinitionImpl(_actions, null, labels, propertyKeys, true))); } else { return(new NodeKeyConstraintDefinition(_actions, new IndexDefinitionImpl(_actions, null, labels, propertyKeys, true))); } } else if (constraint is RelExistenceConstraintDescriptor) { RelationTypeSchemaDescriptor descriptor = ( RelationTypeSchemaDescriptor )constraint.Schema(); return(new RelationshipPropertyExistenceConstraintDefinition(_actions, withName(lookup.RelationshipTypeGetName(descriptor.RelTypeId)), lookup.PropertyKeyGetName(descriptor.PropertyId))); } throw new System.ArgumentException("Unknown constraint " + constraint); }
private static IList <IDictionary <string, object> > Constraints(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer) { IList <IDictionary <string, object> > constraints = new List <IDictionary <string, object> >(); SilentTokenNameLookup tokenLookup = new SilentTokenNameLookup(tokens); IEnumerator <ConstraintDescriptor> iterator = schemaRead.ConstraintsGetAll(); while (iterator.MoveNext()) { ConstraintDescriptor constraint = iterator.Current; EntityType entityType = constraint.Schema().entityType(); IDictionary <string, object> data = new Dictionary <string, object>(); data["properties"] = Map(constraint.Schema().PropertyIds, id => anonymizer.PropertyKey(tokenLookup.PropertyKeyGetName(id), id)); data["type"] = ConstraintType(constraint); int entityTokenId = constraint.Schema().EntityTokenIds[0]; switch (entityType.innerEnumValue) { case EntityType.InnerEnum.NODE: data["label"] = anonymizer.Label(tokenLookup.LabelGetName(entityTokenId), entityTokenId); constraints.Add(data); break; case EntityType.InnerEnum.RELATIONSHIP: data["relationshipType"] = anonymizer.RelationshipType(tokenLookup.RelationshipTypeGetName(entityTokenId), entityTokenId); constraints.Add(data); break; default: break; } } return(constraints); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void launchCustomIndexPopulation(java.util.Map<String,int> labelNameIdMap, int propertyId, Runnable customAction) throws Exception private void LaunchCustomIndexPopulation(IDictionary <string, int> labelNameIdMap, int propertyId, ThreadStart customAction) { NeoStores neoStores = NeoStores; LabelScanStore labelScanStore = LabelScanStore; ThreadToStatementContextBridge transactionStatementContextBridge = TransactionStatementContextBridge; using (Transaction transaction = EmbeddedDatabase.beginTx(), KernelTransaction ktx = transactionStatementContextBridge.GetKernelTransactionBoundToThisThread(true)) { DynamicIndexStoreView storeView = DynamicIndexStoreViewWrapper(customAction, neoStores, labelScanStore); IndexProviderMap providerMap = IndexProviderMap; JobScheduler scheduler = JobScheduler; TokenNameLookup tokenNameLookup = new SilentTokenNameLookup(ktx.TokenRead()); NullLogProvider nullLogProvider = NullLogProvider.Instance; _indexService = IndexingServiceFactory.createIndexingService(Config.defaults(), scheduler, providerMap, storeView, tokenNameLookup, GetIndexRules(neoStores), nullLogProvider, nullLogProvider, IndexingService.NO_MONITOR, SchemaState, false); _indexService.start(); _rules = CreateIndexRules(labelNameIdMap, propertyId); _indexService.createIndexes(_rules); transaction.Success(); } }
public virtual GraphResult BuildSchemaGraph() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,VirtualNodeHack> nodes = new java.util.HashMap<>(); IDictionary <string, VirtualNodeHack> nodes = new Dictionary <string, VirtualNodeHack>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,java.util.Set<VirtualRelationshipHack>> relationships = new java.util.HashMap<>(); IDictionary <string, ISet <VirtualRelationshipHack> > relationships = new Dictionary <string, ISet <VirtualRelationshipHack> >(); using (Statement statement = _kernelTransaction.acquireStatement()) { Read dataRead = _kernelTransaction.dataRead(); TokenRead tokenRead = _kernelTransaction.tokenRead(); TokenNameLookup tokenNameLookup = new SilentTokenNameLookup(tokenRead); SchemaRead schemaRead = _kernelTransaction.schemaRead(); using (Transaction transaction = _graphDatabaseAPI.beginTx()) { // add all labelsInDatabase using (ResourceIterator <Label> labelsInDatabase = _graphDatabaseAPI.AllLabelsInUse.GetEnumerator()) { while (labelsInDatabase.MoveNext()) { Label label = labelsInDatabase.Current; int labelId = tokenRead.NodeLabel(label.Name()); IDictionary <string, object> properties = new Dictionary <string, object>(); IEnumerator <IndexReference> indexReferences = schemaRead.IndexesGetForLabel(labelId); List <string> indexes = new List <string>(); while (indexReferences.MoveNext()) { IndexReference index = indexReferences.Current; if (!index.Unique) { string[] propertyNames = PropertyNameUtils.getPropertyKeys(tokenNameLookup, index.Properties()); indexes.Add(string.join(",", propertyNames)); } } properties["indexes"] = indexes; IEnumerator <ConstraintDescriptor> nodePropertyConstraintIterator = schemaRead.ConstraintsGetForLabel(labelId); List <string> constraints = new List <string>(); while (nodePropertyConstraintIterator.MoveNext()) { ConstraintDescriptor constraint = nodePropertyConstraintIterator.Current; constraints.Add(constraint.PrettyPrint(tokenNameLookup)); } properties["constraints"] = constraints; GetOrCreateLabel(label.Name(), properties, nodes); } } //add all relationships using (ResourceIterator <RelationshipType> relationshipTypeIterator = _graphDatabaseAPI.AllRelationshipTypesInUse.GetEnumerator()) { while (relationshipTypeIterator.MoveNext()) { RelationshipType relationshipType = relationshipTypeIterator.Current; string relationshipTypeGetName = relationshipType.Name(); int relId = tokenRead.RelationshipType(relationshipTypeGetName); using (ResourceIterator <Label> labelsInUse = _graphDatabaseAPI.AllLabelsInUse.GetEnumerator()) { IList <VirtualNodeHack> startNodes = new LinkedList <VirtualNodeHack>(); IList <VirtualNodeHack> endNodes = new LinkedList <VirtualNodeHack>(); while (labelsInUse.MoveNext()) { Label labelToken = labelsInUse.Current; string labelName = labelToken.Name(); IDictionary <string, object> properties = new Dictionary <string, object>(); VirtualNodeHack node = GetOrCreateLabel(labelName, properties, nodes); int labelId = tokenRead.NodeLabel(labelName); if (dataRead.CountsForRelationship(labelId, relId, [email protected]_Fields.ANY_LABEL) > 0) { startNodes.Add(node); } if (dataRead.CountsForRelationship([email protected]_Fields.ANY_LABEL, relId, labelId) > 0) { endNodes.Add(node); } } foreach (VirtualNodeHack startNode in startNodes) { foreach (VirtualNodeHack endNode in endNodes) { AddRelationship(startNode, endNode, relationshipTypeGetName, relationships); } } } } } transaction.Success(); return(GetGraphResult(nodes, relationships)); } } }