apoc.meta.Tables4LabelsProfile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apoc-common Show documentation
Show all versions of apoc-common Show documentation
Data types package for Neo4j Procedures
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package apoc.meta;
import apoc.meta.tablesforlabels.OrderedLabels;
import apoc.meta.tablesforlabels.PropertyContainerProfile;
import apoc.meta.tablesforlabels.PropertyTracker;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.neo4j.graphdb.*;
public class Tables4LabelsProfile {
Map labelMap;
Map relMap;
Map obsByNode;
Map obsByRelType;
/**
* DAO class that the stored procedure returns
*/
public class NodeTypePropertiesEntry {
public String nodeType;
public List nodeLabels;
public String propertyName;
public List propertyTypes;
public boolean mandatory;
public long propertyObservations;
public long totalObservations;
public NodeTypePropertiesEntry(
String nodeType,
List nodeLabels,
String propertyName,
List propertyTypes,
boolean mandatory,
long propertyObservations,
long totalObservations) {
this.nodeType = nodeType;
this.nodeLabels = nodeLabels;
this.propertyName = propertyName;
this.propertyTypes = propertyTypes;
this.mandatory = mandatory;
this.propertyObservations = propertyObservations;
this.totalObservations = totalObservations;
}
}
public class RelTypePropertiesEntry {
public String relType;
public List sourceNodeLabels;
public List targetNodeLabels;
public String propertyName;
public List propertyTypes;
public boolean mandatory;
public long propertyObservations;
public long totalObservations;
public RelTypePropertiesEntry(
String relType,
List sourceNodeLabels,
List targetNodeLabels,
String propertyName,
List propertyTypes,
boolean mandatory,
long propertyObservations,
long totalObservations) {
this.relType = relType;
this.sourceNodeLabels = sourceNodeLabels;
this.targetNodeLabels = targetNodeLabels;
this.propertyName = propertyName;
this.propertyTypes = propertyTypes;
this.mandatory = mandatory;
this.propertyObservations = propertyObservations;
this.totalObservations = totalObservations;
}
}
public Tables4LabelsProfile() {
labelMap = new LinkedHashMap(100);
relMap = new LinkedHashMap(100);
obsByNode = new LinkedHashMap(100);
obsByRelType = new LinkedHashMap(100);
}
public PropertyContainerProfile getNodeProfile(OrderedLabels ol) {
if (labelMap.containsKey(ol)) {
return labelMap.get(ol);
} else {
PropertyContainerProfile p = new PropertyContainerProfile();
labelMap.put(ol, p);
return p;
}
}
public PropertyContainerProfile getRelProfile(String relType) {
if (relMap.containsKey(relType)) {
return relMap.get(relType);
} else {
PropertyContainerProfile p = new PropertyContainerProfile();
relMap.put(relType, p);
return p;
}
}
public Long sawNode(OrderedLabels labels) {
if (obsByNode.containsKey(labels)) {
Long val = obsByNode.get(labels) + 1;
obsByNode.put(labels, val);
return val;
} else {
obsByNode.put(labels, 1L);
return 1L;
}
}
public Long sawRel(String typeName) {
if (obsByRelType.containsKey(typeName)) {
Long val = obsByRelType.get(typeName) + 1;
obsByRelType.put(typeName, val);
return val;
} else {
obsByRelType.put(typeName, 1L);
return 1L;
}
}
public static String labelJoin(Iterable
© 2015 - 2024 Weber Informatics LLC | Privacy Policy