Interface ISymbolIndex
- Namespace
- DatabentoDotNet.Dbn
- Assembly
- DatabentoDotNet.Dbn.dll
Resolves a symbol for a decoded record, without the caller having to know which timestamp the record indexes on or which kind of symbol map is answering. Implemented by TsSymbolMap and PitSymbolMap.
public interface ISymbolIndex
Remarks
Port of upstream's SymbolIndex trait (symbol_map.rs:79-83). It exists so code
can be written against "a symbol map" rather than against one of the two: a live session
keeps a PitSymbolMap updated record by record, a historical request builds a
TsSymbolMap from metadata, and a consumer that wants a symbol for the record in
front of it should not have to care which it was handed.
The two implementations answer differently, and that is the design.
TsSymbolMap keys on the record's own index date; PitSymbolMap
ignores the record's timestamp entirely and keys on the instrument ID alone, because the
caller already committed to one date when the map was built. Both match upstream's own impls
(symbol_map.rs:165-171, 336-340). A PitSymbolMap that started consulting
the record's date would not be a point-in-time map any more.
There is no indexer, deliberately. Upstream pairs get_for_rec with
Index<&R> impls (symbol_map.rs:342-364) that unwrap(), so a
miss panics; a C# indexer carries the same expectation, since that is what
Dictionary<TKey, TValue> does. But a miss here is
routine, not exceptional — a live stream resolves nothing for an instrument until its mapping
record arrives, and a timeseries map holds nothing for a date outside the query's range. An
indexer would make the ordinary case throw, so the whole surface is Try*.
Methods
TryGetSymbol(RecordRef, out string?)
Looks up the symbol for a decoded record.
bool TryGetSymbol(RecordRef record, out string? symbol)
Parameters
recordRecordRefThe record to resolve.
symbolstringReceives the resolved symbol, or null when the map has no mapping for this record.
Returns
Remarks
This is the overload a decoder loop uses, since RecordRef is what
TryNextRecord hands out and no downcast is needed to resolve a symbol.
TryGetSymbol<TRecord>(in TRecord, out string?)
Looks up the symbol for a decoded record of a known type.
bool TryGetSymbol<TRecord>(in TRecord record, out string? symbol) where TRecord : unmanaged, IRecord<TRecord>
Parameters
recordTRecordThe record to resolve.
symbolstringReceives the resolved symbol, or null when the map has no mapping for this record.
Returns
Type Parameters
TRecordThe record struct.
Remarks
For a record that has been downcast or copied out of the read buffer — one held in a collection, say, where no RecordRef survives to call the other overload with. Takes the record by in so a 520-byte InstrumentDefMsg is read in place rather than copied to be asked its symbol.