For the complete documentation index, see llms.txt. This page is also available as Markdown.

Records and Writables

DataVec record format — Writable types, Record, and the data representation layer

At the lowest level of DataVec, every data element is a Writable. A Writable is a lightweight, type-safe value holder — the atomic unit of data in DataVec. A record is a List<Writable> where each element corresponds to one column in the schema.

Understanding Writable is useful when writing custom transforms, implementing custom record readers, or manually iterating records to feed into inference.

The Writable Interface

Writable provides a minimal interface for reading and converting values:

public interface Writable {
    void write(DataOutput out) throws IOException;
    void readFields(DataInput in) throws IOException;

    double toDouble();
    float toFloat();
    int toInt();
    long toLong();
    String toString();     // the human-readable string form of the value

    WritableType getType();
}

Every column value in a DataVec record is one of the concrete Writable implementations listed below.

Concrete Writable Types

IntWritable

Holds a 32-bit signed integer.

LongWritable

Holds a 64-bit signed integer. Used for large IDs, timestamps (epoch milliseconds), and any integer that may exceed Integer.MAX_VALUE.

DoubleWritable

Holds a 64-bit double-precision floating point value.

FloatWritable

Holds a 32-bit single-precision floating point value. Preferred for memory-sensitive applications.

Text

Holds a string value. This is the default type produced by CSVRecordReader and LineRecordReader before any type conversion.

Note that Text is modeled after Hadoop's Text class but is not the same class. Do not confuse the two.

BooleanWritable

Holds a boolean value.

BytesWritable

Holds a raw byte array. Used for binary data, serialized objects, or any blob-style column.

NDArrayWritable

Holds an ND4J INDArray. This is the bridge between DataVec's record model and ND4J's tensor model, used when a single column represents an entire feature vector or image.

NDArrayWritable is used by ImageRecordReader to represent image data, and by ArrowRecordReader when reading columnar Arrow batches.

NullWritable

Represents a missing or null value. Used as a placeholder when a join produces rows that have no matching record from the other side.

Record

A Record combines a List<Writable> with optional RecordMetaData. The metadata tracks where the record came from (which file, which line number, which URI), enabling error reporting and selective record reloading.

SequenceRecord

A SequenceRecord wraps a sequence (List<List<Writable>>) with optional RecordMetaData. The outer list is the sequence of time steps; each inner list is one time step's column values.

Working with Records Manually

Most DataVec pipelines do not require direct Writable manipulation — TransformProcess, DataSetIterator, and LocalTransformExecutor handle it internally. The cases where you interact with Writable directly are:

Custom RecordReaders: Implement RecordReader.next() by constructing a List<Writable>:

Custom Transforms: The map method of a custom Transform receives and returns List<Writable>:

Manual Inference: Building a record from a single input for real-time prediction:

WritableType Enum

The WritableType enum identifies the type of a Writable without needing instanceof checks:

Last updated

Was this helpful?