Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void verifySearchInvocations(org.neo4j.kernel.api.impl.index.partition.PartitionSearcher searcher, Object... values) throws java.io.IOException
        private static void VerifySearchInvocations(PartitionSearcher searcher, params object[] values)
        {
            foreach (object value in values)
            {
                verify(searcher.IndexSearcher).search(eq(LuceneDocumentStructure.newSeekQuery(Values.of(value))), any(typeof(DuplicateCheckingCollector)));
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void verify(org.neo4j.storageengine.api.NodePropertyAccessor accessor, int[] propKeyIds, java.util.List<org.neo4j.values.storable.Value[]> updatedValueTuples) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, java.io.IOException
        public override void Verify(NodePropertyAccessor accessor, int[] propKeyIds, IList <Value[]> updatedValueTuples)
        {
            foreach (Value[] valueTuple in updatedValueTuples)
            {
                Query query = LuceneDocumentStructure.newSeekQuery(valueTuple);
                SearchForDuplicates(query, accessor, propKeyIds);
            }
        }
Пример #3
0
        public override long CountIndexedNodes(long nodeId, int[] propertyKeyIds, params Value[] propertyValues)
        {
            Query nodeIdQuery = new TermQuery(LuceneDocumentStructure.newTermForChangeOrRemove(nodeId));
            Query valueQuery  = LuceneDocumentStructure.newSeekQuery(propertyValues);

            BooleanQuery.Builder nodeIdAndValueQuery = (new BooleanQuery.Builder()).setDisableCoord(true);
            nodeIdAndValueQuery.add(nodeIdQuery, BooleanClause.Occur.MUST);
            nodeIdAndValueQuery.add(valueQuery, BooleanClause.Occur.MUST);
            try
            {
                TotalHitCountCollector collector = new TotalHitCountCollector();
                IndexSearcher.search(nodeIdAndValueQuery.build(), collector);
                // A <label,propertyKeyId,nodeId> tuple should only match at most a single propertyValue
                return(collector.TotalHits);
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void verify(org.neo4j.storageengine.api.NodePropertyAccessor accessor, int[] propKeyIds, java.util.List<org.neo4j.values.storable.Value[]> updatedValueTuples) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, java.io.IOException
        public override void Verify(NodePropertyAccessor accessor, int[] propKeyIds, IList <Value[]> updatedValueTuples)
        {
            try
            {
                DuplicateCheckingCollector collector = DuplicateCheckingCollector.ForProperties(accessor, propKeyIds);
                foreach (Value[] valueTuple in updatedValueTuples)
                {
                    collector.Init();
                    Query query = LuceneDocumentStructure.newSeekQuery(valueTuple);
                    IndexSearcher().search(query, collector);
                }
            }
            catch (IOException e)
            {
                Exception cause = e.InnerException;
                if (cause is IndexEntryConflictException)
                {
                    throw ( IndexEntryConflictException )cause;
                }
                throw e;
            }
        }
Пример #5
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));
            }
        }
Пример #6
0
 public static Query NewSeekQuery(params object[] objects)
 {
     return(LuceneDocumentStructure.newSeekQuery(Values.values(objects)));
 }