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;
}
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);
}
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);
}
}
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);
}
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;
}
Aggregations