Search in sources :

Example 11 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.

the class NonUniqueIndexTests method nodeIdsInIndex.

private List<Long> nodeIdsInIndex(int indexId, String value) throws Exception {
    Config config = Config.empty();
    SchemaIndexProvider indexProvider = new LuceneSchemaIndexProvider(fileSystemRule.get(), DirectoryFactory.PERSISTENT, directory.graphDbDir(), NullLogProvider.getInstance(), Config.empty(), OperationalMode.single);
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(config);
    try (IndexAccessor accessor = indexProvider.getOnlineAccessor(indexId, NewIndexDescriptorFactory.forLabel(0, 0), samplingConfig);
        IndexReader reader = accessor.newReader()) {
        return PrimitiveLongCollections.asList(reader.query(IndexQuery.exact(1, value)));
    }
}
Also used : LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Config(org.neo4j.kernel.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) IndexReader(org.neo4j.storageengine.api.schema.IndexReader)

Example 12 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.

the class NonUniqueDatabaseIndexSamplerTest method samplingOfLargeNumericValues.

@Test
public void samplingOfLargeNumericValues() throws Exception {
    try (RAMDirectory dir = new RAMDirectory();
        WritableIndexPartition indexPartition = new WritableIndexPartition(new File("testPartition"), dir, IndexWriterConfigs.standard())) {
        insertDocument(indexPartition, 1, Long.MAX_VALUE);
        insertDocument(indexPartition, 2, Integer.MAX_VALUE);
        indexPartition.maybeRefreshBlocking();
        try (PartitionSearcher searcher = indexPartition.acquireSearcher()) {
            NonUniqueLuceneIndexSampler sampler = new NonUniqueLuceneIndexSampler(searcher.getIndexSearcher(), taskControl.newInstance(), new IndexSamplingConfig(Config.empty()));
            assertEquals(new IndexSample(2, 2, 2), sampler.sampleIndex());
        }
    }
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) IndexSample(org.neo4j.storageengine.api.schema.IndexSample) PartitionSearcher(org.neo4j.kernel.api.impl.index.partition.PartitionSearcher) WritableIndexPartition(org.neo4j.kernel.api.impl.index.partition.WritableIndexPartition) File(java.io.File) RAMDirectory(org.apache.lucene.store.RAMDirectory) Test(org.junit.Test)

Example 13 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.

the class LuceneSchemaIndexProviderTest method shouldFailToInvokePopulatorInReadOnlyMode.

@Test
public void shouldFailToInvokePopulatorInReadOnlyMode() throws Exception {
    Config readOnlyConfig = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.read_only.name(), Settings.TRUE));
    LuceneSchemaIndexProvider readOnlyIndexProvider = getLuceneSchemaIndexProvider(readOnlyConfig, new DirectoryFactory.InMemoryDirectoryFactory(), fs, graphDbDir);
    expectedException.expect(UnsupportedOperationException.class);
    readOnlyIndexProvider.getPopulator(1L, descriptor, new IndexSamplingConfig(readOnlyConfig));
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Config(org.neo4j.kernel.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) DirectoryFactory(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory) Test(org.junit.Test)

Example 14 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatorTest method newPopulator.

private NonUniqueLuceneIndexPopulator newPopulator() throws IOException {
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
    NonUniqueLuceneIndexPopulator populator = new NonUniqueLuceneIndexPopulator(index, samplingConfig);
    populator.create();
    populator.configureSampling(true);
    return populator;
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)

Example 15 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.

the class SimpleIndexPopulatorCompatibility method shouldReportInitialStateAsFailedIfPopulationFailed.

@Test
public void shouldReportInitialStateAsFailedIfPopulationFailed() throws Exception {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.empty());
    IndexPopulator populator = indexProvider.getPopulator(17, descriptor, indexSamplingConfig);
    String failure = "The contrived failure";
    populator.create();
    // WHEN
    populator.markAsFailed(failure);
    // THEN
    assertEquals(FAILED, indexProvider.getInitialState(17, descriptor));
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Test(org.junit.Test)

Aggregations

IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)17 Test (org.junit.Test)9 Config (org.neo4j.kernel.configuration.Config)5 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)4 Before (org.junit.Before)3 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)3 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)3 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)3 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)3 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)3 SchemaStorage (org.neo4j.kernel.impl.store.SchemaStorage)3 File (java.io.File)2 Arrays (java.util.Arrays)2 RAMDirectory (org.apache.lucene.store.RAMDirectory)2 PrimitiveLongCollections (org.neo4j.collection.primitive.PrimitiveLongCollections)2 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Boolean.parseBoolean (java.lang.Boolean.parseBoolean)1