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
This feature request is to add a method like SymbolTable::get_or_insert()[1] to allow callers to intern symbols that will be reused. For example, in the context of emitting a telemetry stream, there are enums used in every "log entry", like log level, log entry kind, that are known at compile time, and there are frequently used symbols that are computed at runtime, then re-used, like the name of the currently executing function.
Currently the only way I can find to do this is to write_symbol(my_str), then look my_str up in symbol_table() to get the SymbolID; this is less efficient and more awkward than necessary.
Example:
let symbol_id = ion_writer.symbol_table().get_or_insert(my_str);
ion_writer.write(symbol_id)
... time passes ...
ion_writer.write(symbol_id)
[1] This is the functionality I meant to request in #888, but which wasn't clear enough about--the first example showed it, but the second one wasn't as clear as it should have been (sorry!).
The text was updated successfully, but these errors were encountered:
Or do I need to write one, then look it up using the same string (which is a bit of extra complexity on the call side and seems inefficient)?
For now this is what you'll have to do. Registering a new symbol ID needs to go through the writer so it knows to emit a symbol table that includes the new text before referencing it in the data stream. I do want to support this, but it might be a bit before I get around to implementing it.
This feature request is to add a method like
SymbolTable::get_or_insert()
[1] to allow callers to intern symbols that will be reused. For example, in the context of emitting a telemetry stream, there are enums used in every "log entry", like log level, log entry kind, that are known at compile time, and there are frequently used symbols that are computed at runtime, then re-used, like the name of the currently executing function.Currently the only way I can find to do this is to
write_symbol(my_str)
, then lookmy_str
up insymbol_table()
to get theSymbolID
; this is less efficient and more awkward than necessary.Example:
[1] This is the functionality I meant to request in #888, but which wasn't clear enough about--the first example showed it, but the second one wasn't as clear as it should have been (sorry!).
The text was updated successfully, but these errors were encountered: