MCPcopy Index your code
hub / github.com/apache/iotdb-client-go

github.com/apache/iotdb-client-go @v2.0.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.8 ↗ · + Follow
4,152 symbols 8,006 edges 33 files 397 documented · 10% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

English | 中文

Apache IoTDB

Apache IoTDB (Database for Internet of Things) is an IoT native database with high performance for data management and analysis, deployable on the edge and the cloud. Due to its light-weight architecture, high performance and rich feature set together with its deep integration with Apache Hadoop, Spark and Flink, Apache IoTDB can meet the requirements of massive data storage, high-speed data ingestion and complex data analysis in the IoT industrial fields.

Apache IoTDB Client for Go

E2E Tests GitHub release License IoTDB Website

Overview

This is the GoLang client of Apache IoTDB.

Apache IoTDB website: https://iotdb.apache.org Apache IoTDB GitHub: https://github.com/apache/iotdb

Prerequisites

golang >= 1.13

How to Use the Client (Quick Start)

With go mod

export GO111MODULE=on
export GOPROXY=https://goproxy.io

mkdir session_example && cd session_example

curl -o session_example.go -L https://github.com/apache/iotdb-client-go/raw/main/example/session_example.go

go mod init session_example
go run session_example.go

Without go mod

# get thrift 0.15.0
go get github.com/apache/thrift
cd $GOPATH/src/github.com/apache/thrift
git checkout 0.15.0

mkdir -p $GOPATH/src/iotdb-client-go-example/session_example
cd $GOPATH/src/iotdb-client-go-example/session_example

curl -o session_example.go -L https://github.com/apache/iotdb-client-go/raw/main/example/session_example.go
go run session_example.go

How to Use the SessionPool

SessionPool is a wrapper of a Session Set. Using SessionPool, the user do not need to consider how to reuse a session connection. If there is no available connections and the pool reaches its max size, the all methods will hang until there is a available connection. The PutBack method must be called after use

New sessionPool

standalone


config := &client.PoolConfig{
    Host:     host,
    Port:     port,
    UserName: user,
    Password: password,
}
sessionPool = client.NewSessionPool(config, 3, 60000, 60000, false)

cluster or doubleLive


config := &client.PoolConfig{
  UserName: user,
  Password: password,
  NodeUrls: strings.Split("127.0.0.1:6667,127.0.0.1:6668", ","),
 }
sessionPool = client.NewSessionPool(config, 3, 60000, 60000, false)

Get session through sessionPool, putback after use

set storage group


session, err := sessionPool.GetSession()
defer sessionPool.PutBack(session)
if err == nil {
    session.SetStorageGroup(sg)
}

query statement


var timeout int64 = 1000
session, err := sessionPool.GetSession()
defer sessionPool.PutBack(session)
if err != nil {
    log.Print(err)
    return
}
sessionDataSet, err := session.ExecuteQueryStatement(sql, &timeout)
if err == nil {
    defer sessionDataSet.Close()
    printDataSet1(sessionDataSet)
} else {
    log.Println(err)
}

Developer environment requirements for iotdb-client-go

OS

  • Linux, Macos or other unix-like OS
  • Windows+bash(WSL, cygwin, Git Bash)

Command Line Tools

  • golang >= 1.13
  • make >= 3.0
  • curl >= 7.1.1
  • thrift 0.15.0

Troubleshooting

Thrift version compatibility issues

In the branch rel/0.13 and earlier versions, the version of apache/thrift is v0.14.1. In the latest version, apache/thrift has been upgraded to v0.15.0.

The two versions are not compatible on some interfaces. Using mismatched version will cause compilation errors.

The interfaces changed in the two versions are as follows:

  1. NewTSocketConf. This function returns two values in the version v0.14.1 and only one value in the version v0.15.0.
  2. NewTFramedTransport has been deprecated, use NewTFramedTransportConf instead.

For more details, please take a look at this PR: update thrift to 0.15.0 to fit IoTDB 0.13.0

Parameter name mismatch with actual usage in function 'Open'

The implementation of the function client/session.go/Open() is mismatched with the description. The parameter connectionTimeoutInMs represents connection timeout in milliseconds. However, in the older version, this function did not implement correctly, regarding it as nanosecond instead. The bug is now fixed. Positive value of this parameter means connection timeout in milliseconds. Set 0 for no timeout.

Extension points exported contracts — how you extend this code

ColumnDecoder (Interface)
(no doc) [5 implementers]
client/column_decoder.go
ITableSession (Interface)
ITableSession defines an interface for interacting with IoTDB tables. It supports operations such as data insertion, exe [2 …
client/tablesession.go
Column (Interface)
(no doc) [1 implementers]
client/column.go
IClientRPCService (Interface)
(no doc) [1 implementers]
rpc/client.go

Core symbols most depended-on inside this repo

Write
called by 280
rpc/client.go
Error
called by 151
client/errors.go
Read
called by 140
rpc/client.go
SetValueAt
called by 95
client/tablet.go
Close
called by 72
client/tablesession.go
Write
called by 70
common/common.go
Client_
called by 69
rpc/client.go
SetLastResponseMeta_
called by 69
rpc/client.go

Shape

Method 3,343
Function 440
Struct 348
TypeAlias 17
Interface 4

Languages

Go100%

Modules by API surface

rpc/client.go2,916 symbols
common/common.go646 symbols
client/column.go141 symbols
client/rpcdataset.go63 symbols
client/session.go61 symbols
example/session_example.go35 symbols
example/session_pool/session_pool_example.go33 symbols
client/sessiondataset.go30 symbols
client/utils.go25 symbols
test/e2e/e2e_test.go24 symbols
client/tablet.go19 symbols
test/e2e/e2e_table_test.go15 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add iotdb-client-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact