Search in sources :

Example 1 with PropertyKeyTokenHolder

use of org.neo4j.kernel.impl.core.PropertyKeyTokenHolder in project neo4j by neo4j.

the class IndexingServiceIntegrationTest method testSchemaIndexMatchIndexingService.

@Test
public void testSchemaIndexMatchIndexingService() throws IndexNotFoundKernelException {
    try (Transaction transaction = database.beginTx()) {
        database.schema().constraintFor(Label.label(CLOTHES_LABEL)).assertPropertyIsUnique(PROPERTY_NAME).create();
        database.schema().indexFor(Label.label(WEATHER_LABEL)).on(PROPERTY_NAME).create();
        transaction.success();
    }
    try (Transaction transaction = database.beginTx()) {
        database.schema().awaitIndexesOnline(1, TimeUnit.MINUTES);
    }
    IndexingService indexingService = getIndexingService(database);
    LabelTokenHolder labelTokenHolder = getLabelTokenHolder(database);
    PropertyKeyTokenHolder propertyKeyTokenHolder = getPropertyKeyTokenHolder(database);
    int clothedLabelId = labelTokenHolder.getIdByName(CLOTHES_LABEL);
    int weatherLabelId = labelTokenHolder.getIdByName(WEATHER_LABEL);
    int propertyId = propertyKeyTokenHolder.getIdByName(PROPERTY_NAME);
    IndexProxy clothesIndex = indexingService.getIndexProxy(SchemaDescriptorFactory.forLabel(clothedLabelId, propertyId));
    IndexProxy weatherIndex = indexingService.getIndexProxy(SchemaDescriptorFactory.forLabel(weatherLabelId, propertyId));
    assertEquals(InternalIndexState.ONLINE, clothesIndex.getState());
    assertEquals(InternalIndexState.ONLINE, weatherIndex.getState());
}
Also used : Transaction(org.neo4j.graphdb.Transaction) PropertyKeyTokenHolder(org.neo4j.kernel.impl.core.PropertyKeyTokenHolder) LabelTokenHolder(org.neo4j.kernel.impl.core.LabelTokenHolder) Test(org.junit.Test)

Example 2 with PropertyKeyTokenHolder

use of org.neo4j.kernel.impl.core.PropertyKeyTokenHolder in project neo4j by neo4j.

the class IndexingServiceIntegrationTest method testManualIndexPopulation.

@Test
public void testManualIndexPopulation() throws IOException, IndexNotFoundKernelException, InterruptedException {
    IndexingService indexingService = getIndexingService(database);
    SchemaStore schemaStore = getSchemaStore(database);
    LabelTokenHolder labelTokenHolder = getLabelTokenHolder(database);
    PropertyKeyTokenHolder propertyKeyTokenHolder = getPropertyKeyTokenHolder(database);
    int foodId = labelTokenHolder.getIdByName(FOOD_LABEL);
    int propertyId = propertyKeyTokenHolder.getIdByName(PROPERTY_NAME);
    IndexRule rule = IndexRule.indexRule(schemaStore.nextId(), NewIndexDescriptorFactory.forLabel(foodId, propertyId), indexDescriptor);
    indexingService.createIndexes(rule);
    IndexProxy indexProxy = indexingService.getIndexProxy(rule.getId());
    waitIndexOnline(indexProxy);
    assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
    PopulationProgress progress = indexProxy.getIndexPopulationProgress();
    assertEquals(progress.getCompleted(), progress.getTotal());
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) PopulationProgress(org.neo4j.storageengine.api.schema.PopulationProgress) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) PropertyKeyTokenHolder(org.neo4j.kernel.impl.core.PropertyKeyTokenHolder) LabelTokenHolder(org.neo4j.kernel.impl.core.LabelTokenHolder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 LabelTokenHolder (org.neo4j.kernel.impl.core.LabelTokenHolder)2 PropertyKeyTokenHolder (org.neo4j.kernel.impl.core.PropertyKeyTokenHolder)2 Transaction (org.neo4j.graphdb.Transaction)1 SchemaStore (org.neo4j.kernel.impl.store.SchemaStore)1 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)1 PopulationProgress (org.neo4j.storageengine.api.schema.PopulationProgress)1