use of org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatingUpdaterTest method changedNodePropertiesIncludedInSample.
@Test
public void changedNodePropertiesIncludedInSample() throws Exception {
NonUniqueIndexSampler sampler = newSampler();
NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(sampler);
updater.process(add(1, SCHEMA_DESCRIPTOR, "initial1"));
updater.process(add(2, SCHEMA_DESCRIPTOR, "initial2"));
updater.process(add(3, SCHEMA_DESCRIPTOR, "new2"));
updater.process(change(1, SCHEMA_DESCRIPTOR, "initial1", "new1"));
updater.process(change(1, SCHEMA_DESCRIPTOR, "initial2", "new2"));
verifySamplingResult(sampler, 3, 2, 3);
}
use of org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatingUpdaterTest method changedNodeCompositePropertiesIncludedInSample.
@Test
public void changedNodeCompositePropertiesIncludedInSample() throws Exception {
NonUniqueIndexSampler sampler = newSampler();
NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(sampler);
updater.process(add(1, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "initial1"));
updater.process(add(2, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "initial2"));
updater.process(add(3, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "new2"));
updater.process(change(1, COMPOSITE_SCHEMA_DESCRIPTOR, new Object[] { "bit", "initial1" }, new Object[] { "bit", "new1" }));
updater.process(change(1, COMPOSITE_SCHEMA_DESCRIPTOR, new Object[] { "bit", "initial2" }, new Object[] { "bit", "new2" }));
verifySamplingResult(sampler, 3, 2, 3);
}
use of org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatingUpdaterTest method addedNodePropertiesIncludedInSample.
@Test
public void addedNodePropertiesIncludedInSample() throws Exception {
NonUniqueIndexSampler sampler = newSampler();
NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(sampler);
updater.process(add(1, SCHEMA_DESCRIPTOR, "foo"));
updater.process(add(2, SCHEMA_DESCRIPTOR, "bar"));
updater.process(add(3, SCHEMA_DESCRIPTOR, "baz"));
updater.process(add(4, SCHEMA_DESCRIPTOR, "bar"));
verifySamplingResult(sampler, 4, 3, 4);
}
use of org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueLuceneIndexSampler method performSampling.
@Override
protected IndexSample performSampling() throws IndexNotFoundKernelException {
NonUniqueIndexSampler sampler = new DefaultNonUniqueIndexSampler(indexSamplingConfig.sampleSizeLimit());
IndexReader indexReader = indexSearcher.getIndexReader();
for (LeafReaderContext readerContext : indexReader.leaves()) {
try {
Set<String> fieldNames = getFieldNamesToSample(readerContext);
for (String fieldName : 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 RuntimeException(e);
}
}
return sampler.result(indexReader.numDocs());
}
use of org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatingUpdaterTest method nodeCompositePropertyUpdatesIncludedInSample.
@Test
public void nodeCompositePropertyUpdatesIncludedInSample() throws Exception {
NonUniqueIndexSampler sampler = newSampler();
NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(sampler);
updater.process(add(1, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "foo"));
updater.process(change(1, COMPOSITE_SCHEMA_DESCRIPTOR, new Object[] { "bit", "foo" }, new Object[] { "bit", "newFoo1" }));
updater.process(add(2, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "bar"));
updater.process(remove(2, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "bar"));
updater.process(change(1, COMPOSITE_SCHEMA_DESCRIPTOR, new Object[] { "bit", "newFoo1" }, new Object[] { "bit", "newFoo2" }));
updater.process(add(42, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "qux"));
updater.process(add(3, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "bar"));
updater.process(add(4, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "baz"));
updater.process(add(5, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "bar"));
updater.process(remove(42, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "qux"));
verifySamplingResult(sampler, 4, 3, 4);
}
Aggregations