Search in sources :

Example 1 with PropertySchemaType

use of org.neo4j.internal.schema.PropertySchemaType in project neo4j by neo4j.

the class SchemaStore method buildSchemaDescriptor.

private static SchemaDescriptor buildSchemaDescriptor(Map<String, Value> props) throws MalformedSchemaRuleException {
    EntityType entityType = getEntityType(getString(PROP_SCHEMA_DESCRIPTOR_ENTITY_TYPE, props));
    PropertySchemaType propertySchemaType = getPropertySchemaType(getString(PROP_SCHEMA_DESCRIPTOR_PROPERTY_SCHEMA_TYPE, props));
    int[] entityIds = getIntArray(PROP_SCHEMA_DESCRIPTOR_ENTITY_IDS, props);
    int[] propertyIds = getIntArray(PROP_SCHEMA_DESCRIPTOR_PROPERTY_IDS, props);
    return new SchemaDescriptorImplementation(entityType, propertySchemaType, entityIds, propertyIds);
}
Also used : EntityType(org.neo4j.common.EntityType) SchemaDescriptorImplementation(org.neo4j.internal.schema.SchemaDescriptorImplementation) PropertySchemaType(org.neo4j.internal.schema.PropertySchemaType)

Example 2 with PropertySchemaType

use of org.neo4j.internal.schema.PropertySchemaType in project neo4j by neo4j.

the class SchemaStore method schemaDescriptorToMap.

private static void schemaDescriptorToMap(SchemaDescriptor schemaDescriptor, Map<String, Value> map) {
    EntityType entityType = schemaDescriptor.entityType();
    PropertySchemaType propertySchemaType = schemaDescriptor.propertySchemaType();
    int[] entityTokenIds = schemaDescriptor.getEntityTokenIds();
    int[] propertyIds = schemaDescriptor.getPropertyIds();
    putStringProperty(map, PROP_SCHEMA_DESCRIPTOR_ENTITY_TYPE, entityType.name());
    putStringProperty(map, PROP_SCHEMA_DESCRIPTOR_PROPERTY_SCHEMA_TYPE, propertySchemaType.name());
    putIntArrayProperty(map, PROP_SCHEMA_DESCRIPTOR_ENTITY_IDS, entityTokenIds);
    putIntArrayProperty(map, PROP_SCHEMA_DESCRIPTOR_PROPERTY_IDS, propertyIds);
}
Also used : EntityType(org.neo4j.common.EntityType) PropertySchemaType(org.neo4j.internal.schema.PropertySchemaType)

Example 3 with PropertySchemaType

use of org.neo4j.internal.schema.PropertySchemaType in project neo4j by neo4j.

the class NodeChecker method checkIndexVsNodes.

private void checkIndexVsNodes(LongRange range, IndexDescriptor descriptor, boolean lastRange) throws Exception {
    CacheAccess.Client client = context.cacheAccess.client();
    IndexAccessor accessor = context.indexAccessors.accessorFor(descriptor);
    RelationshipCounter.NodeLabelsLookup nodeLabelsLookup = observedCounts.nodeLabelsLookup();
    SchemaDescriptor schema = descriptor.schema();
    PropertySchemaType propertySchemaType = schema.propertySchemaType();
    long[] indexEntityTokenIds = toLongArray(schema.getEntityTokenIds());
    indexEntityTokenIds = sortAndDeduplicate(indexEntityTokenIds);
    try (var cursorContext = new CursorContext(context.pageCacheTracer.createPageCursorTracer(NODE_INDEXES_CHECKER_TAG));
        var allEntriesReader = accessor.newAllEntriesValueReader(range.from(), lastRange ? Long.MAX_VALUE : range.to(), cursorContext)) {
        for (long entityId : allEntriesReader) {
            try {
                boolean entityExists = client.getBooleanFromCache(entityId, CacheSlots.NodeLink.SLOT_IN_USE);
                if (!entityExists) {
                    reporter.forIndexEntry(new IndexEntry(descriptor, context.tokenNameLookup, entityId)).nodeNotInUse(recordLoader.node(entityId, cursorContext));
                } else {
                    long[] entityTokenIds = nodeLabelsLookup.nodeLabels(entityId);
                    compareTwoSortedLongArrays(propertySchemaType, entityTokenIds, indexEntityTokenIds, indexLabel -> reporter.forIndexEntry(new IndexEntry(descriptor, context.tokenNameLookup, entityId)).nodeDoesNotHaveExpectedLabel(recordLoader.node(entityId, cursorContext), indexLabel), storeLabel -> {
                    /*here we're only interested in what the the index has that the store doesn't have*/
                    });
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // OK so apparently the index has a node way outside node highId
                reporter.forIndexEntry(new IndexEntry(descriptor, context.tokenNameLookup, entityId)).nodeNotInUse(recordLoader.node(entityId, cursorContext));
            }
        }
    }
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) CacheAccess(org.neo4j.consistency.checking.cache.CacheAccess) IndexEntry(org.neo4j.consistency.store.synthetic.IndexEntry) CursorContext(org.neo4j.io.pagecache.context.CursorContext) PropertySchemaType(org.neo4j.internal.schema.PropertySchemaType) RelationshipCounter(org.neo4j.internal.recordstorage.RelationshipCounter)

Aggregations

PropertySchemaType (org.neo4j.internal.schema.PropertySchemaType)3 EntityType (org.neo4j.common.EntityType)2 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)1 IndexEntry (org.neo4j.consistency.store.synthetic.IndexEntry)1 RelationshipCounter (org.neo4j.internal.recordstorage.RelationshipCounter)1 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)1 SchemaDescriptorImplementation (org.neo4j.internal.schema.SchemaDescriptorImplementation)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1