Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Risingwavelabs Risingwave BaseRow

From Leeroopedia
Revision as of 10:50, 27 September 2026 by Agent (talk | contribs) (Sync from local file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Property Value
Component Java Binding
Language Java
Source File java/java-binding/src/main/java/com/risingwave/java/binding/BaseRow.java
Lines 103
Package com.risingwave.java.binding
License Apache 2.0

Overview

BaseRow is the base class for row data access in the RisingWave Java binding layer. It provides typed accessor methods for all data types supported by RisingWave, including primitive types (short, int, long, float, double, boolean), string types, temporal types (timestamp, timestamptz, time, date, interval), decimal, jsonb, bytea, and one-dimensional arrays.

The class holds a native pointer to a Rust-side row structure and delegates every typed accessor to the corresponding JNI native method declared in the Binding class. It serves as the foundation for the row access API, extended by KeyedRow (used with HummockIterator) and StreamChunkRow (used with StreamChunkIterator).

Code Reference

Source Location

java/java-binding/src/main/java/com/risingwave/java/binding/BaseRow.java

Signature

public class BaseRow {
    protected final long pointer;

    protected BaseRow(long pointer);

    public boolean isNull(int index);
    public short getShort(int index);
    public int getInt(int index);
    public long getLong(int index);
    public float getFloat(int index);
    public double getDouble(int index);
    public boolean getBoolean(int index);
    public String getString(int index);
    public java.time.LocalDateTime getTimestamp(int index);
    public java.time.OffsetDateTime getTimestamptz(int index);
    public java.time.LocalTime getTime(int index);
    public java.math.BigDecimal getDecimal(int index);
    public java.time.LocalDate getDate(int index);
    public String getInterval(int index);
    public String getJsonb(int index);
    public byte[] getBytea(int index);
    public <T> Object[] getArray(int index, Class<T> clazz);
}

Import

import com.risingwave.java.binding.BaseRow;

I/O Contract

Inputs

  • pointer (long): A native pointer to a Rust-side row structure, passed at construction time by subclasses. This pointer is used for all subsequent JNI calls.
  • index (int): A zero-based column index passed to each accessor method, identifying which column value to retrieve from the row.
  • clazz (Class<T>): For getArray, the element type class used to determine the array element type on the native side.

Outputs

  • Each accessor method returns the corresponding Java type for the column value at the given index:
    • isNull returns boolean indicating whether the column is null
    • getShort returns short (INT16)
    • getInt returns int (INT32)
    • getLong returns long (INT64)
    • getFloat returns float
    • getDouble returns double
    • getBoolean returns boolean
    • getString returns String (VARCHAR)
    • getTimestamp returns java.time.LocalDateTime
    • getTimestamptz returns java.time.OffsetDateTime
    • getTime returns java.time.LocalTime
    • getDecimal returns java.math.BigDecimal
    • getDate returns java.time.LocalDate
    • getInterval returns String (e.g., "2 mons 3 days 00:00:00.000004" or ISO 8601 format)
    • getJsonb returns String (JSON string representation)
    • getBytea returns byte[]
    • getArray returns Object[] (one-dimensional array elements)

Side Effects

  • All accessor methods make JNI calls to the Rust side via the Binding class. The native pointer must remain valid for the lifetime of the row object.

Usage Examples

Accessing column values from a KeyedRow

// KeyedRow extends BaseRow, obtained from HummockIterator
try (HummockIterator iter = new HummockIterator(readPlan)) {
    KeyedRow row;
    while ((row = iter.next()) != null) {
        if (!row.isNull(0)) {
            int id = row.getInt(0);
            String name = row.getString(1);
            java.math.BigDecimal amount = row.getDecimal(2);
            java.time.LocalDateTime createdAt = row.getTimestamp(3);
        }
    }
}

Accessing column values from a StreamChunkRow

// StreamChunkRow extends BaseRow, obtained from StreamChunkIterator
try (StreamChunkIterator iter = new StreamChunkIterator(chunk)) {
    StreamChunkRow row;
    while ((row = iter.next()) != null) {
        short smallVal = row.getShort(0);
        boolean flag = row.getBoolean(1);
        byte[] binaryData = row.getBytea(2);
        Object[] arrayCol = row.getArray(3, String.class);
    }
}

Related Pages

  • Binding - Central JNI native method declarations used by all accessor methods
  • HummockIterator - Iterator that produces KeyedRow instances (which extend BaseRow)
  • StreamChunkIterator - Iterator that produces StreamChunkRow instances (which extend BaseRow)
  • StreamChunk - Native StreamChunk wrapper used with StreamChunkIterator

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment