示例#1
0
        public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, NodePropertyAccessor propertyAccessor, bool needsValues)
        {
            BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);

            cursor.Initialize(_descriptor, multiProgressor, new IndexQuery[0], IndexOrder.NONE, needsValues);
            InstanceSelector.forAll(reader => reader.distinctValues(multiProgressor, propertyAccessor, needsValues));
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void verifyDeferredConstraints(org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void VerifyDeferredConstraints(NodePropertyAccessor nodePropertyAccessor)
        {
            foreach (IndexSlot slot in Enum.GetValues(typeof(IndexSlot)))
            {
                InstanceSelector.select(slot).verifyDeferredConstraints(nodePropertyAccessor);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.collection.PrimitiveLongResourceIterator query(org.neo4j.internal.kernel.api.IndexQuery... predicates) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
        public override PrimitiveLongResourceIterator Query(params IndexQuery[] predicates)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IndexSlot slot = SlotSelector.selectSlot(predicates, IndexQuery::valueGroup);

            return(slot != null?InstanceSelector.select(slot).query(predicates) : concat(InstanceSelector.transform(reader => reader.query(predicates))));
        }
示例#4
0
        public override BoundedIterable <long> NewAllEntriesReader()
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IEnumerable <BoundedIterable <long> > entries = InstanceSelector.transform(IndexAccessor::newAllEntriesReader);

            return(new BoundedIterableAnonymousInnerClass(this, entries));
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void verifyDeferredConstraints(org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void VerifyDeferredConstraints(NodePropertyAccessor nodePropertyAccessor)
        {
            // Manual loop due do multiple exception types
            foreach (IndexSlot slot in Enum.GetValues(typeof(IndexSlot)))
            {
                InstanceSelector.select(slot).verifyDeferredConstraints(nodePropertyAccessor);
            }
        }
示例#6
0
        public override IDictionary <string, Value> IndexConfig()
        {
            IDictionary <string, Value> indexConfig = new Dictionary <string, Value>();

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            InstanceSelector.transform(IndexAccessor::indexConfig).forEach(source => IndexConfigProvider.putAllNoOverwrite(indexConfig, source));
            return(indexConfig);
        }
示例#7
0
 public FusionIndexProvider(IndexProvider stringProvider, IndexProvider numberProvider, IndexProvider spatialProvider, IndexProvider temporalProvider, IndexProvider luceneProvider, SlotSelector slotSelector, IndexProviderDescriptor descriptor, IndexDirectoryStructure.Factory directoryStructure, FileSystemAbstraction fs, bool archiveFailedIndex) : base(descriptor, directoryStructure)
 {
     this._archiveFailedIndex = archiveFailedIndex;
     this._slotSelector       = slotSelector;
     this._providers          = new InstanceSelector <IndexProvider>();
     this._dropAction         = new FileSystemIndexDropAction(fs, directoryStructure());
     FillProvidersSelector(stringProvider, numberProvider, spatialProvider, temporalProvider, luceneProvider);
     slotSelector.ValidateSatisfied(_providers);
 }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") @Test public void shouldNotThrowOnNonInstantiatedClose()
        public virtual void ShouldNotThrowOnNonInstantiatedClose()
        {
            // given
            InstanceSelector <string> selector = selector(NUMBER, "0");

            // when
            selector.Close(int?.parseInt);

            // then
            // good
        }
示例#9
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());
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMap()
        public virtual void ShouldMap()
        {
            // given
            InstanceSelector <string> selector = SelectorFilledWithOrdinal();

            // when
            Dictionary <IndexSlot, int> actual = selector.Map(int?.parseInt);

            // then
            foreach (IndexSlot slot in Enum.GetValues(typeof(IndexSlot)))
            {
                assertEquals(( int )slot, actual[slot]);
            }
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void throwIfToFewInstances()
        internal virtual void ThrowIfToFewInstances()
        {
            // given
            Dictionary <IndexSlot, IndexProvider> instances = new Dictionary <IndexSlot, IndexProvider>(typeof(IndexSlot));

            foreach (IndexSlot indexSlot in Enum.GetValues(typeof(IndexSlot)))
            {
                instances[indexSlot] = IndexProvider.EMPTY;
            }
            InstanceSelector <IndexProvider> instanceSelector = new InstanceSelector <IndexProvider>(instances);

            // when, then
            assertThrows(typeof(System.ArgumentException), () => validateSelectorInstances(instanceSelector, NUMBER));
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFlatMap()
        public virtual void ShouldFlatMap()
        {
            // given
            InstanceSelector <string> selector = SelectorFilledWithOrdinal();

            // when
            IList <int> actual   = Iterables.asList(selector.Transform(int?.parseInt));
            IList <int> expected = java.util.Enum.GetValues(typeof(IndexSlot)).Select(Enum.ordinal).ToList();

            // then
            assertEquals(expected.Count, actual.Count);
            foreach (int?i in expected)
            {
                assertTrue(actual.Contains(i));
            }
        }
示例#13
0
        private void SetupMocks()
        {
            IndexSlot[] aliveSlots = FusionVersion.aliveSlots();
            _aliveProviders = new IndexProvider[aliveSlots.Length];
            _providers      = new Dictionary <IndexSlot, IndexProvider>(typeof(IndexSlot));
            fill(_providers, IndexProvider.EMPTY);
            for (int i = 0; i < aliveSlots.Length; i++)
            {
                switch (aliveSlots[i])
                {
                case STRING:
                    IndexProvider @string = MockProvider(typeof(StringIndexProvider), "string");
                    _providers[STRING] = @string;
                    _aliveProviders[i] = @string;
                    break;

                case NUMBER:
                    IndexProvider number = MockProvider(typeof(NumberIndexProvider), "number");
                    _providers[NUMBER] = number;
                    _aliveProviders[i] = number;
                    break;

                case SPATIAL:
                    IndexProvider spatial = MockProvider(typeof(SpatialIndexProvider), "spatial");
                    _providers[SPATIAL] = spatial;
                    _aliveProviders[i]  = spatial;
                    break;

                case TEMPORAL:
                    IndexProvider temporal = MockProvider(typeof(TemporalIndexProvider), "temporal");
                    _providers[TEMPORAL] = temporal;
                    _aliveProviders[i]   = temporal;
                    break;

                case LUCENE:
                    IndexProvider lucene = MockProvider(typeof(IndexProvider), "lucene");
                    _providers[LUCENE] = lucene;
                    _aliveProviders[i] = lucene;
                    break;

                default:
                    throw new Exception();
                }
            }
            _fusionIndexProvider = new FusionIndexProvider(_providers[STRING], _providers[NUMBER], _providers[SPATIAL], _providers[TEMPORAL], _providers[LUCENE], FusionVersion.slotSelector(), _descriptor, NONE, mock(typeof(FileSystemAbstraction)), false);
            _instanceSelector    = new InstanceSelector <IndexProvider>(_providers);
        }
示例#14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOnNonInstantiatedSelect()
        public virtual void ShouldThrowOnNonInstantiatedSelect()
        {
            // given
            InstanceSelector <string> selector = selector(NUMBER, "0");

            try
            {
                // when
                selector.Select(STRING);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException)
            {
                // then
                // good
            }
        }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOnNonInstantiatedFlatMap()
        public virtual void ShouldThrowOnNonInstantiatedFlatMap()
        {
            // given
            InstanceSelector <string> selector = selector(NUMBER, "0");

            // when
            try
            {
                selector.Transform(int?.parseInt);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException)
            {
                // then
                // good
            }
        }
示例#16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSelect()
        public virtual void ShouldSelect()
        {
            // given
            InstanceSelector <string> selector = selector(NUMBER, "0", STRING, "1");

            // when
            string select0 = selector.Select(NUMBER);

            // then
            assertEquals("0", select0);

            // when
            string select1 = selector.Select(STRING);

            // then
            assertEquals("1", select1);
        }
示例#17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldValidateSelectorInstances()
        internal virtual void ShouldValidateSelectorInstances()
        {
            // given
            Dictionary <IndexSlot, IndexProvider> instances = new Dictionary <IndexSlot, IndexProvider>(typeof(IndexSlot));

            foreach (IndexSlot indexSlot in Enum.GetValues(typeof(IndexSlot)))
            {
                instances[indexSlot] = IndexProvider.EMPTY;
            }
            IndexProvider mockedIndxProvider = mock(typeof(IndexProvider));

            instances[NUMBER] = mockedIndxProvider;
            InstanceSelector <IndexProvider> selector = new InstanceSelector <IndexProvider>(instances);

            // when
            validateSelectorInstances(selector, NUMBER);

            // then this should be fine
        }
示例#18
0
        public override bool HasFullValuePrecision(params IndexQuery[] predicates)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IndexSlot slot = SlotSelector.selectSlot(predicates, IndexQuery::valueGroup);

            if (slot != null)
            {
                return(InstanceSelector.select(slot).hasFullValuePrecision(predicates));
            }
            else
            {
                // UNKNOWN slot which basically means the EXISTS predicate
                if (!(predicates.Length == 1 && predicates[0] is IndexQuery.ExistsPredicate))
                {
                    throw new System.InvalidOperationException("Selected IndexReader null for predicates " + Arrays.ToString(predicates));
                }
                return(true);
            }
        }
示例#19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void query(org.neo4j.storageengine.api.schema.IndexProgressor_NodeValueClient cursor, org.neo4j.internal.kernel.api.IndexOrder indexOrder, boolean needsValues, org.neo4j.internal.kernel.api.IndexQuery... predicates) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
        public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexOrder indexOrder, bool needsValues, params IndexQuery[] predicates)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IndexSlot slot = SlotSelector.selectSlot(predicates, IndexQuery::valueGroup);

            if (slot != null)
            {
                InstanceSelector.select(slot).query(cursor, indexOrder, needsValues, predicates);
            }
            else
            {
                if (indexOrder != IndexOrder.NONE)
                {
                    throw new System.NotSupportedException(format("Tried to query index with unsupported order %s. Supported orders for query %s are %s.", indexOrder, Arrays.ToString(predicates), IndexOrder.NONE));
                }
                BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);
                cursor.Initialize(_descriptor, multiProgressor, predicates, indexOrder, needsValues);
                try
                {
                    InstanceSelector.forAll(reader =>
                    {
                        try
                        {
                            reader.query(multiProgressor, indexOrder, needsValues, predicates);
                        }
                        catch (IndexNotApplicableKernelException e)
                        {
                            throw new InnerException(e);
                        }
                    });
                }
                catch (InnerException e)
                {
                    throw e.InnerException;
                }
            }
        }
