Search in sources :

Example 1 with DynamicStringStore

use of org.neo4j.kernel.impl.store.DynamicStringStore in project neo4j by neo4j.

the class MockedNeoStores method basicMockedNeoStores.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static NeoStores basicMockedNeoStores() {
    NeoStores neoStores = mock(NeoStores.class);
    // Cursor, absolutely mocked and cannot be used at all as it is
    RecordCursor cursor = mockedRecordCursor();
    // NodeStore - DynamicLabelStore
    NodeStore nodeStore = mock(NodeStore.class);
    when(nodeStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    // NodeStore - DynamicLabelStore
    DynamicArrayStore dynamicLabelStore = mock(DynamicArrayStore.class);
    when(dynamicLabelStore.newRecordCursor(any())).thenReturn(cursor);
    when(nodeStore.getDynamicLabelStore()).thenReturn(dynamicLabelStore);
    // RelationshipStore
    RelationshipStore relationshipStore = mock(RelationshipStore.class);
    when(relationshipStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
    // RelationshipGroupStore
    RelationshipGroupStore relationshipGroupStore = mock(RelationshipGroupStore.class);
    when(relationshipGroupStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipGroupStore()).thenReturn(relationshipGroupStore);
    // PropertyStore
    PropertyStore propertyStore = mock(PropertyStore.class);
    when(propertyStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    // PropertyStore -- DynamicStringStore
    DynamicStringStore propertyStringStore = mock(DynamicStringStore.class);
    when(propertyStringStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getStringStore()).thenReturn(propertyStringStore);
    // PropertyStore -- DynamicArrayStore
    DynamicArrayStore propertyArrayStore = mock(DynamicArrayStore.class);
    when(propertyArrayStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getArrayStore()).thenReturn(propertyArrayStore);
    return neoStores;
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) NodeStore(org.neo4j.kernel.impl.store.NodeStore) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Example 2 with DynamicStringStore

use of org.neo4j.kernel.impl.store.DynamicStringStore in project neo4j by neo4j.

the class StorePropertyCursorTest method newStorePropertyCursor.

private static StorePropertyCursor newStorePropertyCursor(PropertyStore propertyStore, Consumer<StorePropertyCursor> cache) {
    RecordCursor<PropertyRecord> propertyRecordCursor = propertyStore.newRecordCursor(propertyStore.newRecord());
    propertyRecordCursor.acquire(0, NORMAL);
    DynamicStringStore stringStore = propertyStore.getStringStore();
    RecordCursor<DynamicRecord> dynamicStringCursor = stringStore.newRecordCursor(stringStore.nextRecord());
    dynamicStringCursor.acquire(0, NORMAL);
    DynamicArrayStore arrayStore = propertyStore.getArrayStore();
    RecordCursor<DynamicRecord> dynamicArrayCursor = arrayStore.newRecordCursor(arrayStore.nextRecord());
    dynamicArrayCursor.acquire(0, NORMAL);
    RecordCursors cursors = mock(RecordCursors.class);
    when(cursors.property()).thenReturn(propertyRecordCursor);
    when(cursors.propertyString()).thenReturn(dynamicStringCursor);
    when(cursors.propertyArray()).thenReturn(dynamicArrayCursor);
    return new StorePropertyCursor(cursors, cache);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) RecordCursors(org.neo4j.kernel.impl.store.RecordCursors) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore)

Example 3 with DynamicStringStore

use of org.neo4j.kernel.impl.store.DynamicStringStore in project neo4j by neo4j.

the class StorePropertyPayloadCursorTest method newCursor.

private static StorePropertyPayloadCursor newCursor(Object... values) {
    DynamicStringStore dynamicStringStore = mock(DynamicStringStore.class);
    DynamicArrayStore dynamicArrayStore = mock(DynamicArrayStore.class);
    return newCursor(dynamicStringStore, dynamicArrayStore, values);
}
Also used : DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore)

Example 4 with DynamicStringStore

use of org.neo4j.kernel.impl.store.DynamicStringStore in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method newRecordCursorsWithMockedNeoStores.

private static RecordCursors newRecordCursorsWithMockedNeoStores(RelationshipStore relationshipStore) {
    NeoStores neoStores = mock(NeoStores.class);
    NodeStore nodeStore = newStoreMockWithRecordCursor(NodeStore.class);
    RelationshipGroupStore relGroupStore = newStoreMockWithRecordCursor(RelationshipGroupStore.class);
    PropertyStore propertyStore = newStoreMockWithRecordCursor(PropertyStore.class);
    DynamicStringStore dynamicStringStore = newStoreMockWithRecordCursor(DynamicStringStore.class);
    DynamicArrayStore dynamicArrayStore = newStoreMockWithRecordCursor(DynamicArrayStore.class);
    DynamicArrayStore dynamicLabelStore = newStoreMockWithRecordCursor(DynamicArrayStore.class);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
    when(neoStores.getRelationshipGroupStore()).thenReturn(relGroupStore);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    when(propertyStore.getStringStore()).thenReturn(dynamicStringStore);
    when(propertyStore.getArrayStore()).thenReturn(dynamicArrayStore);
    when(nodeStore.getDynamicLabelStore()).thenReturn(dynamicLabelStore);
    return new RecordCursors(neoStores);
}
Also used : NodeStore(org.neo4j.kernel.impl.store.NodeStore) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RecordCursors(org.neo4j.kernel.impl.store.RecordCursors) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Example 5 with DynamicStringStore

use of org.neo4j.kernel.impl.store.DynamicStringStore in project neo4j by neo4j.

the class RecordLoading method safeLoadTokens.

static <RECORD extends TokenRecord> List<NamedToken> safeLoadTokens(TokenStore<RECORD> tokenStore, CursorContext cursorContext) {
    long highId = tokenStore.getHighId();
    List<NamedToken> tokens = new ArrayList<>();
    DynamicStringStore nameStore = tokenStore.getNameStore();
    List<DynamicRecord> nameRecords = new ArrayList<>();
    MutableLongSet seenRecordIds = new LongHashSet();
    int nameBlockSize = nameStore.getRecordDataSize();
    try (RecordReader<RECORD> tokenReader = new RecordReader<>(tokenStore, true, cursorContext);
        RecordReader<DynamicRecord> nameReader = new RecordReader<>(nameStore, false, cursorContext)) {
        for (long id = 0; id < highId; id++) {
            RECORD record = tokenReader.read(id);
            nameRecords.clear();
            if (record.inUse()) {
                String name;
                if (!NULL_REFERENCE.is(record.getNameId()) && safeLoadDynamicRecordChain(r -> nameRecords.add(r.copy()), nameReader, seenRecordIds, record.getNameId(), nameBlockSize)) {
                    record.addNameRecords(nameRecords);
                    name = tokenStore.getStringFor(record, cursorContext);
                } else {
                    name = format("<name not loaded due to token(%d) referencing unused name record>", id);
                }
                tokens.add(new NamedToken(name, toIntExact(id), record.isInternal()));
            }
        }
    }
    return tokens;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ThrowingIntFunction(org.neo4j.function.ThrowingIntFunction) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Value(org.neo4j.values.storable.Value) ArrayList(java.util.ArrayList) IntObjectMap(org.eclipse.collections.api.map.primitive.IntObjectMap) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) NodeLabelsField(org.neo4j.kernel.impl.store.NodeLabelsField) TokenHolder(org.neo4j.token.api.TokenHolder) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) NeoStores(org.neo4j.kernel.impl.store.NeoStores) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) BiConsumer(java.util.function.BiConsumer) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) TokenRecord(org.neo4j.kernel.impl.store.record.TokenRecord) Math.toIntExact(java.lang.Math.toIntExact) NO_VALUE(org.neo4j.values.storable.Values.NO_VALUE) MutableIntCollection(org.eclipse.collections.api.collection.primitive.MutableIntCollection) MutablePrimitiveObjectMap(org.eclipse.collections.api.map.primitive.MutablePrimitiveObjectMap) NULL_REFERENCE(org.neo4j.kernel.impl.store.record.Record.NULL_REFERENCE) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RecordType(org.neo4j.consistency.RecordType) TokenStore(org.neo4j.kernel.impl.store.TokenStore) String.format(java.lang.String.format) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Consumer(java.util.function.Consumer) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) RecordStore(org.neo4j.kernel.impl.store.RecordStore) List(java.util.List) PrimitiveRecord(org.neo4j.kernel.impl.store.record.PrimitiveRecord) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) TokenNotFoundException(org.neo4j.token.api.TokenNotFoundException) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) NamedToken(org.neo4j.token.api.NamedToken) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertySchemaType(org.neo4j.internal.schema.PropertySchemaType) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) ArrayList(java.util.ArrayList) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) NamedToken(org.neo4j.token.api.NamedToken)

Aggregations

DynamicStringStore (org.neo4j.kernel.impl.store.DynamicStringStore)12 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)9 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 DynamicArrayStore (org.neo4j.kernel.impl.store.DynamicArrayStore)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)3 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)3 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)3 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)2 CursorContext (org.neo4j.io.pagecache.context.CursorContext)2 NodeStore (org.neo4j.kernel.impl.store.NodeStore)2 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)2 RecordCursors (org.neo4j.kernel.impl.store.RecordCursors)2 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)2 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)2