Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.storageengine.api.schema.IndexSample sampleIndex() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        public override IndexSample SampleIndex()
        {
            NonUniqueIndexSampler sampler     = new DefaultNonUniqueIndexSampler(_indexSamplingConfig.sampleSizeLimit());
            IndexReader           indexReader = _indexSearcher.IndexReader;

            foreach (LeafReaderContext readerContext in indexReader.leaves())
            {
                try
                {
                    ISet <string> fieldNames = GetFieldNamesToSample(readerContext);
                    foreach (string fieldName in fieldNames)
                    {
                        Terms terms = readerContext.reader().terms(fieldName);
                        if (terms != null)
                        {
                            TermsEnum termsEnum = LuceneDocumentStructure.originalTerms(terms, fieldName);
                            BytesRef  termsRef;
                            while ((termsRef = termsEnum.next()) != null)
                            {
                                sampler.Include(termsRef.utf8ToString(), termsEnum.docFreq());
                                CheckCancellation();
                            }
                        }
                    }
                }
                catch (IOException e)
                {
                    throw new Exception(e);
                }
            }

            return(sampler.Result(indexReader.numDocs()));
        }
Пример #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) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, java.io.IOException
        public override void Verify(NodePropertyAccessor accessor, int[] propKeyIds)
        {
            foreach (string field in AllFields())
            {
                if (LuceneDocumentStructure.useFieldForUniquenessVerification(field))
                {
                    TermsEnum terms = LuceneDocumentStructure.originalTerms(TermsForField(field), field);
                    BytesRef  termsRef;
                    while ((termsRef = terms.next()) != null)
                    {
                        if (terms.docFreq() > 1)
                        {
                            TermQuery query = new TermQuery(new Term(field, termsRef));
                            SearchForDuplicates(query, accessor, propKeyIds, terms.docFreq());
                        }
                    }
                }
            }
        }
Пример #3
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) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, java.io.IOException
        public override void Verify(NodePropertyAccessor accessor, int[] propKeyIds)
        {
            try
            {
                DuplicateCheckingCollector collector = DuplicateCheckingCollector.ForProperties(accessor, propKeyIds);
                IndexSearcher searcher = IndexSearcher();
                foreach (LeafReaderContext leafReaderContext in searcher.IndexReader.leaves())
                {
                    Fields fields = leafReaderContext.reader().fields();
                    foreach (string field in fields)
                    {
                        if (LuceneDocumentStructure.useFieldForUniquenessVerification(field))
                        {
                            TermsEnum terms = LuceneDocumentStructure.originalTerms(fields.terms(field), field);
                            BytesRef  termsRef;
                            while ((termsRef = terms.next()) != null)
                            {
                                if (terms.docFreq() > 1)
                                {
                                    collector.Init(terms.docFreq());
                                    searcher.search(new TermQuery(new Term(field, termsRef)), collector);
                                }
                            }
                        }
                    }
                }
            }
            catch (IOException e)
            {
                Exception cause = e.InnerException;
                if (cause is IndexEntryConflictException)
                {
                    throw ( IndexEntryConflictException )cause;
                }
                throw e;
            }
        }