Skip to content

Commit 8b44f2f

Browse files
authored
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
1 parent 69ff73d commit 8b44f2f

File tree

5 files changed

+41
-49
lines changed

5 files changed

+41
-49
lines changed

cpp/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!--
22
3-
Licensed to the Apache Software Foundation (ASF) under one
4-
or more contributor license agreements. See the NOTICE file
5-
distributed with this work for additional information
6-
regarding copyright ownership. The ASF licenses this file
7-
to you under the Apache License, Version 2.0 (the
8-
"License"); you may not use this file except in compliance
9-
with the License. You may obtain a copy of the License at
10-
11-
http://www.apache.org/licenses/LICENSE-2.0
12-
13-
Unless required by applicable law or agreed to in writing,
14-
software distributed under the License is distributed on an
15-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
KIND, either express or implied. See the License for the
17-
specific language governing permissions and limitations
18-
under the License.
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
1919
2020
-->
2121

cpp/examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ set(SDK_LIB_DIR_DEBUG ${PROJECT_SOURCE_DIR}/../build/Debug/lib)
3434
message("SDK_LIB_DIR_DEBUG: ${SDK_LIB_DIR_DEBUG}")
3535
include_directories(${PROJECT_SOURCE_DIR}/../third_party/antlr4-cpp-runtime-4/runtime/src)
3636

37-
set(BUILD_TYPE "Debug")
37+
set(BUILD_TYPE "Release")
3838
include_directories(${SDK_INCLUDE_DIR})
3939

4040
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")

cpp/examples/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!--
22
3-
Licensed to the Apache Software Foundation (ASF) under one
4-
or more contributor license agreements. See the NOTICE file
5-
distributed with this work for additional information
6-
regarding copyright ownership. The ASF licenses this file
7-
to you under the Apache License, Version 2.0 (the
8-
"License"); you may not use this file except in compliance
9-
with the License. You may obtain a copy of the License at
10-
11-
http://www.apache.org/licenses/LICENSE-2.0
12-
13-
Unless required by applicable law or agreed to in writing,
14-
software distributed under the License is distributed on an
15-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
KIND, either express or implied. See the License for the
17-
specific language governing permissions and limitations
18-
under the License.
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
1919
2020
-->
2121

@@ -29,7 +29,7 @@ Build Methods (Choose either approach)
2929
Execute from the project root directory:
3030

3131
```BASH
32-
mvn package -P with-cpp clean verify
32+
mvn clean package verify -P with-cpp
3333
```
3434
Output location: cpp/target/build/lib
3535

cpp/examples/cpp_examples/demo_read.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
#include <iostream>
2021
#include <string>
2122
#include <vector>
2223

2324
#include "../c_examples/c_examples.h"
2425
#include "cpp_examples.h"
2526

26-
using namespace storage;
27-
2827
int demo_read() {
2928
int code = 0;
30-
libtsfile_init();
29+
storage::libtsfile_init();
3130
std::string table_name = "table1";
3231

3332
// Create tsfile reader and open tsfile with specify path.

cpp/examples/cpp_examples/demo_write.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
#include <cwrapper/tsfile_cwrapper.h>
21-
#include <time.h>
2220
#include <writer/tsfile_table_writer.h>
2321

24-
#include <iostream>
25-
#include <random>
2622
#include <string>
2723

2824
#include "cpp_examples.h"
2925

30-
using namespace storage;
31-
3226
int demo_write() {
33-
int code = 0;
34-
libtsfile_init();
27+
28+
storage::libtsfile_init();
3529

3630
std::string table_name = "table1";
3731

@@ -56,13 +50,11 @@ int demo_write() {
5650
common::PLAIN, common::ColumnCategory::FIELD),
5751
});
5852

59-
60-
6153
// Create a file with specify path to write tsfile.
62-
auto* writer = new TsFileTableWriter(&file, schema);
54+
auto* writer = new storage::TsFileTableWriter(&file, schema);
6355

6456
// Create tablet to insert data.
65-
storage::Tablet tablet = storage::Tablet(
57+
storage::Tablet tablet(
6658
table_name, {"id1", "id2", "s1"},
6759
{common::STRING, common::STRING, common::INT64},
6860
{common::ColumnCategory::TAG, common::ColumnCategory::TAG,
@@ -88,6 +80,7 @@ int demo_write() {
8880
HANDLE_ERROR(writer->close());
8981

9082
delete writer;
83+
delete schema;
9184

9285
return 0;
9386
}

0 commit comments

Comments
 (0)