Implementation:Risingwavelabs Risingwave JNI Binding Header
| Knowledge Sources | |
|---|---|
| Domains | JNI, Java-Rust Interop, Connectors, Storage |
| Language | C (auto-generated JNI header) |
| Lines | 301 |
| Last Updated | 2026-02-09 07:00 GMT |
Overview
Auto-generated JNI (Java Native Interface) C header file that declares native function signatures for the com.risingwave.java.binding.Binding Java class.
Description
This machine-generated header provides the bridge between Java and Rust by declaring JNIEXPORT function prototypes that correspond to Java native method declarations. The functions cover four major areas of functionality:
- Iterator operations -- Creating iterators over Hummock storage and StreamChunk data, advancing iterators, and extracting typed column values (INT16, INT32, INT64, FLOAT, DOUBLE, BOOLEAN, VARCHAR, TIMESTAMP, TIMESTAMPTZ, DECIMAL, TIME, DATE, INTERVAL, JSONB, BYTEA, and arrays).
- CDC source channel -- Sending CDC source messages to a channel for event stream processing.
- Sink writer/coordinator channels -- Receiving sink writer requests, sending sink writer responses and errors, receiving sink coordinator requests, and sending sink coordinator responses through JNI-managed channels.
- Object store operations -- Putting, getting, listing, deleting objects and querying the object store type for Hummock storage integration.
Usage
This header is not used directly by developers. It is auto-generated by javah (or javac -h) from the Java Binding class and consumed by the Rust JNI implementation that provides the native method bodies.
Code Reference
Source Location
- Repository: risingwave
- File: java/com_risingwave_java_binding_Binding.h
- Lines: 1-301
Signature
/* Iterator lifecycle */
JNIEXPORT jlong JNICALL Java_com_risingwave_java_binding_Binding_iteratorNewHummock
(JNIEnv *, jclass, jbyteArray);
JNIEXPORT jboolean JNICALL Java_com_risingwave_java_binding_Binding_iteratorNext
(JNIEnv *, jclass, jlong);
JNIEXPORT void JNICALL Java_com_risingwave_java_binding_Binding_iteratorClose
(JNIEnv *, jclass, jlong);
/* StreamChunk iterators */
JNIEXPORT jlong JNICALL Java_com_risingwave_java_binding_Binding_iteratorNewFromStreamChunkPayload
(JNIEnv *, jclass, jbyteArray);
JNIEXPORT jlong JNICALL Java_com_risingwave_java_binding_Binding_iteratorNewFromStreamChunkPretty
(JNIEnv *, jclass, jstring);
/* Typed value getters (examples) */
JNIEXPORT jint JNICALL Java_com_risingwave_java_binding_Binding_iteratorGetInt32Value
(JNIEnv *, jclass, jlong, jint);
JNIEXPORT jstring JNICALL Java_com_risingwave_java_binding_Binding_iteratorGetStringValue
(JNIEnv *, jclass, jlong, jint);
JNIEXPORT jobject JNICALL Java_com_risingwave_java_binding_Binding_iteratorGetTimestampValue
(JNIEnv *, jclass, jlong, jint);
/* CDC source channel */
JNIEXPORT jboolean JNICALL Java_com_risingwave_java_binding_Binding_sendCdcSourceMsgToChannel
(JNIEnv *, jclass, jlong, jbyteArray);
/* Sink writer channel */
JNIEXPORT jbyteArray JNICALL Java_com_risingwave_java_binding_Binding_recvSinkWriterRequestFromChannel
(JNIEnv *, jclass, jlong);
JNIEXPORT jboolean JNICALL Java_com_risingwave_java_binding_Binding_sendSinkWriterResponseToChannel
(JNIEnv *, jclass, jlong, jbyteArray);
/* Object store operations */
JNIEXPORT void JNICALL Java_com_risingwave_java_binding_Binding_putObject
(JNIEnv *, jclass, jstring, jbyteArray);
JNIEXPORT jbyteArray JNICALL Java_com_risingwave_java_binding_Binding_getObject
(JNIEnv *, jclass, jstring);
Import
#include <jni.h>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| JNIEnv * | JNI pointer | Yes | JNI environment pointer provided by the JVM |
| jclass | JNI class ref | Yes | Reference to the Binding Java class |
| jlong (pointer) | long | Varies | Opaque handle to a native iterator or channel object |
| jint (index) | int | Varies | Column index for typed value getter functions |
| jbyteArray | byte[] | Varies | Serialized protobuf data (ReadPlan, StreamChunk payload, CDC messages, sink requests/responses) |
| jstring | String | Varies | Object name for object store operations or pretty-print StreamChunk string |
Outputs
| Name | Type | Description |
|---|---|---|
| jlong | long | Opaque native pointer to a newly created iterator |
| jboolean | boolean | Success/failure flag or hasNext indicator |
| jint / jshort / jfloat / jdouble | primitive | Typed column values from iterator rows |
| jstring | String | String column values, interval/jsonb representations, or object store type |
| jobject | Object | Java objects for Timestamp, Timestamptz, Decimal, Time, Date, and array values |
| jbyteArray | byte[] | Binary data for key extraction, bytea values, or object store get results |
| jobjectArray | String[] | List of object names from object store listing |
Usage Examples
Java Native Method Declaration (corresponding Java side)
// In com.risingwave.java.binding.Binding
public class Binding {
static native int defaultVnodeCount();
static native long iteratorNewHummock(byte[] readPlan);
static native boolean iteratorNext(long pointer);
static native void iteratorClose(long pointer);
static native int iteratorGetInt32Value(long pointer, int index);
static native String iteratorGetStringValue(long pointer, int index);
static native boolean sendCdcSourceMsgToChannel(long channelPtr, byte[] msg);
}