use of org.neo4j.values.storable.RandomValues in project neo4j by neo4j.
the class AbstractIndexProvidedOrderTest method shouldProvideResultInOrderIfCapable.
@Test
void shouldProvideResultInOrderIfCapable() throws KernelException {
int prop = token.propertyKey(PROPERTY_KEY);
RandomValues randomValues = randomRule.randomValues();
IndexReadSession index = read.indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
for (int i = 0; i < N_ITERATIONS; i++) {
ValueType type = randomValues.among(targetedTypes);
IndexOrderCapability order = index.reference().getCapability().orderCapability(type.valueGroup.category());
if (order.supportsAsc()) {
expectResultInOrder(randomValues, type, prop, index, IndexOrder.ASCENDING);
}
if (order.supportsDesc()) {
expectResultInOrder(randomValues, type, prop, index, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.values.storable.RandomValues in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method createDatabaseWithNativeIndexes.
private static void createDatabaseWithNativeIndexes(Path homeDirectory, String databaseName) {
// Create one index for every provider that we have
for (SchemaIndex schemaIndex : SchemaIndex.values()) {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(homeDirectory).setConfig(default_schema_provider, schemaIndex.providerName()).setConfig(default_database, databaseName).build();
GraphDatabaseService db = managementService.database(databaseName);
String key = "key-" + schemaIndex.name();
try {
Label labelOne = Label.label("one");
try (Transaction tx = db.beginTx()) {
tx.schema().indexFor(labelOne).on(key).create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
RandomValues randomValues = RandomValues.create();
for (int i = 0; i < 10_000; i++) {
tx.createNode(labelOne).setProperty(key, randomValues.nextValue().asObject());
}
tx.commit();
}
} finally {
managementService.shutdown();
}
}
}
use of org.neo4j.values.storable.RandomValues in project neo4j by neo4j.
the class IndexPopulationIT method prePopulateDatabase.
private void prePopulateDatabase(GraphDatabaseService database, Label testLabel, String propertyName) {
final RandomValues randomValues = RandomValues.create();
try (Transaction transaction = database.beginTx()) {
for (int j = 0; j < 10_000; j++) {
Node node = transaction.createNode(testLabel);
Object property = randomValues.nextValue().asObject();
node.setProperty(propertyName, property);
}
transaction.commit();
}
}
use of org.neo4j.values.storable.RandomValues in project neo4j by neo4j.
the class FulltextProceduresTestSupport method generateRandomValues.
List<Value> generateRandomValues(Predicate<Value> predicate) {
int valuesToGenerate = 1000;
RandomValues generator = RandomValues.create();
List<Value> values = new ArrayList<>(valuesToGenerate);
for (int i = 0; i < valuesToGenerate; i++) {
Value value;
do {
value = generator.nextValue();
} while (!predicate.test(value));
values.add(value);
}
return values;
}
use of org.neo4j.values.storable.RandomValues in project neo4j by neo4j.
the class ReuseStorageSpaceIT method createStuff.
/**
* The seed will make this method create the same data every time.
* @param db {@link GraphDatabaseService} db.
* @param seed starting seed for the randomness.
*/
private static void createStuff(GraphDatabaseService db, long seed) {
Race race = new Race();
AtomicLong createdNodes = new AtomicLong();
AtomicLong createdRelationships = new AtomicLong();
int dataSizePerTransaction = DATA_SIZE / NUMBER_OF_TRANSACTIONS_PER_THREAD / CREATION_THREADS;
AtomicLong nextSeed = new AtomicLong(seed);
race.addContestants(CREATION_THREADS, throwing(() -> {
RandomValues random = RandomValues.create(new Random(nextSeed.getAndIncrement()));
int nodeCount = 0;
int relationshipCount = 0;
for (int t = 0; t < NUMBER_OF_TRANSACTIONS_PER_THREAD; t++) {
try (Transaction tx = db.beginTx()) {
// Nodes
Node[] nodes = new Node[dataSizePerTransaction];
for (int n = 0; n < nodes.length; n++) {
Node node = nodes[n] = tx.createNode(labels(random.selection(TOKENS, 0, TOKENS.length, false)));
setProperties(random, node);
nodeCount++;
}
// Relationships
for (int r = 0; r < nodes.length; r++) {
Relationship relationship = random.among(nodes).createRelationshipTo(random.among(nodes), withName(random.among(TOKENS)));
setProperties(random, relationship);
relationshipCount++;
}
tx.commit();
}
}
createdNodes.addAndGet(nodeCount);
createdRelationships.addAndGet(relationshipCount);
}), 1);
race.goUnchecked();
}
Aggregations