private static IList <IDictionary <string, object> > NodeCounts(TokenRead tokens, Read read, Anonymizer anonymizer) { IList <IDictionary <string, object> > nodeCounts = new List <IDictionary <string, object> >(); IDictionary <string, object> nodeCount = new Dictionary <string, object>(); nodeCount["count"] = read.CountsForNodeWithoutTxState(-1); nodeCounts.Add(nodeCount); tokens.LabelsGetAllTokens().forEachRemaining(t => { long count = read.CountsForNodeWithoutTxState(t.id()); IDictionary <string, object> labelCount = new Dictionary <string, object>(); labelCount.put("label", anonymizer.Label(t.name(), t.id())); labelCount.put("count", count); nodeCounts.Add(labelCount); }); return(nodeCounts); }
private static IList <IDictionary <string, object> > RelationshipCounts(TokenRead tokens, Read read, Anonymizer anonymizer) { IList <IDictionary <string, object> > relationshipCounts = new List <IDictionary <string, object> >(); IDictionary <string, object> relationshipCount = new Dictionary <string, object>(); relationshipCount["count"] = read.CountsForRelationshipWithoutTxState(-1, -1, -1); relationshipCounts.Add(relationshipCount); IList <NamedToken> labels = Iterators.asList(tokens.LabelsGetAllTokens()); tokens.RelationshipTypesGetAllTokens().forEachRemaining(t => { long count = read.CountsForRelationshipWithoutTxState(-1, t.id(), -1); IDictionary <string, object> relationshipTypeCount = new Dictionary <string, object>(); relationshipTypeCount.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id())); relationshipTypeCount.put("count", count); relationshipCounts.Add(relationshipTypeCount); foreach (NamedToken label in labels) { long startCount = read.CountsForRelationshipWithoutTxState(label.id(), t.id(), -1); if (startCount > 0) { IDictionary <string, object> x = new Dictionary <string, object>(); x.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id())); x.put("startLabel", anonymizer.Label(label.name(), label.id())); x.put("count", startCount); relationshipCounts.Add(x); } long endCount = read.CountsForRelationshipWithoutTxState(-1, t.id(), label.id()); if (endCount > 0) { IDictionary <string, object> x = new Dictionary <string, object>(); x.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id())); x.put("endLabel", anonymizer.Label(label.name(), label.id())); x.put("count", endCount); relationshipCounts.Add(x); } } }); return(relationshipCounts); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static java.util.stream.Stream<RetrieveResult> retrieve(org.neo4j.internal.kernel.api.Kernel kernel) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException internal static Stream <RetrieveResult> Retrieve(Kernel kernel) { using (Transaction tx = kernel.BeginTransaction([email protected]_Type.Explicit, LoginContext.AUTH_DISABLED)) { TokenRead tokens = tx.TokenRead(); IList <string> labels = new List <string>(tokens.LabelCount()); tokens.LabelsGetAllTokens().forEachRemaining(t => labels.Add(t.name())); IList <string> relationshipTypes = new List <string>(tokens.RelationshipTypeCount()); tokens.RelationshipTypesGetAllTokens().forEachRemaining(t => relationshipTypes.Add(t.name())); IList <string> propertyKeys = new List <string>(tokens.PropertyKeyCount()); tokens.PropertyKeyGetAllTokens().forEachRemaining(t => propertyKeys.Add(t.name())); IDictionary <string, object> data = new Dictionary <string, object>(); data["labels"] = labels; data["relationshipTypes"] = relationshipTypes; data["propertyKeys"] = propertyKeys; return(Stream.of(new RetrieveResult(Sections.TOKENS, data))); } }
internal override IEnumerator <NamedToken> tokens(TokenRead read) { return(read.LabelsGetAllTokens()); }