Data Model #
This chapter describes how the Proxima Platform models domain data in terms of entities and attributes on top of its core abstraction: an immutable, partitioned stream of attribute updates.
Entities #
Proxima defines the complete data model in terms of abstract entities. Each entity has a string key (identifying a specific entity instance) and a set of typed attributes. Conceptually, an entity resembles a sparse wide-column table:
| Entity key | details | preferences | event.1700000000001 | event.1700000000002 |
|---|---|---|---|---|
user-1 | {...} | {...} | {...} | {...} |
user-2 | {...} | (missing) | {...} | (missing) |
Entity names must match [a-zA-Z_][a-zA-Z0-9_]*, and attribute names must match [a-zA-Z_][a-zA-Z0-9_\-$]*(\.\*)?.
The data type and binary serialization of every attribute are defined by a scheme URI resolved by a
ValueSerializerFactory into a
ValueSerializer.
Consider an e-commerce site with products, users, and user interaction events. In HOCON configuration, you declare these entities as follows:
entities {
# User entity
user {
attributes {
# Scalar attribute for user profile details (e.g., name, email)
details { scheme: "proto:cz.o2.proxima.example.user.User$Details" }
# Scalar attribute holding computed user preferences
preferences { scheme: "proto:cz.o2.proxima.example.user.User$Preferences" }
# Wildcard attribute storing selected events in the user's history
"event.*" { scheme: "proto:cz.o2.proxima.example.event.Event$BaseEvent" }
}
}
# Entity describing a single product
product {
# Split properties into separate attributes whenever they need to be updated independently
attributes {
price { scheme: "proto:cz.o2.proxima.example.product.Product$Price" }
details { scheme: "proto:cz.o2.proxima.example.product.Product$Details" }
# Wildcard attribute representing associated categories
"category.*" { scheme: "proto:cz.o2.proxima.example.product.Product$Category" }
}
}
# Atomic event entity linking users to products
event {
attributes {
data { scheme: "proto:cz.o2.proxima.example.event.Event$BaseEvent" }
}
}
}
Entity Inheritance (from)
#
An entity can inherit all attribute definitions from another entity using the from keyword. This is useful when you want a separate logical entity (with its own attribute families and storage layout) that shares an existing schema:
entities {
product_archive {
from: product
}
}
Attributes #
Attributes fall into three categories: scalar, wildcard, and proxy attributes.
Scalar Attributes #
details and preferences on entity user are scalar attributes. For any given entity key, a scalar attribute either holds a single typed value or is absent (deleted/never written).
The attribute’s scheme URI determines its Java type and serialization format—for example string, integer, long, float, double, bytes, json, proto:<ClassName>, json-proto:<ClassName>, avro:<ClassName>, or schema-registry:<url>/<subject>. See
Serialization schemes for the complete reference.
Wildcard Attributes #
An attribute whose name ends with .* (such as event.* on user or category.* on product) is a wildcard attribute. Conceptually, it represents a sorted map of (suffix -> value) entries scoped to an entity key.
For example, entity user with key alice may simultaneously hold:
event.1700000000001event.1700000000042event.640ab744-3b3e-11ed-936b-e5b6cd08b011
Wildcard attributes naturally model:
- Time-ordered histories / lists (using timestamp or reverse-timestamp suffixes)
- Key-value maps (using item identifiers as suffixes)
- One-to-many / many-to-many relations (e.g.
product.category.<categoryId>)
Wildcard attributes support prefix scans (scanWildcard) in random-access stores as well as atomic bulk deletion of all suffixes via a delete wildcard operation.
Proxy Attributes #
A proxy attribute presents a virtual attribute view backed by one or more underlying (“raw”) attributes on the same entity, applying a name transformation on reads and/or writes via
ElementWiseProxyTransform (or an operator-specific ProxyTransform).
Proxy attributes are commonly used to:
- Hide internal/protected storage attributes (conventionally prefixed with
_, such as_e.*) behind a clean public attribute name - Rename or normalize wildcard suffixes transparently
- Route reads and writes to different underlying attributes (for example, in multi-cluster replication topologies)
Symmetric Proxy #
Applies the same transform in both directions (toProxy on reads, fromProxy on writes):
entities {
proxied {
attributes {
# Internal raw attribute mapped to physical storage
"_e.*" { scheme: bytes }
# Public proxy attribute exposed to applications
"event.*" {
proxy: "_e.*"
apply: cz.o2.proxima.example.EventProxyTransform
}
}
}
}
Asymmetric Proxy #
Separates read and write paths so writes go to one target attribute while reads come from another:
entities {
proxied {
attributes {
"_e.*" { scheme: bytes }
"raw.*" { scheme: bytes }
"asymmetric.*" {
proxy {
write {
into: "_e.*"
apply: cz.o2.proxima.example.WriteProxyTransform
}
read {
from: "raw.*"
apply: cz.o2.proxima.example.ReadProxyTransform
}
}
}
}
}
}
You can also specify only a write block or only a read block (in which case you must specify scheme explicitly because the non-proxied side behaves as a regular attribute), or override the scheme on any proxy attribute.
ElementWiseProxyTransform provides built-in factory helpers for common name transformations:
ElementWiseProxyTransform.identity()ElementWiseProxyTransform.renaming(proxyPrefix, rawPrefix)ElementWiseProxyTransform.droppingUntilCharacter(character, rawPrefix)ElementWiseProxyTransform.composite(transforms...)ElementWiseProxyTransform.from(fromProxyFn, toProxyFn)
StreamElement
#
Proxima represents every mutation in the platform—whether an insert, an update, a single deletion, or a wildcard deletion—as an immutable
StreamElement.
| Field | Type | Description |
|---|---|---|
entityDescriptor | EntityDescriptor | Metadata of the target entity. |
attributeDescriptor | AttributeDescriptor<?> | Metadata of the attribute definition (for wildcards, the prefix.* descriptor). |
uuid / sequentialId | String / long | Unique event identifier. Non-transactional writes use a non-empty uuid; transactional writes use a positive monotonic sequentialId. |
key | String | Entity key (“row” identifier). |
attribute | String | Concrete attribute name (e.g. details or event.1700000000001, or category.* for wildcard deletes). |
stamp | long | Event timestamp in epoch milliseconds. |
value | byte[] (@Nullable) | Serialized attribute payload for upserts, or null for deletes. |
deleteWildcard | boolean | When true (with value == null), deletes all suffixes matching the wildcard attribute for the given key. |
Creating StreamElement Instances
#
Use the static factory methods on StreamElement (or the type-safe helpers on a
generated Model):
// Upsert a scalar or wildcard attribute
StreamElement upsert = StreamElement.upsert(
userEntity,
detailsAttr,
UUID.randomUUID().toString(),
"user-1",
"details",
System.currentTimeMillis(),
detailsAttr.getValueSerializer().serialize(userDetails));
// Delete a single attribute (or a specific wildcard instance)
StreamElement delete = StreamElement.delete(
userEntity,
detailsAttr,
UUID.randomUUID().toString(),
"user-1",
"details",
System.currentTimeMillis());
// Delete ALL instances of a wildcard attribute for key "book-42"
StreamElement deleteAllCategories = StreamElement.deleteWildcard(
productEntity,
categoryAttr,
UUID.randomUUID().toString(),
"book-42",
System.currentTimeMillis());
A stream is an unbounded, generally unordered sequence of StreamElements:
| entity | attribute | key | timestamp | value | delete wildcard | operation |
|---|---|---|---|---|---|---|
user | details | me | 1700000000500 | <bytes> | false | upsert |
user | preferences | you | 1700000000400 | <bytes> | false | upsert |
event | data | ${UUID} | 1700000000900 | <bytes> | false | upsert |
user | details | other | 1700000000300 | null | false | delete |
product | category.* | book | 1700000000900 | null | true | delete wildcard |
Stream-Table Duality #
Stream-table duality defines how an unbounded stream of upserts and deletes reduces into a table (called a batch snapshot in Proxima) at any point in time $T$:
- Take all
StreamElements withstamp <= T. - Group elements by
(entity, key, attribute). - Keep only the element with the highest timestamp (or highest
sequentialIdfor transactional attributes). - If the winning element is a delete (or a wildcard delete with a timestamp greater than or equal to a matching wildcard attribute’s timestamp), the attribute is absent from the snapshot.
For example, starting from this snapshot:
| entity | attribute | key | timestamp | value |
|---|---|---|---|---|
user | details | other | 1700000000000 | <old> |
product | details | car | 1700000000100 | <car> |
product | category.books | book | 1700000000200 | <cat> |
Applying the five stream elements shown above yields the compacted snapshot:
| entity | attribute | key | timestamp | value |
|---|---|---|---|---|
product | details | car | 1700000000100 | <car> |
user | details | me | 1700000000500 | <bytes> |
user | preferences | you | 1700000000400 | <bytes> |
event | data | ${UUID} | 1700000000900 | <bytes> |
Notice that user(other).details was removed by the delete at 1700000000300, and product(book).category.books was removed by the wildcard delete product(book).category.* at 1700000000900.
Next, see Serialization schemes to learn how attribute values are typed and serialized, or proceed to Storages to map entities onto physical storage systems.