Search in sources :

Example 1 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class RecordStorageReaderSchemaTest method shouldListAllIndexesForRelationshipTypeAtTimeOfSnapshot.

@Test
void shouldListAllIndexesForRelationshipTypeAtTimeOfSnapshot() throws Exception {
    // Given
    IndexDescriptor expectedIndex = createIndex(relType1, propertyKey);
    createIndex(relType2, propertyKey);
    // When
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    Set<IndexDescriptor> indexes = asSet(snapshot.indexesGetForRelationshipType(relationshipTypeId(relType1)));
    // Then
    assertEquals(asSet(expectedIndex), indexes);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class RecordStorageReaderSchemaTest method shouldListAllConstraintsForLabelAtTimeOfSnapshot.

@Test
void shouldListAllConstraintsForLabelAtTimeOfSnapshot() throws Exception {
    // Given
    createUniquenessConstraint(label1, propertyKey);
    createUniquenessConstraint(label2, propertyKey);
    // When
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    createUniquenessConstraint(label1, otherPropertyKey);
    Set<ConstraintDescriptor> constraints = asSet(snapshot.constraintsGetForLabel(labelId(label1)));
    // Then
    Set<ConstraintDescriptor> expectedConstraints = asSet(uniqueConstraintDescriptor(label1, propertyKey));
    assertEquals(expectedConstraints, constraints);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class AllStoreHolder method snapshot.

@Override
public SchemaReadCore snapshot() {
    ktx.assertOpen();
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    return new SchemaReadCoreSnapshot(snapshot, ktx, this);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader)

Example 4 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class AllStoreHolder method indexGetForName.

IndexDescriptor indexGetForName(StorageSchemaReader reader, String name) {
    ktx.assertOpen();
    IndexDescriptor index = reader.indexGetForName(name);
    if (ktx.hasTxStateWithChanges()) {
        Predicate<IndexDescriptor> namePredicate = indexDescriptor -> indexDescriptor.getName().equals(name);
        Iterator<IndexDescriptor> indexes = ktx.txState().indexChanges().filterAdded(namePredicate).apply(Iterators.iterator(index));
        index = singleOrNull(indexes);
    }
    return lockIndex(index);
}
Also used : ValueIndexReader(org.neo4j.kernel.api.index.ValueIndexReader) CursorContext(org.neo4j.io.pagecache.context.CursorContext) EMPTY(org.neo4j.storageengine.api.txstate.TxStateVisitor.EMPTY) ResourceTypes(org.neo4j.lock.ResourceTypes) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Value(org.neo4j.values.storable.Value) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Statement(org.neo4j.kernel.api.Statement) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) AdminAccessMode(org.neo4j.internal.kernel.api.security.AdminAccessMode) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) Predicates.alwaysTrue(org.neo4j.function.Predicates.alwaysTrue) PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Dependencies(org.neo4j.collection.Dependencies) Predicate(java.util.function.Predicate) Set(java.util.Set) String.format(java.lang.String.format) UserFunctionHandle(org.neo4j.internal.kernel.api.procs.UserFunctionHandle) Objects(java.util.Objects) AccessMode(org.neo4j.internal.kernel.api.security.AccessMode) IndexQueryConstraints.unconstrained(org.neo4j.internal.kernel.api.IndexQueryConstraints.unconstrained) Stream(java.util.stream.Stream) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) EntityType(org.neo4j.common.EntityType) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) CountsDelta(org.neo4j.storageengine.api.CountsDelta) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) AnyValue(org.neo4j.values.AnyValue) RawIterator(org.neo4j.collection.RawIterator) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) RestrictedAccessMode(org.neo4j.kernel.impl.api.security.RestrictedAccessMode) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Function(java.util.function.Function) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) Iterators.singleOrNull(org.neo4j.internal.helpers.collection.Iterators.singleOrNull) DefaultValueMapper(org.neo4j.kernel.impl.util.DefaultValueMapper) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexReaderCache(org.neo4j.kernel.impl.api.IndexReaderCache) UserAggregator(org.neo4j.internal.kernel.api.procs.UserAggregator) StorageReader(org.neo4j.storageengine.api.StorageReader) MemoryTracker(org.neo4j.memory.MemoryTracker) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexSample(org.neo4j.kernel.api.index.IndexSample) Iterator(java.util.Iterator) Iterators(org.neo4j.internal.helpers.collection.Iterators) DiffSets(org.neo4j.storageengine.api.txstate.DiffSets) OverriddenAccessMode(org.neo4j.kernel.impl.api.security.OverriddenAccessMode) BasicContext.buildContext(org.neo4j.kernel.api.procedure.BasicContext.buildContext) TransactionState(org.neo4j.kernel.api.txstate.TransactionState) Context(org.neo4j.kernel.api.procedure.Context) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) KernelException(org.neo4j.exceptions.KernelException) TransactionCountingStateVisitor(org.neo4j.storageengine.api.txstate.TransactionCountingStateVisitor) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) TokenIndexReader(org.neo4j.kernel.api.index.TokenIndexReader) StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) SchemaState(org.neo4j.internal.schema.SchemaState) Collections(java.util.Collections) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 5 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class AllStoreHolder method constraintGetForName.

ConstraintDescriptor constraintGetForName(StorageSchemaReader reader, String name) {
    ktx.assertOpen();
    ConstraintDescriptor constraint = reader.constraintGetForName(name);
    if (ktx.hasTxStateWithChanges()) {
        Predicate<ConstraintDescriptor> namePredicate = constraintDescriptor -> constraintDescriptor.getName().equals(name);
        Iterator<ConstraintDescriptor> constraints = ktx.txState().constraintsChanges().filterAdded(namePredicate).apply(Iterators.iterator(constraint));
        constraint = singleOrNull(constraints);
    }
    return lockConstraint(constraint);
}
Also used : ValueIndexReader(org.neo4j.kernel.api.index.ValueIndexReader) CursorContext(org.neo4j.io.pagecache.context.CursorContext) EMPTY(org.neo4j.storageengine.api.txstate.TxStateVisitor.EMPTY) ResourceTypes(org.neo4j.lock.ResourceTypes) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Value(org.neo4j.values.storable.Value) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Statement(org.neo4j.kernel.api.Statement) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) AdminAccessMode(org.neo4j.internal.kernel.api.security.AdminAccessMode) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) Predicates.alwaysTrue(org.neo4j.function.Predicates.alwaysTrue) PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Dependencies(org.neo4j.collection.Dependencies) Predicate(java.util.function.Predicate) Set(java.util.Set) String.format(java.lang.String.format) UserFunctionHandle(org.neo4j.internal.kernel.api.procs.UserFunctionHandle) Objects(java.util.Objects) AccessMode(org.neo4j.internal.kernel.api.security.AccessMode) IndexQueryConstraints.unconstrained(org.neo4j.internal.kernel.api.IndexQueryConstraints.unconstrained) Stream(java.util.stream.Stream) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) EntityType(org.neo4j.common.EntityType) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) CountsDelta(org.neo4j.storageengine.api.CountsDelta) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) AnyValue(org.neo4j.values.AnyValue) RawIterator(org.neo4j.collection.RawIterator) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) RestrictedAccessMode(org.neo4j.kernel.impl.api.security.RestrictedAccessMode) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Function(java.util.function.Function) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) Iterators.singleOrNull(org.neo4j.internal.helpers.collection.Iterators.singleOrNull) DefaultValueMapper(org.neo4j.kernel.impl.util.DefaultValueMapper) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexReaderCache(org.neo4j.kernel.impl.api.IndexReaderCache) UserAggregator(org.neo4j.internal.kernel.api.procs.UserAggregator) StorageReader(org.neo4j.storageengine.api.StorageReader) MemoryTracker(org.neo4j.memory.MemoryTracker) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexSample(org.neo4j.kernel.api.index.IndexSample) Iterator(java.util.Iterator) Iterators(org.neo4j.internal.helpers.collection.Iterators) DiffSets(org.neo4j.storageengine.api.txstate.DiffSets) OverriddenAccessMode(org.neo4j.kernel.impl.api.security.OverriddenAccessMode) BasicContext.buildContext(org.neo4j.kernel.api.procedure.BasicContext.buildContext) TransactionState(org.neo4j.kernel.api.txstate.TransactionState) Context(org.neo4j.kernel.api.procedure.Context) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) KernelException(org.neo4j.exceptions.KernelException) TransactionCountingStateVisitor(org.neo4j.storageengine.api.txstate.TransactionCountingStateVisitor) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) TokenIndexReader(org.neo4j.kernel.api.index.TokenIndexReader) StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) SchemaState(org.neo4j.internal.schema.SchemaState) Collections(java.util.Collections) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor)

Aggregations

StorageSchemaReader (org.neo4j.storageengine.api.StorageSchemaReader)8 Test (org.junit.jupiter.api.Test)5 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 String.format (java.lang.String.format)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Function (java.util.function.Function)2 Predicate (java.util.function.Predicate)2 Stream (java.util.stream.Stream)2 Dependencies (org.neo4j.collection.Dependencies)2 RawIterator (org.neo4j.collection.RawIterator)2 EntityType (org.neo4j.common.EntityType)2 Config (org.neo4j.configuration.Config)2 KernelException (org.neo4j.exceptions.KernelException)2 Predicates.alwaysTrue (org.neo4j.function.Predicates.alwaysTrue)2 Iterators (org.neo4j.internal.helpers.collection.Iterators)2 Iterators.singleOrNull (org.neo4j.internal.helpers.collection.Iterators.singleOrNull)2