//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConsiderNodesChangedInSameTxInIndexSeek()
        public virtual void ShouldConsiderNodesChangedInSameTxInIndexSeek()
        {
            // GIVEN
            CreateNodes(_db, _label, NonMatching[0]);
            LongSet        toChangeToMatch    = CreateNodes(_db, _label, NonMatching[1]);
            LongSet        toChangeToNotMatch = CreateNodes(_db, _label, Values);
            MutableLongSet expected           = CreateNodes(_db, _label, Values);
            // WHEN
            MutableLongSet found = new LongHashSet();

            using (Transaction tx = _db.beginTx())
            {
                LongIterator toMatching = toChangeToMatch.longIterator();
                while (toMatching.hasNext())
                {
                    long id = toMatching.next();
                    SetProperties(id, Values);
                    expected.add(id);
                }
                LongIterator toNotMatching = toChangeToNotMatch.longIterator();
                while (toNotMatching.hasNext())
                {
                    long id = toNotMatching.next();
                    SetProperties(id, NonMatching[2]);
                    expected.remove(id);
                }

                CollectNodes(found, IndexSeek.findNodes(Keys, Values, _db));
            }
            // THEN
            assertThat(found, equalTo(expected));
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.List<java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>>> addACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfBlocks) throws java.io.IOException
        private IList <IList <BlockEntry <MutableLong, MutableLong> > > AddACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage <MutableLong, MutableLong> storage, int numberOfBlocks)
        {
            Debug.Assert(numberOfBlocks != 1);

            MutableLongSet uniqueKeys = LongSets.mutable.empty();
            IList <IList <BlockEntry <MutableLong, MutableLong> > > expected        = new List <IList <BlockEntry <MutableLong, MutableLong> > >();
            IList <BlockEntry <MutableLong, MutableLong> >          currentExpected = new List <BlockEntry <MutableLong, MutableLong> >();
            long currentBlock = 0;

            while (monitor.BlockFlushedCallCount < numberOfBlocks - 1)
            {
                MutableLong key   = UniqueKey(uniqueKeys);
                MutableLong value = new MutableLong(Random.nextLong(10_000_000));

                storage.Add(key, value);
                if (monitor.BlockFlushedCallCount > currentBlock)
                {
                    Sort(currentExpected);
                    expected.Add(currentExpected);
                    currentExpected = new List <BlockEntry <MutableLong, MutableLong> >();
                    currentBlock    = monitor.BlockFlushedCallCount;
                }
                currentExpected.Add(new BlockEntry <>(key, value));
            }
            storage.DoneAdding();
            if (currentExpected.Count > 0)
            {
                expected.Add(currentExpected);
            }
            return(expected);
        }
Exemple #3
0
        private static AddedWithValuesAndRemoved IndexUpdatesWithValuesScanAndFilter(ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery filter, IndexOrder indexOrder)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> updates = getUpdates(txState, descriptor, indexOrder);
            IDictionary <ValueTuple, ? extends LongDiffSets> updates = GetUpdates(txState, descriptor, indexOrder);

            if (updates == null)
            {
                return(_emptyAddedAndRemovedWithValues);
            }

            MutableList <NodeWithPropertyValues> added = Lists.mutable.empty();
            MutableLongSet removed = LongSets.mutable.empty();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : updates.entrySet())
            foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in updates.SetOfKeyValuePairs())
            {
                ValueTuple key = entry.Key;
                if (filter == null || filter.AcceptsValue(key.OnlyValue))
                {
                    Value[]      values  = key.Values;
                    LongDiffSets diffSet = entry.Value;
                    diffSet.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, values)));
                    removed.addAll(diffSet.Removed);
                }
            }
            return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed));
        }
