Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/client-cpp-example/src/TableModelSessionExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using namespace std;

TableSession *session;
shared_ptr<TableSession> session;

void insertRelationalTablet() {

Expand Down Expand Up @@ -203,8 +203,6 @@ int main() {
cout << "session close\n" << endl;
session->close();

delete session;

cout << "finished!\n" << endl;
} catch (IoTDBConnectionException &e) {
cout << e.what() << endl;
Expand Down
6 changes: 3 additions & 3 deletions iotdb-client/client-cpp/src/main/SessionBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class SessionBuilder : public AbstractSessionBuilder {
return this;
}

Session* build() {
std::shared_ptr<Session> build() {
sqlDialect = "tree";
Session* newSession = new Session(this);
auto newSession = std::make_shared<Session>(this);
newSession->open(false);
return newSession;
}
}
};

#endif // IOTDB_SESSION_BUILDER_H
12 changes: 4 additions & 8 deletions iotdb-client/client-cpp/src/main/TableSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@

class TableSession {
private:
Session* session_;
std::shared_ptr<Session> session_;
string getDatabase();
public:
TableSession(Session* session) {
TableSession(std::shared_ptr<Session> session) {
this->session_ = session;
}
~TableSession() {
if (session_) {
delete session_;
session_ = nullptr;
}
}
~TableSession() {}

void insert(Tablet& tablet, bool sorted = false);
void executeNonQueryStatement(const std::string& sql);
unique_ptr<SessionDataSet> executeQueryStatement(const std::string& sql);
Expand Down
6 changes: 3 additions & 3 deletions iotdb-client/client-cpp/src/main/TableSessionBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class TableSessionBuilder : public AbstractSessionBuilder {
AbstractSessionBuilder::nodeUrls = nodeUrls;
return this;
}
TableSession* build() {
std::shared_ptr<TableSession> build() {
sqlDialect = "table";
Session* newSession = new Session(this);
auto newSession = std::make_shared<Session>(this);
newSession->open(false);
return new TableSession(newSession);
return std::make_shared<TableSession>(newSession);
}
};

Expand Down
Loading