| 236 | } |
| 237 | |
| 238 | Expected<SeriesReader> DataReader::series(TopicId topic_id, std::size_t column_index) const { |
| 239 | auto lock = engine_.lockEngine(); |
| 240 | const TopicStorage* storage = engine_.getTopicStorage(topic_id); |
| 241 | if (storage == nullptr) { |
| 242 | return PJ::unexpected(fmt::format("Topic {} not found", topic_id)); |
| 243 | } |
| 244 | |
| 245 | const std::vector<ColumnDescriptor> columns = columnsForTopic(engine_, *storage); |
| 246 | if (column_index >= columns.size()) { |
| 247 | return PJ::unexpected(fmt::format("Column {} not found in topic {}", column_index, topic_id)); |
| 248 | } |
| 249 | |
| 250 | if (!isSeriesValueType(columns[column_index].logical_type)) { |
| 251 | return PJ::unexpected(fmt::format("Column {} in topic {} is not a numeric series", column_index, topic_id)); |
| 252 | } |
| 253 | |
| 254 | return SeriesReader(storage->sealedChunks(), column_index, storage->retentionFloor(), std::move(lock)); |
| 255 | } |
| 256 | |
| 257 | } // namespace PJ |