Exemple #4
0
        internal static AddedWithValuesAndRemoved IndexUpdatesWithValuesForRangeSeekByPrefix(ReadableTransactionState txState, IndexDescriptor descriptor, TextValue prefix, IndexOrder indexOrder)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.NavigableMap<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema());
            NavigableMap <ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.GetSortedIndexUpdates(descriptor.Schema());

            if (sortedUpdates == null)
            {
                return(_emptyAddedAndRemovedWithValues);
            }
            ValueTuple floor = ValueTuple.of(prefix);

            MutableList <NodeWithPropertyValues> added = Lists.mutable.empty();
            MutableLongSet removed = LongSets.mutable.empty();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : sortedUpdates.tailMap(floor).entrySet())
            foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in sortedUpdates.tailMap(floor).entrySet())
            {
                ValueTuple key = entry.Key;
                if ((( TextValue )key.OnlyValue).startsWith(prefix))
                {
                    LongDiffSets diffSets = entry.Value;
                    Value[]      values   = key.Values;
                    diffSets.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, values)));
                    removed.addAll(diffSets.Removed);
                }
                else
                {
                    break;
                }
            }
            return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConsiderNodesChangedInSameTxInIndexSeek()
        public virtual void ShouldConsiderNodesChangedInSameTxInIndexSeek()
        {
            // GIVEN
            CreateNodes(_db, _label, _nonMatching[0]);
            LongSet        toChangeToMatch    = CreateNodes(_db, _label, _nonMatching[1]);
            MutableLongSet toChangeToNotMatch = CreateNodes(_db, _label, _matching[0]);
            MutableLongSet expected           = CreateNodes(_db, _label, _matching[1]);
            // WHEN
            MutableLongSet found = new LongHashSet();

            using (Transaction tx = _db.beginTx())
            {
                LongIterator toMatching = toChangeToMatch.longIterator();
                while (toMatching.hasNext())
                {
                    long id = toMatching.next();
                    _db.getNodeById(id).setProperty(_key, _matching[2]);
                    expected.add(id);
                }
                LongIterator toNotMatching = toChangeToNotMatch.longIterator();
                while (toNotMatching.hasNext())
                {
                    long id = toNotMatching.next();
                    _db.getNodeById(id).setProperty(_key, _nonMatching[2]);
                    expected.remove(id);
                }

                CollectNodes(found, _db.findNodes(_label, _key, _template, _searchMode));
            }
            // THEN
            assertThat(found, equalTo(expected));
        }
 private void CollectNodes(MutableLongSet bucket, ResourceIterator <Node> toCollect)
 {
     while (toCollect.MoveNext())
     {
         bucket.add(toCollect.Current.Id);
     }
 }
Exemple #7
0
        private MutableLong UniqueKey(MutableLongSet uniqueKeys)
        {
            MutableLong key;

            do
            {
                key = new MutableLong(Random.nextLong(10_000_000));
            } while (!uniqueKeys.add(key.longValue()));
            return(key);
        }
        public virtual void AddRelationship(long relId, int typeId, RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap = getTypeToRelMapForDirection(direction);
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap = GetTypeToRelMapForDirection(direction);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet rels = relTypeToRelsMap.getIfAbsentPut(typeId, org.eclipse.collections.impl.set.mutable.primitive.LongHashSet::new);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            MutableLongSet rels = relTypeToRelsMap.getIfAbsentPut(typeId, LongHashSet::new);

            rels.add(relId);
        }
Exemple #9
0
        public override MutableLongSet AugmentLabels(MutableLongSet labels, NodeState nodeState)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.LongDiffSets labelDiffSets = nodeState.labelDiffSets();
            LongDiffSets labelDiffSets = nodeState.LabelDiffSets();

            if (!labelDiffSets.Empty)
            {
                labelDiffSets.Removed.forEach(labels.remove);
                labelDiffSets.Added.forEach(labels.add);
            }
            return(labels);
        }
Exemple #10
0
 public override bool Remove(long elem)
 {
     if (IsAdded(elem) && base.Remove(elem))
     {
         if (RemovedFromAdded == null)
         {
             RemovedFromAdded = outerInstance.collectionsFactory.NewLongSet();
         }
         RemovedFromAdded.add(elem);
         return(true);
     }
     return(base.Remove(elem));
 }
        internal FulltextIndexTransactionState(FulltextIndexProvider provider, Log log, IndexReference indexReference)
        {
            FulltextIndexAccessor accessor = provider.GetOpenOnlineAccessor(( StoreIndexDescriptor )indexReference);

            log.Debug("Acquired online fulltext schema index accessor, as base accessor for transaction state: %s", accessor);
            _descriptor = accessor.Descriptor;
            SchemaDescriptor schema = _descriptor.schema();

            _toCloseLater = new List <AutoCloseable>();
            _writer       = accessor.TransactionStateIndexWriter;
            _modifiedEntityIdsInThisTransaction = new LongHashSet();
            _visitingNodes  = Schema.entityType() == EntityType.NODE;
            _txStateVisitor = new FulltextIndexTransactionStateVisitor(_descriptor, _modifiedEntityIdsInThisTransaction, _writer);
        }
