Search in sources :

Example 1 with RandomEntityDataGenerator

use of org.neo4j.internal.batchimport.input.RandomEntityDataGenerator in project neo4j by neo4j.

the class CsvInputEstimateCalculationIT method generateData.

private DataFactory generateData(Header.Factory factory, MutableLong start, long count, long nodeCount, String headerString, String fileName, Groups groups) throws IOException {
    Path file = testDirectory.file(fileName);
    Header header = factory.create(charSeeker(wrap(headerString), COMMAS, false), COMMAS, IdType.INTEGER, groups);
    Distribution<String> distribution = new Distribution<>(new String[] { "Token" });
    Deserialization<String> deserialization = new StringDeserialization(COMMAS);
    try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(file));
        RandomEntityDataGenerator generator = new RandomEntityDataGenerator(nodeCount, count, toIntExact(count), random.seed(), start.longValue(), header, distribution, distribution, 0, 0, 5);
        InputChunk chunk = generator.newChunk();
        InputEntity entity = new InputEntity()) {
        out.println(headerString);
        while (generator.next(chunk)) {
            while (chunk.next(entity)) {
                out.println(convert(entity, deserialization, header));
            }
        }
    }
    start.add(count);
    return DataFactories.data(InputEntityDecorators.NO_DECORATOR, StandardCharsets.UTF_8, file);
}
Also used : Path(java.nio.file.Path) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) Distribution(org.neo4j.internal.batchimport.input.Distribution) InputEntity(org.neo4j.internal.batchimport.input.InputEntity) InputChunk(org.neo4j.internal.batchimport.input.InputChunk) ByteUnit.bytesToString(org.neo4j.io.ByteUnit.bytesToString) RandomEntityDataGenerator(org.neo4j.internal.batchimport.input.RandomEntityDataGenerator) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 Path (java.nio.file.Path)1 Distribution (org.neo4j.internal.batchimport.input.Distribution)1 InputChunk (org.neo4j.internal.batchimport.input.InputChunk)1 InputEntity (org.neo4j.internal.batchimport.input.InputEntity)1 RandomEntityDataGenerator (org.neo4j.internal.batchimport.input.RandomEntityDataGenerator)1 DataFactories.defaultFormatNodeFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)1 DataFactories.defaultFormatRelationshipFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader)1 ByteUnit.bytesToString (org.neo4j.io.ByteUnit.bytesToString)1