public override LabelSet Labels() { if (HasChanges()) { TransactionState txState = _read.txState(); if (txState.NodeIsAddedInThisTx(_storeCursor.entityReference())) { //Node just added, no reason to go down to store and check return(Labels.From(txState.NodeStateLabelDiffSets(_storeCursor.entityReference()).Added)); } else { //Get labels from store and put in intSet, unfortunately we get longs back long[] longs = _storeCursor.labels(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet labels = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(); MutableLongSet labels = new LongHashSet(); foreach (long labelToken in longs) { labels.add(labelToken); } //Augment what was found in store with what we have in tx state return(Labels.From(txState.AugmentLabels(labels, txState.GetNodeState(_storeCursor.entityReference())))); } } else { //Nothing in tx state, just read the data. return(Labels.From(_storeCursor.labels())); } }
public override void Scan(IndexProgressor progressor, bool providesLabels, int label) { base.Initialize(progressor); if (_read.hasTxStateWithChanges()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.LongDiffSets changes = read.txState().nodesWithLabelChanged(label); LongDiffSets changes = _read.txState().nodesWithLabelChanged(label); _added = changes.Augment(ImmutableEmptyLongIterator.INSTANCE); _removed = mergeToSet(_read.txState().addedAndRemovedNodes().Removed, changes.Removed); } }
/// <summary> /// Store all types that was added in the transaction for the current node /// </summary> private void CheckTxStateForUpdates() { if (_read.hasTxStateWithChanges()) { NodeState nodeState = _read.txState().getNodeState(_storeCursor.OwningNode); LongIterator addedRelationships = nodeState.AddedRelationships; while (addedRelationships.hasNext()) { RelationshipState relationshipState = _read.txState().getRelationshipState(addedRelationships.next()); relationshipState.Accept((relationshipId, typeId, startNodeId, endNodeId) => _txTypes.add(typeId)); } } }
private void PrefixQuery(IndexDescriptor descriptor, IndexQuery.StringPrefixPredicate predicate) { TransactionState txState = _read.txState(); if (_needsValues) { AddedWithValuesAndRemoved changes = indexUpdatesWithValuesForRangeSeekByPrefix(txState, descriptor, predicate.Prefix(), _indexOrder); _addedWithValues = changes.Added.GetEnumerator(); _removed = _removed(txState, changes.Removed); } else { AddedAndRemoved changes = indexUpdatesForRangeSeekByPrefix(txState, descriptor, predicate.Prefix(), _indexOrder); _added = changes.Added.longIterator(); _removed = _removed(txState, changes.Removed); } }
/// <summary> /// A label has been changed, figure out what updates are needed to tx state. /// </summary> /// <param name="labelId"> The id of the changed label </param> /// <param name="existingPropertyKeyIds"> all property key ids the node has, sorted by id </param> /// <param name="node"> cursor to the node where the change was applied </param> /// <param name="propertyCursor"> cursor to the properties of node </param> /// <param name="changeType"> The type of change event </param> internal virtual void OnLabelChange(int labelId, int[] existingPropertyKeyIds, NodeCursor node, PropertyCursor propertyCursor, LabelChangeType changeType) { Debug.Assert(NoSchemaChangedInTx()); // Check all indexes of the changed label ICollection <SchemaDescriptor> indexes = _indexingService.getRelatedIndexes(new long[] { labelId }, existingPropertyKeyIds, NODE); if (indexes.Count > 0) { MutableIntObjectMap <Value> materializedProperties = IntObjectMaps.mutable.empty(); foreach (SchemaDescriptor index in indexes) { int[] indexPropertyIds = index.Schema().PropertyIds; Value[] values = GetValueTuple(node, propertyCursor, NO_SUCH_PROPERTY_KEY, NO_VALUE, indexPropertyIds, materializedProperties); switch (changeType) { case Org.Neo4j.Kernel.Impl.Newapi.IndexTxStateUpdater.LabelChangeType.AddedLabel: _indexingService.validateBeforeCommit(index.Schema(), values); _read.txState().indexDoUpdateEntry(index.Schema(), node.NodeReference(), null, ValueTuple.of(values)); break; case Org.Neo4j.Kernel.Impl.Newapi.IndexTxStateUpdater.LabelChangeType.RemovedLabel: _read.txState().indexDoUpdateEntry(index.Schema(), node.NodeReference(), ValueTuple.of(values), null); break; default: throw new System.InvalidOperationException(changeType + " is not a supported event"); } } } }
protected internal override void CollectAddedTxStateSnapshot() { if (Single) { _addedRelationships = Read.txState().relationshipIsAddedInThisTx(_single) ? LongHashSet.newSetWith(_single).longIterator() : ImmutableEmptyLongIterator.INSTANCE; } else { _addedRelationships = Read.txState().addedAndRemovedRelationships().Added.longIterator(); } }
protected internal override void CollectAddedTxStateSnapshot() { if (_filterState == FilterState.NotInitialized) { StoreCursor.next(); SetupFilterState(); } NodeState nodeState = Read.txState().getNodeState(StoreCursor.originNodeReference()); _addedRelationships = HasTxStateFilter() ? nodeState.GetAddedRelationships(_filterState.direction, _filterType) : nodeState.AddedRelationships; }
public override bool Next() { // Check tx state bool hasChanges = hasChanges(); if (hasChanges && _addedRelationships.hasNext()) { Read.txState().relationshipVisit(_addedRelationships.next(), StoreCursor); return(true); } while (StoreCursor.next()) { if (!hasChanges || !Read.txState().relationshipIsDeletedInThisTx(StoreCursor.entityReference())) { return(true); } } return(false); }
public override bool Next() { bool hasChanges; if (_filterState == FilterState.NotInitialized) { hasChanges = hasChanges(); // <- will setup filter state if needed if (_filterState == FilterState.NotInitialized && _filterStore) { StoreCursor.next(); SetupFilterState(); } if (_filterState != FilterState.NotInitialized && !(hasChanges && Read.txState().relationshipIsDeletedInThisTx(RelationshipReference()))) { return(true); } } else { hasChanges = hasChanges(); } // tx-state relationships if (hasChanges && _addedRelationships.hasNext()) { Read.txState().relationshipVisit(_addedRelationships.next(), StoreCursor); return(true); } while (StoreCursor.next()) { bool skip = (_filterStore && !CorrectTypeAndDirection()) || (hasChanges && Read.txState().relationshipIsDeletedInThisTx(StoreCursor.entityReference())); if (!skip) { return(true); } } return(false); }