This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new 8b44f2f7 Release pointer in demo_write.cpp; Fix the error usage of
maven in cpp example (#430)
8b44f2f7 is described below
commit 8b44f2f79578883d6fb43ceb21e44d030f2808f4
Author: Beyyes <[email protected]>
AuthorDate: Mon Mar 10 13:15:36 2025 +0800
Release pointer in demo_write.cpp; Fix the error usage of maven in cpp
example (#430)
* fix README and demo write of cpp
* fix demo_read
* fix example
---
cpp/README.md | 32 +++++++++++++++---------------
cpp/examples/CMakeLists.txt | 2 +-
cpp/examples/README.md | 34 ++++++++++++++++----------------
cpp/examples/cpp_examples/demo_read.cpp | 5 ++---
cpp/examples/cpp_examples/demo_write.cpp | 17 +++++-----------
5 files changed, 41 insertions(+), 49 deletions(-)
diff --git a/cpp/README.md b/cpp/README.md
index abd737a3..b742c4d8 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -1,21 +1,21 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
-->
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index 51126a31..ebe6c66c 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -34,7 +34,7 @@ set(SDK_LIB_DIR_DEBUG
${PROJECT_SOURCE_DIR}/../build/Debug/lib)
message("SDK_LIB_DIR_DEBUG: ${SDK_LIB_DIR_DEBUG}")
include_directories(${PROJECT_SOURCE_DIR}/../third_party/antlr4-cpp-runtime-4/runtime/src)
-set(BUILD_TYPE "Debug")
+set(BUILD_TYPE "Release")
include_directories(${SDK_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
diff --git a/cpp/examples/README.md b/cpp/examples/README.md
index 7b20d5f4..5f5af186 100644
--- a/cpp/examples/README.md
+++ b/cpp/examples/README.md
@@ -1,21 +1,21 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
-->
@@ -29,7 +29,7 @@ Build Methods (Choose either approach)
Execute from the project root directory:
```BASH
-mvn package -P with-cpp clean verify
+mvn clean package verify -P with-cpp
```
Output location: cpp/target/build/lib
diff --git a/cpp/examples/cpp_examples/demo_read.cpp
b/cpp/examples/cpp_examples/demo_read.cpp
index 1b5c982c..20178145 100644
--- a/cpp/examples/cpp_examples/demo_read.cpp
+++ b/cpp/examples/cpp_examples/demo_read.cpp
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
#include <iostream>
#include <string>
#include <vector>
@@ -23,11 +24,9 @@
#include "../c_examples/c_examples.h"
#include "cpp_examples.h"
-using namespace storage;
-
int demo_read() {
int code = 0;
- libtsfile_init();
+ storage::libtsfile_init();
std::string table_name = "table1";
// Create tsfile reader and open tsfile with specify path.
diff --git a/cpp/examples/cpp_examples/demo_write.cpp
b/cpp/examples/cpp_examples/demo_write.cpp
index 594309b7..a9403666 100644
--- a/cpp/examples/cpp_examples/demo_write.cpp
+++ b/cpp/examples/cpp_examples/demo_write.cpp
@@ -17,21 +17,15 @@
* under the License.
*/
-#include <cwrapper/tsfile_cwrapper.h>
-#include <time.h>
#include <writer/tsfile_table_writer.h>
-#include <iostream>
-#include <random>
#include <string>
#include "cpp_examples.h"
-using namespace storage;
-
int demo_write() {
- int code = 0;
- libtsfile_init();
+
+ storage::libtsfile_init();
std::string table_name = "table1";
@@ -56,13 +50,11 @@ int demo_write() {
common::PLAIN, common::ColumnCategory::FIELD),
});
-
-
// Create a file with specify path to write tsfile.
- auto* writer = new TsFileTableWriter(&file, schema);
+ auto* writer = new storage::TsFileTableWriter(&file, schema);
// Create tablet to insert data.
- storage::Tablet tablet = storage::Tablet(
+ storage::Tablet tablet(
table_name, {"id1", "id2", "s1"},
{common::STRING, common::STRING, common::INT64},
{common::ColumnCategory::TAG, common::ColumnCategory::TAG,
@@ -88,6 +80,7 @@ int demo_write() {
HANDLE_ERROR(writer->close());
delete writer;
+ delete schema;
return 0;
}