Search in sources :

Example 6 with LongDiffSets

use of org.neo4j.storageengine.api.txstate.LongDiffSets in project neo4j by neo4j.

the class TxState method augmentLabels.

@Override
public MutableLongSet augmentLabels(MutableLongSet labels, NodeState nodeState) {
    final LongDiffSets labelDiffSets = nodeState.labelDiffSets();
    if (!labelDiffSets.isEmpty()) {
        labelDiffSets.getRemoved().forEach(labels::remove);
        labelDiffSets.getAdded().forEach(labels::add);
    }
    return labels;
}
Also used : TrackableDiffSets.newMutableLongDiffSets(org.neo4j.kernel.impl.util.diffsets.TrackableDiffSets.newMutableLongDiffSets) MutableLongDiffSets(org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSets) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets)

Example 7 with LongDiffSets

use of org.neo4j.storageengine.api.txstate.LongDiffSets in project neo4j by neo4j.

the class DefaultNodeCursor method hasLabel.

@Override
public boolean hasLabel(int label) {
    if (hasChanges()) {
        TransactionState txState = read.txState();
        LongDiffSets diffSets = txState.nodeStateLabelDiffSets(nodeReference());
        if (diffSets.getAdded().contains(label)) {
            return true;
        }
        if (diffSets.getRemoved().contains(label)) {
            return false;
        }
    }
    // Get labels from store and put in intSet, unfortunately we get longs back
    return storeCursor.hasLabel(label);
}
Also used : TransactionState(org.neo4j.kernel.api.txstate.TransactionState) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets)

Example 8 with LongDiffSets

use of org.neo4j.storageengine.api.txstate.LongDiffSets in project neo4j by neo4j.

the class TxStateTransactionDataSnapshot method snapshotModifiedNodes.

private void snapshotModifiedNodes(MemoryTracker memoryTracker, StorageNodeCursor node, StoragePropertyCursor properties, TokenRead tokenRead) throws PropertyKeyIdNotFoundKernelException {
    for (NodeState nodeState : state.modifiedNodes()) {
        Iterator<StorageProperty> added = nodeState.addedAndChangedProperties();
        long nodeId = nodeState.getId();
        while (added.hasNext()) {
            StorageProperty property = added.next();
            var entryView = createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, property.propertyKeyId(), property.value(), committedValue(nodeState, property.propertyKeyId(), node, properties));
            assignedNodeProperties.add(entryView);
        }
        nodeState.removedProperties().each(id -> {
            try {
                removedNodeProperties.add(createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, id, null, committedValue(nodeState, id, node, properties)));
            } catch (PropertyKeyIdNotFoundKernelException e) {
                throw new IllegalStateException("Not existing node properties was modified for node " + nodeId, e);
            }
        });
        final LongDiffSets labels = nodeState.labelDiffSets();
        addLabelEntriesTo(nodeId, labels.getAdded(), assignedLabels);
        addLabelEntriesTo(nodeId, labels.getRemoved(), removedLabels);
    }
}
Also used : NodeState(org.neo4j.storageengine.api.txstate.NodeState) StorageProperty(org.neo4j.storageengine.api.StorageProperty) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 9 with LongDiffSets

use of org.neo4j.storageengine.api.txstate.LongDiffSets in project neo4j by neo4j.

the class TxStateIndexChanges method indexUpdatesForScanAndFilter.

// HELPERS
private static AddedAndRemoved indexUpdatesForScanAndFilter(ReadableTransactionState txState, IndexDescriptor descriptor, PropertyIndexQuery filter, IndexOrder indexOrder) {
    Map<ValueTuple, ? extends LongDiffSets> updates = getUpdates(txState, descriptor, indexOrder);
    if (updates == null) {
        return EMPTY_ADDED_AND_REMOVED;
    }
    MutableLongList added = LongLists.mutable.empty();
    MutableLongSet removed = LongSets.mutable.empty();
    for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : updates.entrySet()) {
        ValueTuple key = entry.getKey();
        if (filter == null || filter.acceptsValue(key.valueAt(0))) {
            LongDiffSets diffSet = entry.getValue();
            added.addAll(diffSet.getAdded());
            removed.addAll(diffSet.getRemoved());
        }
    }
    return new AddedAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) ValueTuple(org.neo4j.values.storable.ValueTuple) NavigableMap(java.util.NavigableMap) Map(java.util.Map) UnmodifiableMap(org.eclipse.collections.impl.UnmodifiableMap) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets)

