Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetDistinctStringValues() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGetDistinctStringValues()
        {
            // given
            LuceneIndexWriter writer = _index.IndexWriter;
            IDictionary <Value, MutableInt> expectedCounts = new Dictionary <Value, MutableInt>();

            for (int i = 0; i < 10_000; i++)
            {
                Value value = stringValue(Random.Next(1_000).ToString());
                writer.AddDocument(documentRepresentingProperties(i, value));
                expectedCounts.computeIfAbsent(value, v => new MutableInt(0)).increment();
            }
            _index.maybeRefreshBlocking();

            // when/then
            GatheringNodeValueClient client           = new GatheringNodeValueClient();
            NodePropertyAccessor     propertyAccessor = mock(typeof(NodePropertyAccessor));

            using (IndexReader reader = _index.IndexReader)
            {
                reader.DistinctValues(client, propertyAccessor, true);
                while (client.Progressor.next())
                {
                    Value      value         = client.Values[0];
                    MutableInt expectedCount = expectedCounts.Remove(value);
                    assertNotNull(expectedCount);
                    assertEquals(expectedCount.intValue(), client.Reference);
                }
                assertTrue(expectedCounts.Count == 0);
            }
            verifyNoMoreInteractions(propertyAccessor);
        }
        public override int GetHashCode()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableInt h = new org.apache.commons.lang3.mutable.MutableInt();
            MutableInt h = new MutableInt();

            Each(element => h.add(( int )(element ^ ( int )(( uint )element >> 32))));
            return(h.intValue());
        }
Esempio n. 3
0
            public override int RadixOf(long value)
            {
                long val1 = value & ~LENGTH_BITS;

                val1 = ( long )(( ulong )val1 >> RadixShift.intValue());
                int index = ( int )val1;

                return(index);
            }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseAll()
        public virtual void ShouldCloseAll()
        {
            // given
            InstanceSelector <string> selector = SelectorFilledWithOrdinal();

            // when
            MutableInt count = new MutableInt();

            selector.Close(s => count.increment());

            // then
            assertEquals(Enum.GetValues(typeof(IndexSlot)).length, count.intValue());
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCountDistinctValues()
        public virtual void ShouldCountDistinctValues()
        {
            // given
            Value[]    strings = GenerateRandomStrings();
            DataCursor source  = new DataCursor(AsHitData(strings));
            GatheringNodeValueClient client = new GatheringNodeValueClient();

            // when
            NativeDistinctValuesProgressor <StringIndexKey, NativeIndexValue> progressor = new NativeDistinctValuesProgressor <StringIndexKey, NativeIndexValue>(source, client, new List <RawCursor <Hit <KEY, VALUE>, IOException> >(), _layout, _layout.compareValue);

            client.Initialize(null, progressor, new IndexQuery[0], IndexOrder.NONE, true);
            IDictionary <Value, MutableInt> expectedCounts = AsDistinctCounts(strings);

            // then
            int uniqueValues    = 0;
            int nonUniqueValues = 0;

            while (progressor.Next())
            {
                Value      @string       = client.Values[0];
                MutableInt expectedCount = expectedCounts.Remove(@string);
                assertNotNull(expectedCount);
                assertEquals(expectedCount.intValue(), client.Reference);

                if (expectedCount.intValue() > 1)
                {
                    nonUniqueValues++;
                }
                else
                {
                    uniqueValues++;
                }
            }
            assertTrue(expectedCounts.Count == 0);
            assertTrue(uniqueValues > 0);
            assertTrue(nonUniqueValues > 0);
        }
Esempio n. 6
0
        private void RemoveLock(ResourceType resourceType, long resourceId, bool exclusive)
        {
            LockUnit   lockUnit  = new LockUnit(resourceType, resourceId, exclusive);
            MutableInt lockCount = _locks[lockUnit];

            if (lockCount == null)
            {
                throw new System.InvalidOperationException("Cannot release " + (exclusive ? "exclusive" : "shared") + " lock that it " + "does not hold: " + resourceType + "[" + resourceId + "].");
            }

            lockCount.decrement();

            if (lockCount.intValue() == 0)
            {
                _locks.Remove(lockUnit);
            }
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void stressInstantiationWithClose() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StressInstantiationWithClose()
        {
            // given
            StringFactory factory             = new StringFactory();
            TemporalIndexCache <string> cache = new TemporalIndexCache <string>(factory);
            Race       race = (new Race()).withRandomStartDelays();
            MutableInt instantiatedAtClose = new MutableInt();

            race.AddContestant(() =>
            {
                try
                {
                    cache.UncheckedSelect(_valueGroups[0]);
                    cache.UncheckedSelect(_valueGroups[1]);
                }
                catch (System.InvalidOperationException)
                {
                    // This exception is OK since it may have been closed
                }
            }, 1);
            race.AddContestant(() =>
            {
                cache.CloseInstantiateCloseLock();
                instantiatedAtClose.Value = count(cache);
            }, 1);

            // when
            race.Go();

            // then
            try
            {
                cache.UncheckedSelect(_valueGroups[2]);
                fail("No instantiation after closed");
            }
            catch (System.InvalidOperationException)
            {
                // good
            }
            assertEquals(instantiatedAtClose.intValue(), count(cache));
        }
Esempio n. 8
0
 internal DirectionData(ShortestPath outerInstance, Node startNode, ICollection <long> sharedVisitedRels, MutableInt sharedFrozenDepth, MutableBoolean sharedStop, MutableInt sharedCurrentDepth, PathExpander expander)
 {
     this._outerInstance          = outerInstance;
     this.StartNode               = startNode;
     this.VisitedNodes[startNode] = new LevelData(null, 0);
     this.NextNodes.Add(startNode);
     this.SharedFrozenDepth  = sharedFrozenDepth;
     this.SharedStop         = sharedStop;
     this.SharedCurrentDepth = sharedCurrentDepth;
     this.Expander           = expander;
     this.SharedVisitedRels  = sharedVisitedRels;
     this.LastPath           = new DirectionDataPath(startNode);
     if (sharedCurrentDepth.intValue() < outerInstance.maxDepth)
     {
         PrepareNextLevel();
     }
     else
     {
         this.NextRelationships = Iterators.emptyResourceIterator();
     }
 }
Esempio n. 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSeeEntriesWhenOnlyLowestIsPresent()
        public virtual void ShouldSeeEntriesWhenOnlyLowestIsPresent()
        {
            // given
            long labelId = 0;
            IList <NodeLabelUpdate> labelUpdates = new List <NodeLabelUpdate>();

            labelUpdates.Add(NodeLabelUpdate.labelChanges(0L, new long[] {}, new long[] { labelId }));

            Start(labelUpdates);

            // when
            MutableInt count = new MutableInt();
            AllEntriesLabelScanReader nodeLabelRanges = _store.allNodeLabelRanges();

            nodeLabelRanges.forEach(nlr =>
            {
                foreach (long nodeId in nlr.nodes())
                {
                    count.add(nlr.labels(nodeId).length);
                }
            });
            assertThat(count.intValue(), @is(1));
        }
Esempio n. 10
0
            internal virtual void RadixOverflow(long val)
            {
                long shiftVal = (val & ~RadixCalculator.LENGTH_BITS) >> (RadixCalculator.RADIX_BITS - 1 + RadixShift.intValue());

                if (shiftVal > 0)
                {
                    while (shiftVal > 0)
                    {
                        RadixShift.increment();
                        CompressRadixIndex();
                        shiftVal = shiftVal >> 1;
                    }
                }
            }