示例#20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void close() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Close()
        {
            AtomicReference <IndexEntryConflictException> chainedExceptions = new AtomicReference <IndexEntryConflictException>();

            InstanceSelector.close(indexUpdater =>
            {
                try
                {
                    indexUpdater.close();
                }
                catch (IndexEntryConflictException e)
                {
                    if (!chainedExceptions.compareAndSet(null, e))
                    {
                        chainedExceptions.get().addSuppressed(e);
                    }
                }
            });

            if (chainedExceptions.get() != null)
            {
                throw chainedExceptions.get();
            }
        }
示例#21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            switch (update.UpdateMode())
            {
            case ADDED:
                InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf)).process(update);
                break;

            case CHANGED:
                // Hmm, here's a little conundrum. What if we change from a value that goes into native
                // to a value that goes into fallback, or vice versa? We also don't want to blindly pass
                // all CHANGED updates to both updaters since not all values will work in them.
                IndexUpdater from = InstanceSelector.select(SlotSelector.selectSlot(update.BeforeValues(), GroupOf));
                IndexUpdater to   = InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf));
                // There are two cases:
                // - both before/after go into the same updater --> pass update into that updater
                if (from == to)
                {
                    from.Process(update);
                }
                // - before go into one and after into the other --> REMOVED from one and ADDED into the other
                else
                {
                    from.Process(IndexEntryUpdate.remove(update.EntityId, update.IndexKey(), update.BeforeValues()));
                    to.Process(IndexEntryUpdate.add(update.EntityId, update.IndexKey(), update.Values()));
                }
                break;

            case REMOVED:
                InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf)).process(update);
                break;

            default:
                throw new System.ArgumentException("Unknown update mode");
            }
        }
