4994 const auto&
cat = loader->getCatalog();
4997 LOG(
INFO) <<
"DEBUG: Table is a foreign table";
4999 _rtree = std::make_unique<RTree>();
5004 const std::string& tableName = loader->getTableDesc()->tableName;
5005 const auto td =
cat.getMetadataForTable(tableName);
5007 CHECK(td->fragmenter);
5010 if (td->fragmenter->getFragmentsForQuery().getPhysicalNumTuples() == 0) {
5012 LOG(
INFO) <<
"DEBUG: Table is empty!";
5014 _rtree = std::make_unique<RTree>();
5020 const auto cd_bounds =
5021 cat.getMetadataForColumn(td->tableId, geoColumnBaseName +
"_bounds");
5022 const auto cd_render_group =
5023 cat.getMetadataForColumn(td->tableId, geoColumnBaseName +
"_render_group");
5024 if (!cd_bounds || !cd_render_group) {
5025 throw std::runtime_error(
"RenderGroupAnalyzer: Table " + tableName +
5026 " doesn't have bounds or render_group columns!");
5030 if (cd_bounds->columnType.get_type() !=
kARRAY ||
5031 cd_bounds->columnType.get_subtype() !=
kDOUBLE) {
5032 throw std::runtime_error(
"RenderGroupAnalyzer: Table " + tableName +
5033 " bounds column is wrong type!");
5035 if (cd_render_group->columnType.get_type() !=
kINT) {
5036 throw std::runtime_error(
"RenderGroupAnalyzer: Table " + tableName +
5037 " render_group column is wrong type!");
5042 cat, td, {geoColumnBaseName +
"_bounds", geoColumnBaseName +
"_render_group"});
5043 const auto table_count = std::get<0>(chunkAccessorTable.back());
5046 LOG(
INFO) <<
"DEBUG: Scanning existing table geo column set '" << geoColumnBaseName
5050 std::vector<Node> nodes;
5052 nodes.resize(table_count);
5053 }
catch (
const std::exception& e) {
5054 throw std::runtime_error(
"RenderGroupAnalyzer failed to reserve memory for " +
5058 for (
size_t row = 0; row < table_count; row++) {
5064 size_t rowOffset = 0;
5066 auto& boundsChunkIter = chunkIters[0];
5067 auto& renderGroupChunkIter = chunkIters[1];
5073 int numBounds = (int)(ad.length /
sizeof(
double));
5074 CHECK(numBounds == 4);
5077 double* bounds =
reinterpret_cast<double*
>(ad.pointer);
5079 boost::geometry::assign_inverse(bounding_box);
5080 boost::geometry::expand(bounding_box,
Point(bounds[0], bounds[1]));
5081 boost::geometry::expand(bounding_box,
Point(bounds[2], bounds[3]));
5087 int renderGroup = *
reinterpret_cast<int32_t*
>(vd.
pointer);
5090 if (renderGroup < 0) {
5095 nodes[row] = std::make_pair(bounding_box, renderGroup);
5103 LOG(
INFO) <<
"DEBUG: Existing row " << row <<
" has Render Group " << renderGroup;
5109 _rtree = std::make_unique<RTree>(nodes);
5111 LOG(
INFO) <<
"Scanning render groups of poly column '" << geoColumnBaseName
5112 <<
"' of table '" << tableName <<
"' took " <<
timer_stop(seedTimer) <<
"ms ("
5113 <<
timer_stop(bulk_load_timer) <<
" ms for tree)";
ChunkAccessorTable getChunkAccessorTable(const Catalog_Namespace::Catalog &cat, const TableDescriptor *td, const std::vector< std::string > &columnNames)
TypeR::rep timer_stop(Type clock_begin)
DEVICE void ChunkIter_get_nth(ChunkIter *it, int n, bool uncompress, VarlenDatum *result, bool *is_end)
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
ChunkIterVector & getChunkItersAndRowOffset(ChunkAccessorTable &table, size_t rowid, size_t &rowOffset)
#define DEBUG_RENDER_GROUP_ANALYZER
boost::geometry::model::box< Point > BoundingBox
std::unique_ptr< RTree > _rtree
static constexpr char const * FOREIGN_TABLE
boost::geometry::model::point< double, 2, boost::geometry::cs::cartesian > Point