Search in sources :

Example 1 with ChunkImpl

use of org.neo4j.csv.reader.CharReadableChunker.ChunkImpl in project neo4j by neo4j.

the class CsvInputIterator method extractHeader.

static Header extractHeader(CharReadable stream, Header.Factory headerFactory, IdType idType, Configuration config, Groups groups, Monitor monitor) throws IOException {
    if (!headerFactory.isDefined()) {
        char[] firstLineBuffer = Readables.extractFirstLineFrom(stream);
        // make the chunk slightly bigger than the header to not have the seeker think that it's reading
        // a value bigger than its max buffer size
        ChunkImpl firstChunk = new ChunkImpl(copyOf(firstLineBuffer, firstLineBuffer.length + 1));
        firstChunk.initialize(firstLineBuffer.length, stream.sourceDescription());
        CharSeeker firstSeeker = seeker(firstChunk, config);
        return headerFactory.create(firstSeeker, config, idType, groups, monitor);
    }
    return headerFactory.create(null, null, null, null, monitor);
}
Also used : BufferedCharSeeker(org.neo4j.csv.reader.BufferedCharSeeker) CharSeeker(org.neo4j.csv.reader.CharSeeker) ChunkImpl(org.neo4j.csv.reader.CharReadableChunker.ChunkImpl)

Aggregations

BufferedCharSeeker (org.neo4j.csv.reader.BufferedCharSeeker)1 ChunkImpl (org.neo4j.csv.reader.CharReadableChunker.ChunkImpl)1 CharSeeker (org.neo4j.csv.reader.CharSeeker)1