in example/table/table_session_example.go [68:117]
func insertRelationalTablet(session client.ITableSession) {
tablet, err := client.NewRelationalTablet("t1", []*client.MeasurementSchema{
{
Measurement: "tag1",
DataType: client.STRING,
},
{
Measurement: "tag2",
DataType: client.STRING,
},
{
Measurement: "s1",
DataType: client.TEXT,
},
{
Measurement: "s2",
DataType: client.TEXT,
},
}, []client.ColumnCategory{client.TAG, client.TAG, client.FIELD, client.FIELD}, 1024)
if err != nil {
log.Fatal("Failed to create relational tablet {}", err)
}
ts := time.Now().UTC().UnixNano() / 1000000
for row := 0; row < 16; row++ {
ts++
tablet.SetTimestamp(ts, row)
tablet.SetValueAt("tag1_value_"+strconv.Itoa(row), 0, row)
tablet.SetValueAt("tag2_value_"+strconv.Itoa(row), 1, row)
tablet.SetValueAt("s1_value_"+strconv.Itoa(row), 2, row)
tablet.SetValueAt("s2_value_"+strconv.Itoa(row), 3, row)
tablet.RowSize++
}
checkError(session.Insert(tablet))
tablet.Reset()
for row := 0; row < 16; row++ {
ts++
tablet.SetTimestamp(ts, row)
tablet.SetValueAt("tag1_value_1", 0, row)
tablet.SetValueAt("tag2_value_1", 1, row)
tablet.SetValueAt("s1_value_"+strconv.Itoa(row), 2, row)
tablet.SetValueAt("s2_value_"+strconv.Itoa(row), 3, row)
nullValueColumn := rand.Intn(4)
tablet.SetValueAt(nil, nullValueColumn, row)
tablet.RowSize++
}
checkError(session.Insert(tablet))
}