MCPcopy Create free account
hub / github.com/ByConity/ByConity / allocate

Method allocate

src/QueryPlan/TableScanStep.cpp:1775–1821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1773}
1774
1775void TableScanStep::allocate(ContextPtr context)
1776{
1777 // init query_info.syntax_analyzer
1778 if (!query_info.syntax_analyzer_result)
1779 {
1780 auto storage_snapshot = storage->getStorageSnapshot(storage->getInMemoryMetadataPtr(), context);
1781 Block header = storage_snapshot->getSampleBlockForColumns(getRequiredColumns());
1782
1783 auto tree_rewriter_result
1784 = std::make_shared<TreeRewriterResult>(header.getNamesAndTypesList(), storage, storage_snapshot);
1785 tree_rewriter_result->required_source_columns = header.getNamesAndTypesList();
1786 tree_rewriter_result->analyzed_join = std::make_shared<TableJoin>();
1787 query_info.syntax_analyzer_result = tree_rewriter_result;
1788 }
1789
1790 query_info = fillQueryInfo(context);
1791 original_table = storage_id.table_name;
1792 storage_id = storage->prepareTableRead(getRequiredColumns(), query_info, context);
1793 size_t shards = context->tryGetCurrentWorkerGroup() ? context->getCurrentWorkerGroup()->getShardsInfo().size() : 1;
1794 if (shards > 1 && !context->getSettingsRef().enable_final_sample)
1795 {
1796 ASTSelectQuery * select = query_info.query->as<ASTSelectQuery>();
1797 if (select && select->sampleSize())
1798 query_info.query = rewriteSampleForDistributedTable(query_info.query, shards);
1799 }
1800
1801 // update query info
1802 if (query_info.query)
1803 {
1804 /// trigger preallocate tables
1805 // if (!cnch->isOnDemandMode())
1806 // cnch->read(column_names, query_info, context, processed_stage, max_block_size, 1);
1807 // cnch->genPlanSegmentQueryAndAllocate(column_names, query_info, context);
1808 auto db_table = getDatabaseAndTable(query_info.query->as<ASTSelectQuery &>(), 0);
1809 if (!db_table->table.empty())
1810 {
1811 if (db_table->table != storage_id.table_name)
1812 {
1813 if (query_info.query)
1814 {
1815 ASTSelectQuery & select_query = query_info.query->as<ASTSelectQuery &>();
1816 select_query.replaceDatabaseAndTable(storage_id);
1817 }
1818 }
1819 }
1820 }
1821}
1822
1823bool TableScanStep::hasLimit() const
1824{

Callers 8

cJSON_strdupFunction · 0.45
cJSON_New_ItemFunction · 0.45
ensureFunction · 0.45
parse_stringFunction · 0.45
printFunction · 0.45
cJSON_PrintBufferedFunction · 0.45
cJSON_mallocFunction · 0.45
allocateLocalTableMethod · 0.45

Calls 13

getDatabaseAndTableFunction · 0.85
getCurrentWorkerGroupMethod · 0.80
sampleSizeMethod · 0.80
getStorageSnapshotMethod · 0.45
getNamesAndTypesListMethod · 0.45
prepareTableReadMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected