Search in sources :

Example 11 with KernelVersion

use of org.neo4j.kernel.KernelVersion in project neo4j by neo4j.

the class SchemaStorage method streamAllSchemaRules.

@VisibleForTesting
Stream<SchemaRule> streamAllSchemaRules(boolean ignoreMalformed, CursorContext cursorContext) {
    long startId = schemaStore.getNumberOfReservedLowIds();
    long endId = schemaStore.getHighId();
    Stream<IndexDescriptor> nli = Stream.empty();
    KernelVersion currentVersion;
    try {
        currentVersion = versionSupplier.kernelVersion();
    } catch (IllegalStateException ignored) {
        // If KernelVersion is missing we are an older store.
        currentVersion = KernelVersion.V4_2;
    }
    if (currentVersion.isLessThan(KernelVersion.VERSION_IN_WHICH_TOKEN_INDEXES_ARE_INTRODUCED)) {
        nli = Stream.of(IndexDescriptor.INJECTED_NLI);
    }
    return Stream.concat(LongStream.range(startId, endId).mapToObj(id -> schemaStore.getRecord(id, schemaStore.newRecord(), RecordLoad.LENIENT_ALWAYS, cursorContext)).filter(AbstractBaseRecord::inUse).flatMap(record -> readSchemaRuleThrowingRuntimeException(record, ignoreMalformed, cursorContext)), nli);
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) SchemaRule(org.neo4j.internal.schema.SchemaRule) CursorContext(org.neo4j.io.pagecache.context.CursorContext) KernelVersion(org.neo4j.kernel.KernelVersion) Value(org.neo4j.values.storable.Value) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) ArrayList(java.util.ArrayList) Values(org.neo4j.values.storable.Values) IntObjectMap(org.eclipse.collections.api.map.primitive.IntObjectMap) KernelVersionRepository(org.neo4j.storageengine.api.KernelVersionRepository) IntObjectProcedure(org.eclipse.collections.api.block.procedure.primitive.IntObjectProcedure) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) VisibleForTesting(org.neo4j.util.VisibleForTesting) MalformedSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRuleNotFoundException(org.neo4j.internal.kernel.api.exceptions.schema.SchemaRuleNotFoundException) MemoryTracker(org.neo4j.memory.MemoryTracker) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Record(org.neo4j.kernel.impl.store.record.Record) LongStream(java.util.stream.LongStream) Iterator(java.util.Iterator) Collection(java.util.Collection) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) DuplicateSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.DuplicateSchemaRuleException) Stream(java.util.stream.Stream) KernelException(org.neo4j.exceptions.KernelException) TokenHolders(org.neo4j.token.TokenHolders) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) SchemaDescriptorSupplier(org.neo4j.internal.schema.SchemaDescriptorSupplier) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) IndexRef(org.neo4j.internal.schema.IndexRef) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Example 12 with KernelVersion

use of org.neo4j.kernel.KernelVersion in project neo4j by neo4j.

the class VersionAwareLogEntryReaderTest method shouldReadACommandLogEntry.

@Test
void shouldReadACommandLogEntry() throws IOException {
    // given
    KernelVersion version = LATEST;
    TestCommand testCommand = new TestCommand(new byte[] { 100, 101, 102 });
    final LogEntryCommand command = new LogEntryCommand(version, testCommand);
    final InMemoryClosableChannel channel = new InMemoryClosableChannel(true);
    channel.put(version.version());
    channel.put(LogEntryTypeCodes.COMMAND);
    testCommand.serialize(channel);
    // when
    final LogEntry logEntry = logEntryReader.readLogEntry(channel);
    // then
    assertEquals(command, logEntry);
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) TestCommand(org.neo4j.kernel.impl.api.TestCommand) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Aggregations

KernelVersion (org.neo4j.kernel.KernelVersion)12 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 IOException (java.io.IOException)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)2 StoreId (org.neo4j.storageengine.api.StoreId)2 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Instant (java.time.Instant)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 UUID.randomUUID (java.util.UUID.randomUUID)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Consumer (java.util.function.Consumer)1 LongStream (java.util.stream.LongStream)1 Stream (java.util.stream.Stream)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 ExceptionUtils.getRootCause (org.apache.commons.lang3.exception.ExceptionUtils.getRootCause)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1