Features of GridDB
Optimized for IoT
A unique key-container model
designed specifically to handle both metadata
and time series data.
High Performance
Utilizing an in-memory data
architecture — along with superb
parallel processing and minimal
overhead — grants benchmark-
shattering performance
High Scalability
Scale out horizontally with
commodity hardware while
maintaining the same
excellent in-memory performance
High Reliability
Non-stop operations even
when tasked with adding
new nodes or when facing
inevitable node failures
GridDB performance
Installation
Java
Connecting to GridDB
Properties props = new Properties();
props.setProperty("notificationMember", "127.0.0.1:10001");
props.setProperty("clusterName", "myCluster");
props.setProperty("user", "admin");
props.setProperty("password", "admin");
GridStore store = GridStoreFactory.getInstance().getGridStore(props);
Creating A TimeSeries Containers
static class Point {
@RowKey Date timestamp;
boolean active;
double voltage;
}
TimeSeries<Point> ts = store.putTimeSeries("point01", Point.class);
Point point = new Point();
point.active = false;
point.voltage = 100;
// Store the time-series element (GridStore sets its timestamp)
ts.append(point);
Date now = TimestampUtils.current();
Date before = TimestampUtils.add(now, -6, TimeUnit.HOUR);
RowSet<Point> rs = ts.query(before, now).fetch();
while (rs.hasNext()) {
point = rs.next();
System.out.println(
"Time=" + TimestampUtils.format(point.timestamp) +
" Active=" + point.active +
" Voltage=" + point.voltage);
}
JDBC
Connecting to GridDB
String notificationMember = "127.0.0.1:20001";
String clusterName = "myCluster";
String databaseName = "public";
String username = "admin";
String password = "admin";
String encodeClusterName = URLEncoder.encode(clusterName, "UTF-8");
String encodeDatabaseName = URLEncoder.encode(databaseName, "UTF-8");
String jdbcUrl = "jdbc:gs://" + notificationMember + "/";
jdbcUrl = jdbcUrl + encodeClusterName + "/" + encodeDatabaseName;
Properties prop = new Properties();
prop.setProperty("user", username);
prop.setProperty("password", password);
System.out.println(jdbcUrl);
con = DriverManager.getConnection(jdbcUrl, prop);
Creating A TimeSeries Containers
String str = "CREATE TABLE device";
str = str+"(ts TIMESTAMP PRIMARY KEY, co DOUBLE,";
str = str+"humidity DOUBLE,light BOOL,lpg DOUBLE,motion BOOL,smoke DOUBLE,temp DOUBLE)";
str = str+" USING TIMESERIES WITH (expiration_type='PARTITION',";
str = str+" expiration_time=90,expiration_time_unit='DAY')";
str = str+" PARTITION BY RANGE (ts) EVERY (60, DAY) SUBPARTITION BY HASH (ts) SUBPARTITIONS 64;";
Statement stmt = con.createStatement();
stmt.executeUpdate("DROP TABLE IF EXISTS device");
stmt.executeUpdate(str);
System.out.println("Successfully created device");
con.close();
Python
Connecting to GridDB
import griddb_python as griddb
factory = griddb.StoreFactory.get_instance()
DB_HOST = "127.0.0.1:10001"
DB_CLUSTER = "myCluster"
DB_USER = "admin"
DB_PASS = "admin"
try:
# (1) Connect to GridDB
# Fixed list method
gridstore = factory.get_store(
notification_member=DB_HOST,
cluster_name=DB_CLUSTER,
username=DB_USER,
password=DB_PASS)
print("Succesfully connected to GridDB!")
except griddb.GSException as e:
for i in range(e.get_error_stack_size()):
print("[", i, "]")
print(e.get_error_code(i))
print(e.get_location(i))
print(e.get_message(i))
Creating A TimeSeries Containers
conInfo = griddb.ContainerInfo(name="device",
column_info_list=[["ts", griddb.Type.TIMESTAMP],
["co", griddb.Type.DOUBLE],
["humidity", griddb.Type.DOUBLE],
["light", griddb.Type.BOOL],
["lpg", griddb.Type.DOUBLE],
["motion", griddb.Type.BOOL],
["smoke", griddb.Type.DOUBLE],
["temperature", griddb.Type.DOUBLE]],
type=griddb.ContainerType.TIME_SERIES)
# Create the container
ts = gridstore.put_container(conInfo)
print(conInfo.name, "container succesfully created")
device = gridstore.get_container("device")
if device == None:
print("ERROR Container not found.")
# Put a single row
device.put(["2022-09-21T12:00:01.234Z", 0.003551, 50.0,
False, 0.00754352, False, 0.0232432, 21.6])
print("Single row successfully inserted!")
node.js
Connecting to GridDB
const griddb = require('griddb-node-api');
var factory = griddb.StoreFactory.getInstance();
var store = factory.getStore({
"notificationMember": "127.0.0.1:10001",
"clusterName": "myCluster",
"username": "admin",
"password": "admin"
});
Creating A TimeSeries Containers
var conInfo = new griddb.ContainerInfo({
'name': "point01",
'columnInfoList': [
["timestamp", griddb.Type.TIMESTAMP],
["active", griddb.Type.BOOL],
["voltage", griddb.Type.DOUBLE]
],
'type': griddb.ContainerType.TIME_SERIES, 'rowKey': true
});
var time_series;
store.putContainer(conInfo, false)
.then(ts => {
time_series = ts;
return ts.put([new Date(), false, 100]);
})
.then(() => {
let str = "select * where timestamp > TIMESTAMPADD(HOUR, NOW(), -6)"
query = time_series.query(str);
return query.fetch();
})
.then(rowset => {
while (rowset.hasNext()) {
var row = rowset.next();
console.log("Time =", row[0],
"Active =", row[1].toString(),
"Voltage =", row[2]);
}
})
.catch(err => {
console.log(err.message);
});
Go
Connecting to GridDB
import griddb "github.com/griddb/go_client"
factory := griddb.StoreFactoryGetInstance()
// Get GridStore object
gridstore, err := factory.GetStore(map[string]interface{}{
"notification_member": "127.0.0.1:10001",
"cluster_name": "myCluster",
"username": "admin",
"password": "admin"})
if err != nil {
fmt.Println(err)
panic("err get store")
}
Creating A TimeSeries Containers
conInfo, err := griddb.CreateContainerInfo(map[string]interface{}{
"name": "todo",
"column_info_list": [][]interface{}{
{"id", griddb.TYPE_INTEGER},
{"title", griddb.TYPE_STRING},
{"completed", griddb.TYPE_BOOL}},
"type": griddb.CONTAINER_COLLECTION,
"row_key": true})
if err != nil {
fmt.Println("Create containerInfo failed, err:", err)
panic("err CreateContainerInfo")
}
_, e := gridstore.PutContainer(conInfo)
if e != nil {
fmt.Println("put container failed, err:", e)
panic("err PutContainer")
}
Web API
Connecting to GridDB
Make an HTTP Request to the specified port (default: 8080)
Creating A Collection Containers
# http://[host]:[port]/griddb/v2/[clusterName]/dbs/public/containers
$ curl -X POST --basic -u admin:admin -H "Content-type:application/json" http://127.0.0.1:8080/griddb/v2/myCluster/dbs/public/containers -d
'{
"container_name": "test",
"container_type": "COLLECTION",
"rowkey": true,
"columns": [
{
"name": "col1",
"type": "STRING",
"index": [
"TREE"
]
},
{
"name": "col2",
"type": "INTEGER"
},
{
"name": "col3",
"type": "BOOL"
}
]
}'
# Append a Row of Data
# http://[host]:[port]/griddb/v2/[clusterName]/dbs/public/containers/[containerName]/rows
$ curl -X PUT --basic -u admin:admin -H "Content-type:application/json" http://127.0.0.1:8080/griddb/v2/myCluster/dbs/public/containers -d
'[["value", 1, true]]'
Ubuntu
Install using apt repository
- sudo sh -c 'echo "deb https://www.griddb.net/apt griddb/5.3 multiverse" >> /etc/apt/sources.list.d/griddb.list'
- wget -qO - https://www.griddb.net/apt/griddb.asc | sudo apt-key add -
- sudo apt update
- sudo apt install griddb-meta
- sudo systemctl start gridstore
Windows (WSL)
First install WSL to your Windows Machine
- Open up a raised (admin privileges) Windows powershell or command prompt
- Enter `wsl --install`
- Detailed instructions for WSL found: here
And then normal Ubuntu instructions
- sudo sh -c 'echo "deb https://www.griddb.net/apt griddb/5.3 multiverse" >> /etc/apt/sources.list.d/griddb.list'
- wget -qO - https://www.griddb.net/apt/griddb.asc | sudo apt-key add -
- sudo apt update
- sudo apt install griddb-meta
- sudo systemctl start gridstore
Docker
After Installing Docker:
- docker network create griddb-net
- docker pull griddbnet/griddb
- docker run --network griddb-net --name griddb-server -d -t griddbnet/griddb
ChromeOS
First enable Linux
- head to your chromebook's settings, find the advanced section, and then developers.
- You will see a setting title "Linux development environment" and select "turn on".
- You will then be greeted with some simple on-screen instructions.
And then normal Ubuntu instructions
- sudo sh -c 'echo "deb https://www.griddb.net/apt griddb/5.3 multiverse" >> /etc/apt/sources.list.d/griddb.list'
- wget -qO - https://www.griddb.net/apt/griddb.asc | sudo apt-key add -
- sudo apt update
- sudo apt install griddb-meta
- sudo systemctl start gridstore