Schemas and Arrow
For teams that share tables between services: give each table a versioned schema, block changes that would break a reader, and move column batches without hand-written conversion.
Java modules: jdogo-schema, jdogo-schema-jdbc and jdogo-arrow. Documents never need a schema to be read; schemas are for checking and governance.
Define or infer a schema
import com.jdogo.schema.*;
record Order(long id, String sku, int qty, String note) {}
SchemaDefinition v1 = SchemaInference.infer(Order.class); // fields and types from the record
SchemaDefinition v2 = SchemaDefinition.builder("Order", 2)
.addField("id", FieldType.INT64)
.addField("sku", FieldType.STRING)
.addField("qty", FieldType.INT32)
.addField(new FieldDefinition.Builder("note", FieldType.STRING).optional(true).build())
.addField(new FieldDefinition.Builder("channel", FieldType.STRING).defaultValue("web").build())
.build();Field types cover the Java scalars, BIG_DECIMAL, BIG_INTEGER, UUID, the java.time types, BYTES, ENUM, and nested OBJECT, RECORD, LIST, SET and MAP. Each schema has a fingerprint computed from its fields.
Check a change before you ship it
var result = SchemaEvolutionValidator.validate(v1, v2, SchemaEvolutionValidator.CompatibilityMode.FULL);
if (!result.valid()) {
result.violations().forEach(System.err::println);
// New required field 'channel' added without default value breaks BACKWARD compatibility
}| Mode | Rejects |
|---|---|
BACKWARD | New required fields without a default; type changes |
FORWARD | Removing a required field |
FULL | Both |
NONE | Nothing |
Run it in CI against the schema you have in production.
Registries
SchemaRegistry registry = new InMemorySchemaRegistry();
// or, shared by every service:
SchemaRegistry registry = JdbcSchemaRegistry.create(dataSource); // creates jdogo_schemas and jdogo_schema_fields
registry.register(v2);
registry.findLatest("Order");
registry.findById(v2.getId());
registry.findByFingerprint(v2.getFingerprint());JdbcSchemaRegistry uses portable SQL with bound parameters. The test suite runs it on H2; bring the driver for your database.
Column batches
ArrowColumnBatch holds named int, long, double, boolean and string vectors with null masks. Copy your Apache Arrow vectors into it, or fill it from any columnar source, and write it as the same 2.x table every SDK reads.
import com.jdogo.format.arrow.*;
var batch = new ArrowColumnBatch(List.of(
new ArrowColumnVector.IntVector("id", ids, null),
new ArrowColumnVector.StringVector("symbol", symbols),
new ArrowColumnVector.DoubleVector("price", prices, priceNulls)));
var out = new StringWriter();
ArrowJDogoBridge.exportToJDogo(batch, out);
ArrowColumnBatch back = ArrowJDogoBridge.importFromJDogo(new StringReader(out.toString()),
List.of(Integer.class, String.class, Double.class));Nulls stay nulls in both directions. Reading also accepts the 1.x pipe-delimited form. For pandas and polars in Python, use jdogo.to_dataframe(text); see Integrations.