use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class GraphCountsSection method constraints.
private static List<Map<String, Object>> constraints(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer) {
List<Map<String, Object>> constraints = new ArrayList<>();
Iterator<ConstraintDescriptor> iterator = schemaRead.constraintsGetAll();
while (iterator.hasNext()) {
ConstraintDescriptor constraint = iterator.next();
EntityType entityType = constraint.schema().entityType();
Map<String, Object> data = new HashMap<>();
data.put("properties", map(constraint.schema().getPropertyIds(), id -> anonymizer.propertyKey(tokens.propertyKeyGetName(id), id)));
data.put("type", constraintType(constraint));
int entityTokenId = constraint.schema().getEntityTokenIds()[0];
switch(entityType) {
case NODE:
data.put("label", anonymizer.label(tokens.labelGetName(entityTokenId), entityTokenId));
constraints.add(data);
break;
case RELATIONSHIP:
data.put("relationshipType", anonymizer.relationshipType(tokens.relationshipTypeGetName(entityTokenId), entityTokenId));
constraints.add(data);
break;
default:
}
}
return constraints;
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class TransactionImpl method findUsableMatchingIndex.
/**
* Find an ONLINE index that matches the schema.
*/
private static IndexDescriptor findUsableMatchingIndex(KernelTransaction transaction, SchemaDescriptor schemaDescriptor) {
SchemaRead schemaRead = transaction.schemaRead();
Iterator<IndexDescriptor> iterator = schemaRead.index(schemaDescriptor);
while (iterator.hasNext()) {
IndexDescriptor index = iterator.next();
if (index.getIndexType() != IndexType.FULLTEXT && indexIsOnline(schemaRead, index)) {
return index;
}
}
return IndexDescriptor.NO_INDEX;
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method getConstraints.
@Override
public Iterable<ConstraintDefinition> getConstraints(final Label label) {
transaction.assertOpen();
TokenRead tokenRead = transaction.tokenRead();
SchemaRead schemaRead = transaction.schemaRead();
int labelId = tokenRead.nodeLabel(label.name());
if (labelId == TokenRead.NO_TOKEN) {
return emptyList();
}
return asConstraintDefinitions(schemaRead.constraintsGetForLabel(labelId), tokenRead);
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method awaitIndexOnline.
@Override
public void awaitIndexOnline(String indexName, long duration, TimeUnit unit) {
requireNonNull(indexName);
transaction.assertOpen();
SchemaRead schemaRead = transaction.schemaRead();
Iterable<IndexDescriptor> iterable = () -> Iterators.iterator(schemaRead.indexGetForName(indexName));
if (awaitIndexesOnline(iterable, index -> "`" + indexName + "`", duration, unit, false)) {
throw new IllegalStateException("Expected index to come online within a reasonable time.");
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method getIndexes.
@Override
public Iterable<IndexDefinition> getIndexes() {
transaction.assertOpen();
SchemaRead schemaRead = transaction.schemaRead();
List<IndexDefinition> definitions = new ArrayList<>();
Iterator<IndexDescriptor> indexes = schemaRead.indexesGetAll();
addDefinitions(definitions, transaction.tokenRead(), IndexDescriptor.sortByType(indexes));
return definitions;
}
Aggregations