Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed Mar 4, 2024
1 parent 0f5dd6a commit d5be6fa
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,11 @@ DB::Array ApproxPercentileParser::parseFunctionParameters(
}
}

DB::Array ApproxPercentileParser::getDefaultFunctionParameters() const
{
return {10000, 1};
}


static const AggregateFunctionParserRegister<ApproxPercentileParser> register_approx_percentile;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ class ApproxPercentileParser : public AggregateFunctionParser

DB::Array
parseFunctionParameters(const CommonFunctionInfo & /*func_info*/, DB::ActionsDAG::NodeRawConstPtrs & arg_nodes) const override;

DB::Array getDefaultFunctionParameters() const override;
};
}
}
2 changes: 0 additions & 2 deletions cpp-ch/local-engine/Storages/IO/NativeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ DB::Block NativeReader::read()
if (columns_parse_util.empty())
{
result_block = prepareByFirstBlock();
std::cout << "first block:" << result_block.dumpStructure() << std::endl;
if (!result_block)
return {};
}
Expand Down Expand Up @@ -184,7 +183,6 @@ DB::Block NativeReader::prepareByFirstBlock()
{
agg_opt_column = true;
real_type_name = type_name.substr(0, type_name.length() - NativeWriter::AGG_STATE_SUFFIX.length());
std::cout << "real_type_name:" << real_type_name << std::endl;
}
column.type = data_type_factory.get(real_type_name);
auto nested_type = DB::removeNullable(column.type);
Expand Down
61 changes: 30 additions & 31 deletions cpp-ch/local-engine/Storages/SourceFromJavaIter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,41 @@ DB::Chunk SourceFromJavaIter::generate()
SCOPE_EXIT({CLEAN_JNIENV});

DB::Chunk result;
jboolean has_next = safeCallBooleanMethod(env, java_iter, serialized_record_batch_iterator_hasNext);
if (has_next)
DB::Block * data = nullptr;
if (first_block) [[unlikely]]
{
data = first_block;
first_block = nullptr;
}
else if (jboolean has_next = safeCallBooleanMethod(env, java_iter, serialized_record_batch_iterator_hasNext))
{
DB::Block * data = nullptr;
if (first_block) [[unlikely]]
jbyteArray block = static_cast<jbyteArray>(safeCallObjectMethod(env, java_iter, serialized_record_batch_iterator_next));
data = reinterpret_cast<DB::Block *>(byteArrayToLong(env, block));
}
else
return {};

/// Post-processing
if (materialize_input)
materializeBlockInplace(*data);

if (data->rows() > 0)
{
size_t rows = data->rows();
if (original_header.columns())
{
data = first_block;
first_block = nullptr;
result.setColumns(data->mutateColumns(), rows);
convertNullable(result);
auto info = std::make_shared<DB::AggregatedChunkInfo>();
info->is_overflows = data->info.is_overflows;
info->bucket_num = data->info.bucket_num;
result.setChunkInfo(info);
}
else
{
jbyteArray block = static_cast<jbyteArray>(safeCallObjectMethod(env, java_iter, serialized_record_batch_iterator_next));
data = reinterpret_cast<DB::Block *>(byteArrayToLong(env, block));
}

if (materialize_input)
materializeBlockInplace(*data);

if (data->rows() > 0)
{
size_t rows = data->rows();
if (original_header.columns())
{
result.setColumns(data->mutateColumns(), rows);
convertNullable(result);
auto info = std::make_shared<DB::AggregatedChunkInfo>();
info->is_overflows = data->info.is_overflows;
info->bucket_num = data->info.bucket_num;
result.setChunkInfo(info);
}
else
{
result = BlockUtil::buildRowCountChunk(rows);
auto info = std::make_shared<DB::AggregatedChunkInfo>();
result.setChunkInfo(info);
}
result = BlockUtil::buildRowCountChunk(rows);
auto info = std::make_shared<DB::AggregatedChunkInfo>();
result.setChunkInfo(info);
}
}
return result;
Expand Down
1 change: 1 addition & 0 deletions cpp-ch/local-engine/compile_commands.json

0 comments on commit d5be6fa

Please sign in to comment.