Exemple #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>> addEntries(BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfEntries) throws java.io.IOException
        private IList <BlockEntry <MutableLong, MutableLong> > AddEntries(BlockStorage <MutableLong, MutableLong> storage, int numberOfEntries)
        {
            MutableLongSet uniqueKeys = LongSets.mutable.empty();
            IList <BlockEntry <MutableLong, MutableLong> > entries = new List <BlockEntry <MutableLong, MutableLong> >();

            for (int i = 0; i < numberOfEntries; i++)
            {
                MutableLong key   = UniqueKey(uniqueKeys);
                MutableLong value = new MutableLong(Random.nextLong(10_000_000));
                storage.Add(key, value);
                entries.Add(new BlockEntry <>(key, value));
            }
            Sort(entries);
            return(entries);
        }
 internal FulltextIndexTransactionStateVisitor(FulltextIndexDescriptor descriptor, MutableLongSet modifiedEntityIdsInThisTransaction, TransactionStateLuceneIndexWriter writer)
 {
     this._descriptor = descriptor;
     this._schema     = descriptor.Schema();
     this._modifiedEntityIdsInThisTransaction = modifiedEntityIdsInThisTransaction;
     this._writer        = writer;
     this._visitingNodes = _schema.entityType() == EntityType.NODE;
     _entityTokenIds     = _schema.EntityTokenIds;
     int[] propertyIds = _schema.PropertyIds;
     _propertyValues = new Value[propertyIds.Length];
     _propKeyToIndex = new IntIntHashMap();
     for (int i = 0; i < propertyIds.Length; i++)
     {
         _propKeyToIndex.put(propertyIds[i], i);
     }
 }
Exemple #14
0
 internal virtual void RemoveProperty(int propertyKeyId)
 {
     if (_addedProperties != null && _addedProperties.remove(propertyKeyId) != null)
     {
         return;
     }
     if (_removedProperties == null)
     {
         _removedProperties = CollectionsFactory.newLongSet();
     }
     _removedProperties.add(propertyKeyId);
     if (_changedProperties != null)
     {
         _changedProperties.remove(propertyKeyId);
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeNodesCreatedInSameTxInIndexSeek()
        public virtual void ShouldIncludeNodesCreatedInSameTxInIndexSeek()
        {
            // GIVEN
            CreateNodes(_db, _label, _nonMatching[0], _nonMatching[1]);
            MutableLongSet expected = CreateNodes(_db, _label, _matching[0], _matching[1]);
            // WHEN
            MutableLongSet found = new LongHashSet();

            using (Transaction tx = _db.beginTx())
            {
                expected.add(CreateNode(_db, map(_key, _matching[2]), _label).Id);
                CreateNode(_db, map(_key, _nonMatching[2]), _label);

                CollectNodes(found, _db.findNodes(_label, _key, _template, _searchMode));
            }
            // THEN
            assertThat(found, equalTo(expected));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeNodesCreatedInSameTxInIndexSeek()
        public virtual void ShouldIncludeNodesCreatedInSameTxInIndexSeek()
        {
            // GIVEN
            CreateNodes(_db, _label, NonMatching[0], NonMatching[1]);
            MutableLongSet expected = CreateNodes(_db, _label, Values);
            // WHEN
            MutableLongSet found = new LongHashSet();

            using (Transaction tx = _db.beginTx())
            {
                expected.add(CreateNode(_db, PropertyMap(Keys, Values), _label).Id);
                CreateNode(_db, PropertyMap(Keys, NonMatching[2]), _label);

                CollectNodes(found, IndexSeek.findNodes(Keys, Values, _db));
            }
            // THEN
            assertThat(found, equalTo(expected));
        }
        public virtual bool RemoveRelationship(long relId, int typeId, RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap = getTypeToRelMapForDirection(direction);
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap = GetTypeToRelMapForDirection(direction);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet rels = relTypeToRelsMap.get(typeId);
            MutableLongSet rels = relTypeToRelsMap.get(typeId);

            if (rels != null && rels.remove(relId))
            {
                if (rels.Empty)
                {
                    relTypeToRelsMap.remove(typeId);
                }
                return(true);
            }
            return(false);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotIncludeNodesDeletedInSameTxInIndexSeek()
        public virtual void ShouldNotIncludeNodesDeletedInSameTxInIndexSeek()
        {
            // GIVEN
            CreateNodes(_db, _label, _nonMatching[0]);
            LongSet        toDelete = CreateNodes(_db, _label, _matching[0], _nonMatching[1], _matching[1], _nonMatching[2]);
            MutableLongSet expected = CreateNodes(_db, _label, _matching[2]);
            // WHEN
            MutableLongSet found = new LongHashSet();

            using (Transaction tx = _db.beginTx())
            {
                LongIterator deleting = toDelete.longIterator();
                while (deleting.hasNext())
                {
                    long id = deleting.next();
                    _db.getNodeById(id).delete();
                    expected.remove(id);
                }

                CollectNodes(found, _db.findNodes(_label, _key, _template, _searchMode));
            }
            // THEN
            assertThat(found, equalTo(expected));
        }
 public MonitorAnonymousInnerClass(FreeListIdProviderTest outerInstance, MutableLongSet expected)
 {
     this.outerInstance = outerInstance;
     this._expected     = expected;
 }
Exemple #20
0
        internal static AddedWithValuesAndRemoved IndexUpdatesWithValuesForRangeSeek <T1>(ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery.RangePredicate <T1> predicate, IndexOrder indexOrder)
        {
            Value lower = predicate.FromValue();
            Value upper = predicate.ToValue();

            if (lower == null || upper == null)
            {
                throw new System.InvalidOperationException("Use Values.NO_VALUE to encode the lack of a bound");
            }

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.NavigableMap<org.neo4j.values.storable.ValueTuple, ? extends org.neo4j.storageengine.api.txstate.LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema());
            NavigableMap <ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.GetSortedIndexUpdates(descriptor.Schema());

            if (sortedUpdates == null)
            {
                return(_emptyAddedAndRemovedWithValues);
            }

            ValueTuple selectedLower;
            bool       selectedIncludeLower;

            ValueTuple selectedUpper;
            bool       selectedIncludeUpper;

            if (lower == NO_VALUE)
            {
                selectedLower        = ValueTuple.of(Values.minValue(predicate.ValueGroup(), upper));
                selectedIncludeLower = true;
            }
            else
            {
                selectedLower        = ValueTuple.of(lower);
                selectedIncludeLower = predicate.FromInclusive();
            }

            if (upper == NO_VALUE)
            {
                selectedUpper        = ValueTuple.of(Values.maxValue(predicate.ValueGroup(), lower));
                selectedIncludeUpper = false;
            }
            else
            {
                selectedUpper        = ValueTuple.of(upper);
                selectedIncludeUpper = predicate.ToInclusive();
            }

            MutableList <NodeWithPropertyValues> added = Lists.mutable.empty();
            MutableLongSet removed = LongSets.mutable.empty();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper);
            IDictionary <ValueTuple, ? extends LongDiffSets> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : inRange.entrySet())
            foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in inRange.SetOfKeyValuePairs())
            {
                ValueTuple   values               = entry.Key;
                Value[]      valuesArray          = values.Values;
                LongDiffSets diffForSpecificValue = entry.Value;

                // The TreeMap cannot perfectly order multi-dimensional types (spatial) and need additional filtering out false positives
                // TODO: If the composite index starts to be able to handle spatial types the line below needs enhancement
                if (predicate.RegularOrder || predicate.AcceptsValue(values.OnlyValue))
                {
                    diffForSpecificValue.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, valuesArray)));
                    removed.addAll(diffForSpecificValue.Removed);
                }
            }
            return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed));
        }
 public IdProvider_IdProviderVisitor_AdaptorAnonymousInnerClass2(FreeListIdProviderTest outerInstance, MutableLongSet expected)
 {
     this.outerInstance = outerInstance;
     this._expected     = expected;
 }