示例#22
0
 public override void Force(IOLimiter ioLimiter)
 {
     InstanceSelector.forAll(accessor => accessor.force(ioLimiter));
 }
示例#23
0
        public override IndexSampler CreateSampler()
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            return(new FusionIndexSampler(InstanceSelector.transform(IndexReader::createSampler)));
        }
示例#24
0
 public override long CountIndexedNodes(long nodeId, int[] propertyKeyIds, params Value[] propertyValues)
 {
     return(InstanceSelector.select(SlotSelector.selectSlot(propertyValues, GroupOf)).countIndexedNodes(nodeId, propertyKeyIds, propertyValues));
 }
示例#25
0
 public override void Close()
 {
     InstanceSelector.close(Resource.close);
 }
示例#26
0
 public override void Refresh()
 {
     InstanceSelector.forAll(IndexAccessor.refresh);
 }
示例#27
0
 public override void ValidateSatisfied(InstanceSelector <IndexProvider> instances)
 {
     SlotSelector.validateSelectorInstances(instances, NUMBER, LUCENE, SPATIAL, TEMPORAL);
 }
示例#28
0
 public override void Close()
 {
     InstanceSelector.close(IndexAccessor.close);
 }
示例#29
0
 public override void ValidateSatisfied(InstanceSelector <IndexProvider> instances)
 {           // no-op
 }
示例#30
0
        public override IndexReader NewReader()
        {
            LazyInstanceSelector <IndexReader> readerSelector = new LazyInstanceSelector <IndexReader>(slot => InstanceSelector.select(slot).newReader());

            return(new FusionIndexReader(SlotSelector, readerSelector, _descriptor));
        }