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);
}
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);
}
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();
}
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();
}
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;
}
Aggregations