31 const std::vector<std::string>& columnNames) {
35 const auto tableInfo = td->
fragmenter->getFragmentsForQuery();
36 if (tableInfo.fragments.size() == 0) {
37 throw std::runtime_error(
"No fragments in table '" + td->
tableName +
"'");
41 for (
const auto& fragment : tableInfo.fragments) {
44 std::get<0>(table.back()) = 0;
47 bool isFirstColumn =
true;
48 for (
const auto& columnName : columnNames) {
52 throw std::runtime_error(
"Failed to find physical column '" + columnName +
"'");
58 auto chunkMetaIt = fragment.getChunkMetadataMap().find(cd->columnId);
59 if (chunkMetaIt == fragment.getChunkMetadataMap().end()) {
60 throw std::runtime_error(
"Failed to find the chunk for column: " +
61 cd->columnName +
" in table: " + td->
tableName +
62 ". The column was likely deleted via a table truncate.");
66 std::shared_ptr<Chunk_NS::Chunk> chunk =
72 chunkMetaIt->second->numBytes,
73 chunkMetaIt->second->numElements);
77 size_t chunkSize = chunkMetaIt->second->numElements;
80 ChunkIter chunkIt = chunk->begin_iterator(chunkMetaIt->second);
85 std::get<0>(table.back()) = chunkSize;
86 isFirstColumn =
false;
89 CHECK(std::get<0>(table.back()) == chunkSize);
91 std::get<1>(table.back()).push_back(chunk);
92 std::get<2>(table.back()).push_back(chunkIt);
99 for (
auto& entry : table) {
100 sum += std::get<0>(entry);
101 std::get<0>(entry) = sum;
112 for (
auto& entry : table) {
113 if (rowid < std::get<0>(entry)) {
114 return std::get<2>(entry);
116 rowOffset = std::get<0>(entry);
120 return emptyChunkIterVector;
std::vector< int > ChunkKey
ChunkAccessorTable getChunkAccessorTable(const Catalog_Namespace::Catalog &cat, const TableDescriptor *td, const std::vector< std::string > &columnNames)
class for a per-database catalog. also includes metadata for the current database and the current use...
Data_Namespace::DataMgr & getDataMgr() const
This file contains the class specification and related data structures for Catalog.
ChunkIterVector & getChunkItersAndRowOffset(ChunkAccessorTable &table, size_t rowid, size_t &rowOffset)
const DBMetadata & getCurrentDB() const
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
std::vector< ChunkIter > ChunkIterVector
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
std::vector< std::tuple< size_t, std::vector< std::shared_ptr< Chunk_NS::Chunk >>, ChunkIterVector >> ChunkAccessorTable
static std::shared_ptr< Chunk > getChunk(const ColumnDescriptor *cd, DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId, const size_t num_bytes, const size_t num_elems, const bool pinnable=true)