Class RecordAdapter
RecordReader / RecordWriter instances for
formats whose token-stream surface is whole-value-only (no native TokenReader /
TokenWriter).
The cursors are created from the live session (ParserSession /
SerializerSession), so they honor the same per-invocation configuration (swaps, bean
filters, locale/timezone, schema) as parse(...)/serialize(...).
Reduces per-format override boilerplate to a one-liner on the session class:
All four cursors report isStreaming() == close() closes the
input/output it was handed when it is Closeable. Multi-rooted formats that need
different semantics (jsonl, csv, sse) implement their own cursor.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RecordReaderarrayReader(ParserSession session, Object input) Creates an array-elementRecordReaderbacked by a buffered list parse.static RecordWriterarrayWriter(SerializerSession session, Object output) Creates an array-elementRecordWriterthat buffers eachwrite(...)call and emits the whole list onRecordWriter.close().static RecordReaderreader(ParserSession session, Object input) Creates a single-shotRecordReaderthat delegatesread(...)calls to the session'sread(...)entry point.static RecordWriterwriter(SerializerSession session, Object output) Creates a single-shotRecordWriterthat delegateswrite(Object)calls to the session'swrite(...)entry point.
-
Method Details
-
reader
Creates a single-shotRecordReaderthat delegatesread(...)calls to the session'sread(...)entry point.- Parameters:
session- The format's live parser session. Must not benull .input- The input to bind on the firstread(...)call.- Returns:
- A new
RecordReader.
-
arrayReader
Creates an array-elementRecordReaderbacked by a buffered list parse.Equivalent to calling
session.read(input, List.class, Object.class)once and iterating the result. This is correct but NOT streaming — the whole array is materialized. Format-specific implementations may overrideArrayRecordReadable.readArrayRecords(Object)directly for actual streaming.- Parameters:
session- The format's live parser session. Must not benull .input- The input to bind on the first read.- Returns:
- A new
RecordReaderthat yields one record per array element. - Throws:
IOException- If a problem occurred reading the input.
-
arrayWriter
Creates an array-elementRecordWriterthat buffers eachwrite(...)call and emits the whole list onRecordWriter.close().This is correct but NOT streaming — the writes are accumulated in memory. Format-specific implementations may override
ArrayRecordWritable.writeArrayRecords(Object)directly for actual streaming.- Parameters:
session- The format's live serializer session. Must not benull .output- The output to write to.- Returns:
- A new
RecordWriterthat accepts N elements and emits an N-element array.
-
writer
Creates a single-shotRecordWriterthat delegateswrite(Object)calls to the session'swrite(...)entry point.- Parameters:
session- The format's live serializer session. Must not benull .output- The output to write to.- Returns:
- A new
RecordWriter.
-