use of org.neo4j.internal.schema.IndexType in project neo4j by neo4j.
the class SchemaStore method schemaIndexToMap.
private static void schemaIndexToMap(IndexDescriptor rule, Map<String, Value> map) {
// Rule
putStringProperty(map, PROP_SCHEMA_RULE_TYPE, "INDEX");
IndexType indexType = rule.getIndexType();
putStringProperty(map, PROP_INDEX_TYPE, indexType.name());
if (rule.isUnique()) {
putStringProperty(map, PROP_INDEX_RULE_TYPE, "UNIQUE");
if (rule.getOwningConstraintId().isPresent()) {
map.put(PROP_OWNING_CONSTRAINT, Values.longValue(rule.getOwningConstraintId().getAsLong()));
}
} else {
putStringProperty(map, PROP_INDEX_RULE_TYPE, "NON_UNIQUE");
}
// Provider
indexProviderToMap(rule, map);
// Index config
IndexConfig indexConfig = rule.getIndexConfig();
indexConfigToMap(indexConfig, map);
}
use of org.neo4j.internal.schema.IndexType in project neo4j by neo4j.
the class SchemaRuleException method describe.
public static String describe(SchemaDescriptorSupplier schemaThing) {
SchemaDescriptor schema = schemaThing.schema();
String tagType;
switch(schema.entityType()) {
case NODE:
tagType = "label";
break;
case RELATIONSHIP:
tagType = "relationship type";
break;
default:
throw new AssertionError("Unknown entity type: " + schema.entityType());
}
if (schemaThing instanceof ConstraintDescriptor) {
ConstraintDescriptor constraint = (ConstraintDescriptor) schemaThing;
switch(constraint.type()) {
case UNIQUE:
return tagType + " uniqueness constraint";
case EXISTS:
return tagType + " property existence constraint";
case UNIQUE_EXISTS:
return schema.entityType().name().toLowerCase() + " key constraint";
default:
throw new AssertionError("Unknown constraint type: " + constraint.type());
}
} else {
IndexDescriptor index = (IndexDescriptor) schemaThing;
IndexType indexType = index.getIndexType();
if (indexType != IndexType.BTREE) {
String indexTypeName = indexType.name().toLowerCase();
return indexTypeName + " " + tagType + " index";
} else {
return tagType + " index";
}
}
}
use of org.neo4j.internal.schema.IndexType in project neo4j by neo4j.
the class GraphCountsSection method indexes.
private static List<Map<String, Object>> indexes(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer) throws IndexNotFoundKernelException {
List<Map<String, Object>> indexes = new ArrayList<>();
Iterator<IndexDescriptor> iterator = schemaRead.indexesGetAll();
while (iterator.hasNext()) {
IndexDescriptor index = iterator.next();
IndexType indexType = index.getIndexType();
if (indexType == IndexType.FULLTEXT) {
/* For full text indexes, we currently do not return its options, which makes returning information on
* this index not useful and if the index type is ignored, this would even be misleading.
*/
continue;
}
EntityType entityType = index.schema().entityType();
Map<String, Object> data = new HashMap<>();
switch(entityType) {
case NODE:
data.put("labels", map(index.schema().getEntityTokenIds(), id -> anonymizer.label(tokens.labelGetName(id), id)));
break;
case RELATIONSHIP:
data.put("relationshipTypes", map(index.schema().getEntityTokenIds(), id -> anonymizer.relationshipType(tokens.relationshipTypeGetName(id), id)));
break;
default:
}
data.put("properties", map(index.schema().getPropertyIds(), id -> anonymizer.propertyKey(tokens.propertyKeyGetName(id), id)));
var indexSample = schemaRead.indexSample(index);
data.put("totalSize", indexSample.indexSize());
data.put("updatesSinceEstimation", indexSample.updates());
data.put("estimatedUniqueSize", indexSample.uniqueValues());
data.put("indexType", indexType.name());
indexes.add(data);
}
return indexes;
}
Aggregations