Skip to content

Commit

Permalink
createFileWriterWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaichen committed Jul 4, 2024
1 parent c73dcfc commit dcf9ec2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cpp-ch/local-engine/Storages/Output/FileWriterWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void NormalFileWriter::close()
writer->finish();
}

FileWriterWrapper *
createFileWriterWrapper(const std::string & file_uri, const std::vector<std::string> & preferred_column_names, const std::string & format_hint)
std::unique_ptr<FileWriterWrapper>
createFileWriterWrapper(const std::string & file_uri, const DB::Names & preferred_column_names, const std::string & format_hint)
{
// the passed in file_uri is exactly what is expected to see in the output folder
// e.g /xxx/中文/timestamp_field=2023-07-13 03%3A00%3A17.622/abc.parquet
Expand All @@ -66,7 +66,7 @@ createFileWriterWrapper(const std::string & file_uri, const std::vector<std::str
auto context = DB::Context::createCopy(local_engine::SerializedPlanParser::global_context);
auto write_buffer_builder = WriteBufferBuilderFactory::instance().createBuilder(poco_uri.getScheme(), context);
auto file = OutputFormatFileUtil::createFile(context, write_buffer_builder, encoded, preferred_column_names, format_hint);
return new NormalFileWriter(file, context);
return std::make_unique<NormalFileWriter>(file, context);
}

}
4 changes: 2 additions & 2 deletions cpp-ch/local-engine/Storages/Output/FileWriterWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ class NormalFileWriter : public FileWriterWrapper
std::unique_ptr<DB::PushingPipelineExecutor> writer;
};

FileWriterWrapper *
createFileWriterWrapper(const std::string & file_uri, const std::vector<std::string> & preferred_column_names, const std::string & format_hint);
std::unique_ptr<FileWriterWrapper>
createFileWriterWrapper(const std::string & file_uri, const DB::Names & preferred_column_names, const std::string & format_hint);
}
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/local_engine_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ JNIEXPORT jlong Java_org_apache_spark_sql_execution_datasources_CHDatasourceJniW
auto file_uri = jstring_to_cstring(env, file_uri_);
auto format_hint = jstring_to_cstring(env, format_hint_);
// for HiveFileFormat, the file url may not end with .parquet, so we pass in the format as a hint
auto * writer = local_engine::createFileWriterWrapper(file_uri, names, format_hint);
auto * writer = local_engine::createFileWriterWrapper(file_uri, names, format_hint).release();
return reinterpret_cast<jlong>(writer);
LOCAL_ENGINE_JNI_METHOD_END(env, 0)
}
Expand Down

0 comments on commit dcf9ec2

Please sign in to comment.