Example #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()));
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void fill(String field, org.apache.lucene.index.TermsEnum termsEnum) throws java.io.IOException
            protected internal void fill(string field, TermsEnum termsEnum)
            {
                BytesRef term = null;

                while ((term = termsEnum.next()) != null)
                {
                    insertWithOverflow(new TermStats(field, term, termsEnum.docFreq(), termsEnum.totalTermFreq()));
                }
            }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.apache.lucene.index.Terms getTerms(String value, int frequency) throws java.io.IOException
        private static Terms GetTerms(string value, int frequency)
        {
            TermsEnum termsEnum = mock(typeof(TermsEnum));
            Terms     terms     = mock(typeof(Terms));

            when(terms.GetEnumerator()).thenReturn(termsEnum);
            when(termsEnum.next()).thenReturn(new BytesRef(value.GetBytes())).thenReturn(null);
            when(termsEnum.docFreq()).thenReturn(frequency);
            return(terms);
        }
Example #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) 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());
                        }
                    }
                }
            }
        }
Example #5
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;
            }
        }