Reading big texts cause OutOfMemmory Error. How to read text partialy?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 33
Description
I have dataset with big strings (every record about 15 mb) in parquet.
When I try to open all parquet parts I get OutOfMemory exception.
How can I get only headers (first 100 symbols) for each string record without reading all record?
Schema avroProj = SchemaBuilder.builder()
.record("proj").fields()
.name("idx").type().nullable().longType().noDefault()
.name("text").type().nullable().bytesType().noDefault()
.endRecord();
Configuration conf = new Configuration();
AvroReadSupport.setRequestedProjection(conf, avroProj);
ParquetReader parquetReader = AvroParquetReader
.builder(new Path(filePath))
.withConf(conf)
.build();
GenericRecord record = parquetReader.read(); // record already have full text in RAM
Long idx = (Long) record.get("idx");
ByteBuffer rawText = (ByteBuffer) record.get("text");
String header = new String(rawText.array()).substring(0, 200);
Environment: I have dataset with big strings (every record about 15 mb) in parquet.
When I try to open all parquet parts I get OutOfMemory exception.
How can I get only headers (first 100 symbols) for each string record without reading all record?
{code:java}
Schema avroProj = SchemaBuilder.builder()
.record("proj").fields()
.name("idx").type().nullable().longType().noDefault()
.name("text").type().nullable().bytesType().noDefault()
.endRecord();
Configuration conf = new Configuration();
AvroReadSupport.setRequestedProjection(conf, avroProj);
ParquetReader parquetReader = AvroParquetReader
.builder(new Path(filePath))
.withConf(conf)
.build();
GenericRecord record = parquetReader.read();
// record already have full text in RAM
Long idx = (Long) record.get("idx");
ByteBuffer rawText = (ByteBuffer) record.get("text");
String header = new String(rawText.array()).substring(0, 200);
{code}
Reporter: Andrei Iatsuk
Note: This issue was originally created as PARQUET-1237. Please see the migration documentation for further details.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AvroReadSupport projection and AvroParquetReader usage shown in the issue, then investigate the reader path for the bytes field. Done means a supported way to obtain only a text prefix without materializing each full 15 MB value, with coverage for the reported out-of-memory case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100