Example 10 with LongDiffSets

use of org.neo4j.storageengine.api.txstate.LongDiffSets in project neo4j by neo4j.

the class TxStateIndexChanges method indexUpdatesWithValuesForSeek.

static AddedWithValuesAndRemoved indexUpdatesWithValuesForSeek(ReadableTransactionState txState, IndexDescriptor descriptor, ValueTuple values) {
    UnmodifiableMap<ValueTuple, ? extends LongDiffSets> updates = txState.getIndexUpdates(descriptor.schema());
    if (updates != null) {
        LongDiffSets indexUpdatesForSeek = updates.get(values);
        if (indexUpdatesForSeek == null) {
            return EMPTY_ADDED_AND_REMOVED_WITH_VALUES;
        }
        Value[] valueArray = values.getValues();
        MutableList<EntityWithPropertyValues> added = Lists.mutable.empty();
        indexUpdatesForSeek.getAdded().forEach((LongProcedure) l -> added.add(new EntityWithPropertyValues(l, valueArray)));
        return new AddedWithValuesAndRemoved(added, indexUpdatesForSeek.getRemoved());
    }
    return EMPTY_ADDED_AND_REMOVED_WITH_VALUES;
}
Also used : IndexOrder(org.neo4j.internal.schema.IndexOrder) NO_VALUE(org.neo4j.values.storable.Values.NO_VALUE) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) ValueTuple(org.neo4j.values.storable.ValueTuple) LongLists(org.eclipse.collections.impl.factory.primitive.LongLists) Value(org.neo4j.values.storable.Value) TextValue(org.neo4j.values.storable.TextValue) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) NavigableMap(java.util.NavigableMap) MutableList(org.eclipse.collections.api.list.MutableList) Values(org.neo4j.values.storable.Values) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongProcedure(org.eclipse.collections.api.block.procedure.primitive.LongProcedure) Lists(org.eclipse.collections.impl.factory.Lists) Map(java.util.Map) LongIterable(org.eclipse.collections.api.LongIterable) LongSets(org.eclipse.collections.impl.factory.primitive.LongSets) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) ValueGroup(org.neo4j.values.storable.ValueGroup) LongSet(org.eclipse.collections.api.set.primitive.LongSet) Collections(java.util.Collections) UnmodifiableMap(org.eclipse.collections.impl.UnmodifiableMap) ValueTuple(org.neo4j.values.storable.ValueTuple) Value(org.neo4j.values.storable.Value) TextValue(org.neo4j.values.storable.TextValue) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets)

Aggregations

LongDiffSets (org.neo4j.storageengine.api.txstate.LongDiffSets)13 ValueTuple (org.neo4j.values.storable.ValueTuple)8 Map (java.util.Map)7 NavigableMap (java.util.NavigableMap)7 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)7 UnmodifiableMap (org.eclipse.collections.impl.UnmodifiableMap)7 TextValue (org.neo4j.values.storable.TextValue)6 Value (org.neo4j.values.storable.Value)6 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)4 MutableLongDiffSets (org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSets)4 TrackableDiffSets.newMutableLongDiffSets (org.neo4j.kernel.impl.util.diffsets.TrackableDiffSets.newMutableLongDiffSets)3 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)2 NodeState (org.neo4j.storageengine.api.txstate.NodeState)2 Collections (java.util.Collections)1 LongIterable (org.eclipse.collections.api.LongIterable)1 LongProcedure (org.eclipse.collections.api.block.procedure.primitive.LongProcedure)1 MutableList (org.eclipse.collections.api.list.MutableList)1 LongSet (org.eclipse.collections.api.set.primitive.LongSet)1 Lists (org.eclipse.collections.impl.factory.Lists)1 LongLists (org.eclipse.collections.impl.factory.primitive.LongLists)1