Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustSelectStringForStringContainsPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustSelectStringForStringContainsPredicate()
        {
            // given
            IndexQuery.StringContainsPredicate stringContains = IndexQuery.stringContains(PROP_KEY, stringValue("abc"));

            // then
            VerifyQueryWithCorrectReader(ExpectedForStrings(), stringContains);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByContainsWhenThereArePartiallyMatchingNewNodes()
            internal virtual void ShouldComputeIndexUpdatesForRangeSeekByContainsWhenThereArePartiallyMatchingNewNodes()
            {
                // GIVEN
                ReadableTransactionState state = (new TxStateBuilder()).WithAdded(40L, "Aaron").withAdded(41L, "Agatha").withAdded(42L, "Andreas").withAdded(43L, "Andrea").withAdded(44L, "Aristotle").withAdded(45L, "Barbara").withAdded(46L, "Barbarella").withAdded(47L, "Cinderella").build();

                // WHEN
                IndexQuery.StringContainsPredicate indexQuery = IndexQuery.stringContains(outerInstance.index.Schema().PropertyId, stringValue("arbar"));
                AddedAndRemoved           changes             = indexUpdatesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE);
                AddedWithValuesAndRemoved changesWithValues   = indexUpdatesWithValuesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE);

                // THEN
                outerInstance.AssertContains(changes.Added, 45L, 46L);
                outerInstance.AssertContains(changesWithValues.Added, NodeWithPropertyValues(45L, "Barbara"), NodeWithPropertyValues(46L, "Barbarella"));
            }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForRangeSeekByContainsWhenThereAreNoMatchingNodes()
            internal virtual void ShouldComputeIndexUpdatesForRangeSeekByContainsWhenThereAreNoMatchingNodes()
            {
                // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build();
                ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "foo").withAdded(43L, "bar").build();

                // WHEN
                IndexQuery.StringContainsPredicate indexQuery = IndexQuery.stringContains(outerInstance.index.Schema().PropertyId, stringValue("eulav"));
                AddedAndRemoved           changes             = indexUpdatesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE);
                AddedWithValuesAndRemoved changesWithValues   = indexUpdatesWithValuesForSuffixOrContains(state, outerInstance.index, indexQuery, IndexOrder.NONE);

                // THEN
                assertTrue(changes.Added.Empty);
                assertFalse(changesWithValues.Added.GetEnumerator().hasNext());
            }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.apache.lucene.search.Query toLuceneQuery(org.neo4j.internal.kernel.api.IndexQuery... predicates) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
        private Query ToLuceneQuery(params IndexQuery[] predicates)
        {
            IndexQuery predicate = predicates[0];

            switch (predicate.Type())
            {
            case exact:
                Value[] values = new Value[predicates.Length];
                for (int i = 0; i < predicates.Length; i++)
                {
                    Debug.Assert(predicates[i].Type() == exact, "Exact followed by another query predicate type is not supported at this moment.");
                    values[i] = ((IndexQuery.ExactPredicate)predicates[i]).value();
                }
                return(LuceneDocumentStructure.newSeekQuery(values));

            case exists:
                foreach (IndexQuery p in predicates)
                {
                    if (p.Type() != IndexQuery.IndexQueryType.exists)
                    {
                        throw new IndexNotApplicableKernelException("Exists followed by another query predicate type is not supported.");
                    }
                }
                return(LuceneDocumentStructure.newScanQuery());

            case range:
                AssertNotComposite(predicates);
                switch (predicate.ValueGroup())
                {
                case NUMBER:
                    IndexQuery.NumberRangePredicate np = (IndexQuery.NumberRangePredicate)predicate;
                    return(LuceneDocumentStructure.newInclusiveNumericRangeSeekQuery(np.From(), np.To()));

                case TEXT:
                    IndexQuery.TextRangePredicate sp = (IndexQuery.TextRangePredicate)predicate;
                    return(LuceneDocumentStructure.newRangeSeekByStringQuery(sp.From(), sp.FromInclusive(), sp.To(), sp.ToInclusive()));

                default:
                    throw new System.NotSupportedException(format("Range scans of value group %s are not supported", predicate.ValueGroup()));
                }

            case stringPrefix:
                AssertNotComposite(predicates);
                IndexQuery.StringPrefixPredicate spp = (IndexQuery.StringPrefixPredicate)predicate;
                return(LuceneDocumentStructure.newRangeSeekByPrefixQuery(spp.Prefix().stringValue()));

            case stringContains:
                AssertNotComposite(predicates);
                IndexQuery.StringContainsPredicate scp = (IndexQuery.StringContainsPredicate)predicate;
                return(LuceneDocumentStructure.newWildCardStringQuery(scp.Contains().stringValue()));

            case stringSuffix:
                AssertNotComposite(predicates);
                IndexQuery.StringSuffixPredicate ssp = (IndexQuery.StringSuffixPredicate)predicate;
                return(LuceneDocumentStructure.newSuffixStringQuery(ssp.Suffix().stringValue()));

            default:
                // todo figure out a more specific exception
                throw new Exception("Index query not supported: " + Arrays.ToString(predicates));
            }
        }