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)));
}
}
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());
}
}
}
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));
}
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;
}
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));
}
Aggregations