use of org.neo4j.collection.primitive.PrimitiveIntSet 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.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class IndexTxStateUpdater method onLabelChange.
public void onLabelChange(KernelStatement state, int labelId, NodeItem node, LabelChangeType changeType) throws EntityNotFoundException {
PrimitiveIntSet nodePropertyIds = Primitive.intSet();
nodePropertyIds.addAll(readOps.nodeGetPropertyKeys(state, node).iterator());
Iterator<NewIndexDescriptor> indexes = Iterators.concat(schemaReadOps.indexesGetForLabel(state, labelId), schemaReadOps.uniqueIndexesGetForLabel(state, labelId));
while (indexes.hasNext()) {
NewIndexDescriptor index = indexes.next();
int[] indexPropertyIds = index.schema().getPropertyIds();
if (nodeHasIndexProperties(nodePropertyIds, indexPropertyIds)) {
OrderedPropertyValues values = getOrderedPropertyValues(state, node, indexPropertyIds);
if (changeType == LabelChangeType.ADDED_LABEL) {
state.txState().indexDoUpdateEntry(index.schema(), node.id(), null, values);
} else {
state.txState().indexDoUpdateEntry(index.schema(), node.id(), values, null);
}
}
}
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class PropertyChain method checkConsistency.
@Override
public void checkConsistency(RECORD record, CheckerEngine<RECORD, REPORT> engine, RecordAccess records) {
if (!Record.NO_NEXT_PROPERTY.is(record.getNextProp())) {
// Check the whole chain here instead of scattered during multiple checks.
// This type of check obviously favors chains with good locality, performance-wise.
Iterator<PropertyRecord> props = records.rawPropertyChain(record.getNextProp());
PropertyRecord firstProp = props.next();
if (!Record.NO_PREVIOUS_PROPERTY.is(firstProp.getPrevProp())) {
engine.report().propertyNotFirstInChain(firstProp);
}
try (PrimitiveIntSet keys = Primitive.intSet();
MandatoryProperties.Check<RECORD, REPORT> mandatory = mandatoryProperties.apply(record)) {
checkChainItem(firstProp, engine, keys, mandatory);
// Check the whole chain here. We also take the opportunity to check mandatory property constraints.
while (props.hasNext()) {
checkChainItem(props.next(), engine, keys, mandatory);
}
}
}
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class PropertyAndNodeIndexedCheck method checkProperty.
private void checkProperty(NodeRecord record, CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine, Collection<PropertyRecord> props) {
if (!Record.NO_NEXT_PROPERTY.is(record.getNextProp())) {
PropertyRecord firstProp = props.iterator().next();
if (!Record.NO_PREVIOUS_PROPERTY.is(firstProp.getPrevProp())) {
engine.report().propertyNotFirstInChain(firstProp);
}
PrimitiveIntSet keys = Primitive.intSet();
for (PropertyRecord property : props) {
if (!property.inUse()) {
engine.report().propertyNotInUse(property);
} else {
for (int key : ChainCheck.keys(property)) {
if (!keys.add(key)) {
engine.report().propertyKeyNotUniqueInChain();
}
}
}
}
}
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class TransactionCountingStateVisitor method decrementCountForLabelsAndRelationships.
private void decrementCountForLabelsAndRelationships(NodeItem node) {
PrimitiveIntSet labelIds = node.labels();
labelIds.visitKeys(labelId -> {
counts.incrementNodeCount(labelId, -1);
return false;
});
storeLayer.degrees(statement, node, (type, out, in) -> updateRelationshipsCountsFromDegrees(labelIds, type, -out, -in));
}
Aggregations