You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e5234fe
Browse filesBrowse the repository at this point in the historyBrowse files
Follow-ups to RecordPreparer: faster Timestamps, shared generated names, imported message zero values (#1472)
## Summary
Follow-ups to `RecordPreparer` from #1442, proposed as a stacked PR.
```diff
build_scalar_preparer
+ Timestamp field whose scalar uses the DateTime preparer
+ Time.at(seconds, nanos, :nsec).iso8601(DATE_TIME_PRECISION)
other message scalar
- preparer(JSON.parse(encode_json(value)))
+ preparer(JSON.parse(encode_json(value, emit_defaults: true)))
build_enum
- {symbol => name, number => name}
+ {symbol => name}
schema generator and RecordPreparer
- "value", "values", zero value name minus "_UNSPECIFIED"
+ ProtoConversions::ABSTRACT_TYPE_ONEOF_NAME, LIST_WRAPPER_VALUES_FIELD_NAME, enum_value_prefix(name)
```
- **Timestamps:** most of the cost per `Timestamp` was
`IndexingPreparers::DateTime` re-parsing an ISO 8601 string. The direct
format gives the same output: it truncates to milliseconds and handles
negative `seconds`.
- **Imported message scalars:** the canonical protobuf JSON form omits
zero-valued fields. For example, a `geo_point` scalar with `lat: 0` was
indexed as `{"lon" => 5.5}`.
- **Enum numbers:** decoded messages return known enum values as symbols
on MRI and on JRuby. Only a JRuby `RepeatedField#push(0)` keeps a
number, and only the spec did that.
- **Shared names:** the generator and `RecordPreparer` now use the same
constants for the names that the generator emits. `ProtoPublisher` keeps
its own derivation, so it stays an independent check.
## Evidence
- **Before:** the new imported-message spec failed: `expected
{"location" => {"lat" => 0.0, "lon" => 5.5}}, got {"location" => {"lon"
=> 5.5}}`.
**After:** it passes.
- No existing spec failed under these broken implementations. Each now
fails a new spec:
- The `Timestamp` shortcut ignores the scalar's preparer.
- The shortcut rounds instead of truncating, or computes with a `Float`.
- Treat every message outside `google.protobuf` as an object type.
- List recursion drops the nested mapping below the first list level.
- Presence methods use snake_case names.
- A field named `value` marks a type as abstract.
- **Benchmark:** for one `Timestamp` value on MRI 4.0, preparation takes
2.0 µs on the JSON path and 0.4 µs on the direct format.
## Merge Danger
**Door:** two-way
**Blast Radius:** `elasticgraph-proto_ingestion`. The only effect
outside it is a new optional `proto_paths:` argument on
`SpecSupport::ProtoPublisher`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Copy file name to clipboardExpand all lines: elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/enum_type_extension.rb
Copy file name to clipboardExpand all lines: elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb
0 commit comments