Search in sources :

Example 1 with PropertyKeyTokenStore

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

the class DuplicatePropertyRemoverTest method setUp.

@BeforeClass
public static void setUp() {
    GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
    GraphDatabaseService db = factory.newEmbeddedDatabase(storePath.absolutePath());
    api = (GraphDatabaseAPI) db;
    Label nodeLabel = Label.label("Label");
    propertyNames = new ArrayList<>();
    try (Transaction transaction = db.beginTx()) {
        node = db.createNode(nodeLabel);
        nodeId = node.getId();
        for (int i = 0; i < PROPERTY_COUNT; i++) {
            String propKey = "key" + i;
            propertyNames.add(propKey);
            String propValue = "value" + i;
            boolean isBigProp = ThreadLocalRandom.current().nextBoolean();
            if (isBigProp) {
                propValue += propValue;
                propValue += propValue;
                propValue += propValue;
                propValue += propValue;
                propValue += propValue;
            }
            node.setProperty(propKey, propValue);
        }
        transaction.success();
    }
    Collections.shuffle(propertyNames);
    DependencyResolver resolver = api.getDependencyResolver();
    NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    nodeStore = neoStores.getNodeStore();
    PropertyKeyTokenStore propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
    indexedPropertyKeys = PropertyDeduplicatorTestUtil.indexPropertyKeys(propertyKeyTokenStore);
    propertyStore = neoStores.getPropertyStore();
    remover = new DuplicatePropertyRemover(nodeStore, propertyStore);
}
Also used : PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Label(org.neo4j.graphdb.Label) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) NeoStores(org.neo4j.kernel.impl.store.NeoStores) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) BeforeClass(org.junit.BeforeClass)

Example 2 with PropertyKeyTokenStore

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

the class IndexConsultedPropertyBlockSweeperTest method setUp.

@Before
public void setUp() throws IOException {
    api = dbRule.getGraphDatabaseAPI();
    nonIndexedPropKey = "notIndexed";
    indexedPropKey = "indexed";
    Label usedLabel = Label.label("UsedLabel");
    try (Transaction transaction = api.beginTx()) {
        api.schema().indexFor(usedLabel).on(indexedPropKey).create();
        transaction.success();
    }
    try (Transaction transaction = api.beginTx()) {
        indexedValue = "value1";
        nonIndexedValue = "value2";
        Node nodeA = api.createNode(usedLabel);
        nodeA.setProperty(indexedPropKey, indexedValue);
        nodeA.setProperty(nonIndexedPropKey, nonIndexedValue);
        nodeId = nodeA.getId();
        transaction.success();
    }
    DependencyResolver resolver = api.getDependencyResolver();
    NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    nodeStore = neoStores.getNodeStore();
    PropertyKeyTokenStore propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
    propertyKeys = PropertyDeduplicatorTestUtil.indexPropertyKeys(propertyKeyTokenStore);
    propertyStore = neoStores.getPropertyStore();
    nodeRecord = getRecord(nodeStore, nodeId);
    propertyId = nodeRecord.getNextProp();
    indexMock = mock(IndexLookup.Index.class);
    when(indexMock.contains(nodeId, indexedValue)).thenReturn(true);
    propertyRemoverMock = mock(DuplicatePropertyRemover.class);
}
Also used : PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) Transaction(org.neo4j.graphdb.Transaction) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) Node(org.neo4j.graphdb.Node) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Label(org.neo4j.graphdb.Label) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Example 3 with PropertyKeyTokenStore

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

the class IndexLookupTest method setUp.

@BeforeClass
public static void setUp() {
    api = dbRule.getGraphDatabaseAPI();
    String notUsedIndexPropKey = "notUsed";
    String usedIndexPropKey = "used";
    Label usedLabel = Label.label("UsedLabel");
    Label notUsedLabel = Label.label("NotUsedLabel");
    try (Transaction transaction = api.beginTx()) {
        api.schema().indexFor(usedLabel).on(usedIndexPropKey).create();
        transaction.success();
    }
    try (Transaction transaction = api.beginTx()) {
        api.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
        indexedNodePropertyValue = "value1";
        notIndexedNodePropertyValue = "value2";
        Node nodeA = api.createNode(usedLabel);
        nodeA.setProperty(usedIndexPropKey, indexedNodePropertyValue);
        nodeA.setProperty(notUsedIndexPropKey, notIndexedNodePropertyValue);
        indexedNode = nodeA.getId();
        Node nodeB = api.createNode(notUsedLabel);
        nodeB.setProperty(usedIndexPropKey, notIndexedNodePropertyValue);
        nodeB.setProperty(notUsedIndexPropKey, indexedNodePropertyValue);
        notIndexedNode = nodeB.getId();
        transaction.success();
    }
    DependencyResolver resolver = api.getDependencyResolver();
    NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    SchemaStore schemaStore = neoStores.getSchemaStore();
    SchemaIndexProvider schemaIndexProvider = resolver.resolveDependency(SchemaIndexProvider.class);
    indexLookup = new IndexLookup(schemaStore, schemaIndexProvider);
    LabelTokenStore labelTokenStore = neoStores.getLabelTokenStore();
    notUsedLabelId = findTokenFor(labelTokenStore, notUsedLabel.name()).id();
    usedLabelId = findTokenFor(labelTokenStore, usedLabel.name()).id();
    PropertyKeyTokenStore propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
    notUsedPropertyId = findTokenFor(propertyKeyTokenStore, notUsedIndexPropKey).id();
    usedPropertyId = findTokenFor(propertyKeyTokenStore, usedIndexPropKey).id();
}
Also used : LabelTokenStore(org.neo4j.kernel.impl.store.LabelTokenStore) PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Transaction(org.neo4j.graphdb.Transaction) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) Node(org.neo4j.graphdb.Node) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Label(org.neo4j.graphdb.Label) DependencyResolver(org.neo4j.graphdb.DependencyResolver) BeforeClass(org.junit.BeforeClass)

Example 4 with PropertyKeyTokenStore

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

the class ManyPropertyKeysIT method databaseWithManyPropertyKeys.

private GraphDatabaseAPI databaseWithManyPropertyKeys(int propertyKeyCount) throws IOException {
    var cacheTracer = PageCacheTracer.NULL;
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("databaseWithManyPropertyKeys"));
    StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName()), pageCache, fileSystem, NullLogProvider.getInstance(), cacheTracer, writable());
    NeoStores neoStores = storeFactory.openAllNeoStores(true);
    PropertyKeyTokenStore store = neoStores.getPropertyKeyTokenStore();
    for (int i = 0; i < propertyKeyCount; i++) {
        PropertyKeyTokenRecord record = new PropertyKeyTokenRecord((int) store.nextId(cursorContext));
        record.setInUse(true);
        Collection<DynamicRecord> nameRecords = store.allocateNameRecords(PropertyStore.encodeString(key(i)), cursorContext, INSTANCE);
        record.addNameRecords(nameRecords);
        record.setNameId((int) Iterables.first(nameRecords).getId());
        store.updateRecord(record, NULL);
    }
    neoStores.flush(cursorContext);
    neoStores.close();
    return database();
}
Also used : PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 5 with PropertyKeyTokenStore

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

the class DumpCountsStoreTest method createNeoStores.

private NeoStores createNeoStores() {
    NeoStores neoStores = mock(NeoStores.class);
    LabelTokenStore labelTokenStore = mock(LabelTokenStore.class);
    RelationshipTypeTokenStore typeTokenStore = mock(RelationshipTypeTokenStore.class);
    PropertyKeyTokenStore propertyKeyTokenStore = mock(PropertyKeyTokenStore.class);
    when(labelTokenStore.getTokens(Integer.MAX_VALUE)).thenReturn(getLabelTokens());
    when(typeTokenStore.getTokens(Integer.MAX_VALUE)).thenReturn(getTypeTokes());
    when(propertyKeyTokenStore.getTokens(Integer.MAX_VALUE)).thenReturn(getPropertyTokens());
    when(neoStores.getLabelTokenStore()).thenReturn(labelTokenStore);
    when(neoStores.getRelationshipTypeTokenStore()).thenReturn(typeTokenStore);
    when(neoStores.getPropertyKeyTokenStore()).thenReturn(propertyKeyTokenStore);
    return neoStores;
}
Also used : LabelTokenStore(org.neo4j.kernel.impl.store.LabelTokenStore) PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) RelationshipTypeTokenStore(org.neo4j.kernel.impl.store.RelationshipTypeTokenStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores)

Aggregations

PropertyKeyTokenStore (org.neo4j.kernel.impl.store.PropertyKeyTokenStore)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)6 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 Label (org.neo4j.graphdb.Label)3 Transaction (org.neo4j.graphdb.Transaction)3 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)3 BeforeClass (org.junit.BeforeClass)2 Node (org.neo4j.graphdb.Node)2 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)2 CursorContext (org.neo4j.io.pagecache.context.CursorContext)2 LabelTokenStore (org.neo4j.kernel.impl.store.LabelTokenStore)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1