File tree Expand file tree Collapse file tree 6 files changed +45
-3
lines changed
contrib/google-cloud-cpp-cmake Expand file tree Collapse file tree 6 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWIT
159159endif ()
160160
161161option (ENABLE_TESTS "Provide unit_test_dbms target with Google.Test unit tests" ON )
162- option (ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" OFF )
162+ option (ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" ON )
163163option (ENABLE_BENCHMARKS "Build all benchmark programs in 'benchmarks' subdirectories" OFF )
164164
165165if (OS_LINUX AND (ARCH_AMD64 OR ARCH_AARCH64) AND NOT USE_MUSL)
Original file line number Diff line number Diff line change @@ -172,6 +172,8 @@ def main():
172172 run_shell ("clang-tidy-cache stats" , "clang-tidy-cache --show-stats" )
173173 else :
174174 targets = "clickhouse-bundle"
175+
176+ targets += " gcs"
175177 results .append (
176178 Result .from_commands_run (
177179 name = "Build ClickHouse" ,
Original file line number Diff line number Diff line change 1414
1515LC_ALL=" en_US.UTF-8"
1616ROOT_PATH=" ."
17- EXCLUDE=' build/|integration/|widechar_width/|glibc-compatibility/|poco/|memcpy/|consistent-hashing|benchmark|tests/.*.cpp|programs/keeper-bench/example.yaml|base/base/openpty.h'
17+ EXCLUDE=' build/|integration/|widechar_width/|glibc-compatibility/|poco/|memcpy/|consistent-hashing|benchmark|tests/.*.cpp|programs/keeper-bench/example.yaml|base/base/openpty.h|gcs.cpp '
1818EXCLUDE_DOCS=' Settings\.cpp|FormatFactorySettings\.h'
1919
2020# From [1]:
Original file line number Diff line number Diff line change 1- set (ENABLE_GOOGLE_CLOUD_CPP_DEFAULT OFF )
1+ set (ENABLE_GOOGLE_CLOUD_CPP_DEFAULT ON )
22
33if (ENABLE_LIBRARIES AND CLICKHOUSE_CLOUD AND OS_LINUX)
44 set (ENABLE_GOOGLE_CLOUD_CPP_DEFAULT ON )
Original file line number Diff line number Diff line change @@ -6,3 +6,6 @@ target_link_libraries (field PRIVATE dbms)
66
77clickhouse_add_executable (string_ref_hash string_ref_hash.cpp )
88target_link_libraries (string_ref_hash PRIVATE clickhouse_common_io clickhouse_common_config )
9+
10+ clickhouse_add_executable (gcs gcs.cpp )
11+ target_link_libraries (gcs PRIVATE clickhouse_common_io clickhouse_common_config dbms )
Original file line number Diff line number Diff line change 1+ #include < google/cloud/storage/client.h>
2+ #include < iostream>
3+ #include < string>
4+
5+ int main (int argc, char * argv[]) {
6+ if (argc != 2 ) {
7+ std::cerr << " Missing bucket name.\n " ;
8+ std::cerr << " Usage: quickstart <bucket-name>\n " ;
9+ return 1 ;
10+ }
11+ std::string const bucket_name = argv[1 ];
12+
13+ // Create a client to communicate with Google Cloud Storage. This client
14+ // uses the default configuration for authentication and project id.
15+ auto client = google::cloud::storage::Client ();
16+
17+ auto writer = client.WriteObject (bucket_name, " quickstart.txt" );
18+ writer << " Hello World!" ;
19+ writer.Close ();
20+ if (!writer.metadata ()) {
21+ std::cerr << " Error creating object: " << writer.metadata ().status ()
22+ << " \n " ;
23+ return 1 ;
24+ }
25+ std::cout << " Successfully created object: " << *writer.metadata () << " \n " ;
26+
27+ auto reader = client.ReadObject (bucket_name, " quickstart.txt" );
28+ if (!reader) {
29+ std::cerr << " Error reading object: " << reader.status () << " \n " ;
30+ return 1 ;
31+ }
32+
33+ std::string contents{std::istreambuf_iterator<char >{reader}, {}};
34+ std::cout << contents << " \n " ;
35+
36+ return 0 ;
37+ }
You can’t perform that action at this time.
0 commit comments