Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[JAVA] Decoding unset fields in SBE returns default 0 instead of "not set" – How to distinguish? #1078

@daji777

Description

@daji777

I'm using Simple Binary Encoding (SBE) and noticed that when a field (e.g., int32) is not explicitly set by the sender, the decoder still returns a default value (0 for numeric types). This makes it impossible to distinguish between:

A field that was explicitly set to 0, and

A field that was never set (should be treated as "null" or "absent").

Example Scenario:

Schema Definition:

<field name="price" type="int32" presence="optional"/>
Decoding Result:

If the sender omits price, the decoder still returns price = 0.

If the sender sets price = 0, the decoder also returns price = 0.

Is this the expected behavior of SBE?

What is the recommended way to detect if a field was truly "not set" (absent) vs. "set to 0"?

Are there runtime checks (e.g., hasField() methods) generated by SBE?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions