use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class MultipleIndexPopulator method newPopulatingUpdater.
@Override
public MultipleIndexUpdater newPopulatingUpdater(PropertyAccessor accessor) {
Map<LabelSchemaDescriptor, Pair<IndexPopulation, IndexUpdater>> updaters = new HashMap<>();
forEachPopulation(population -> {
IndexUpdater updater = population.populator.newPopulatingUpdater(accessor);
updaters.put(population.descriptor.schema(), Pair.of(population, updater));
});
return new MultipleIndexUpdater(this, updaters, logProvider);
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class NodeSchemaMatcher method onMatchingSchema.
/**
* Iterate over some schema suppliers, and invoke an action for every supplier that matches the node. To match the
* node N the supplier must supply a LabelSchemaDescriptor D, such that N has the label of D, and values for all
* the properties of D.
*
* To avoid unnecessary store lookups, this implementation only gets propertyKeyIds for the node if some
* descriptor has a valid label.
*
* @param state The current statement
* @param schemaSuppliers The suppliers to match
* @param node The node
* @param specialPropertyId This property id will always count as a match for the descriptor, regardless of
* whether the node has this property or not
* @param action The action to take on match
* @param <EXCEPTION> The type of exception that can be thrown when taking the action
* @throws EXCEPTION This exception is propagated from the action
*/
public <EXCEPTION extends Exception> void onMatchingSchema(KernelStatement state, Iterator<SUPPLIER> schemaSuppliers, NodeItem node, int specialPropertyId, SchemaMatchAction<SUPPLIER, EXCEPTION> action) throws EXCEPTION {
PrimitiveIntSet nodePropertyIds = null;
while (schemaSuppliers.hasNext()) {
SUPPLIER schemaSupplier = schemaSuppliers.next();
LabelSchemaDescriptor schema = schemaSupplier.schema();
if (node.labels().contains(schema.getLabelId())) {
if (nodePropertyIds == null) {
nodePropertyIds = Primitive.intSet();
nodePropertyIds.addAll(readOps.nodeGetPropertyKeys(state, node).iterator());
}
if (nodeHasSchemaProperties(nodePropertyIds, schema.getPropertyIds(), specialPropertyId)) {
action.act(schemaSupplier);
}
}
}
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexStatisticsTest method createIndex.
private NewIndexDescriptor createIndex(String labelName, String propertyKeyName) throws KernelException {
try (Transaction tx = db.beginTx()) {
Statement statement = bridge.get();
int labelId = statement.tokenWriteOperations().labelGetOrCreateForName(labelName);
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName(propertyKeyName);
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId);
NewIndexDescriptor index = statement.schemaWriteOperations().indexCreate(descriptor);
tx.success();
return index;
}
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class BatchInserterImpl method verifyIndexOrUniquenessConstraintCanBeCreated.
private void verifyIndexOrUniquenessConstraintCanBeCreated(int labelId, int[] propertyKeyIds, String errorMessage) {
LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds);
ConstraintDescriptor constraintDescriptor = ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyIds);
if (schemaCache.hasIndexRule(schemaDescriptor) || schemaCache.hasConstraintRule(constraintDescriptor)) {
throw new ConstraintViolationException(errorMessage);
}
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaRuleSerialization method readIndexRule.
// PRIVATE
// READ INDEX
private static IndexRule readIndexRule(long id, ByteBuffer source) throws MalformedSchemaRuleException {
SchemaIndexProvider.Descriptor indexProvider = readIndexProviderDescriptor(source);
LabelSchemaDescriptor schema;
byte indexRuleType = source.get();
String name;
switch(indexRuleType) {
case GENERAL_INDEX:
schema = readLabelSchema(source);
name = readRuleName(id, IndexRule.class, source);
return IndexRule.indexRule(id, NewIndexDescriptorFactory.forSchema(schema), indexProvider, name);
case UNIQUE_INDEX:
long owningConstraint = source.getLong();
schema = readLabelSchema(source);
NewIndexDescriptor descriptor = NewIndexDescriptorFactory.uniqueForSchema(schema);
name = readRuleName(id, IndexRule.class, source);
return IndexRule.constraintIndexRule(id, descriptor, indexProvider, owningConstraint == NO_OWNING_CONSTRAINT_YET ? null : owningConstraint, name);
default:
throw new MalformedSchemaRuleException(format("Got unknown index rule type '%d'.", indexRuleType));
}
}
Aggregations