MCPcopy Create free account
hub / github.com/apache/iotdb-client-go / createTablet

Function createTablet

example/session_example.go:493–537  ·  view source on GitHub ↗
(rowCount int)

Source from the content-addressed store, hash-verified

491}
492
493func createTablet(rowCount int) (*client.Tablet, error) {
494 tablet, err := client.NewTablet("root.ln.device1", []*client.MeasurementSchema{
495 {
496 Measurement: "restart_count",
497 DataType: client.INT32,
498 }, {
499 Measurement: "price",
500 DataType: client.DOUBLE,
501 }, {
502 Measurement: "tick_count",
503 DataType: client.INT64,
504 }, {
505 Measurement: "temperature",
506 DataType: client.FLOAT,
507 }, {
508 Measurement: "description",
509 DataType: client.TEXT,
510 },
511 {
512 Measurement: "status",
513 DataType: client.BOOLEAN,
514 },
515 }, rowCount)
516
517 if err != nil {
518 return nil, err
519 }
520 ts := time.Now().UTC().UnixNano() / 1000000
521 for row := 0; row < int(rowCount); row++ {
522 ts++
523 tablet.SetTimestamp(ts, row)
524 tablet.SetValueAt(rand.Int31(), 0, row)
525 if row%2 == 1 {
526 tablet.SetValueAt(rand.Float64(), 1, row)
527 } else {
528 tablet.SetValueAt(nil, 1, row)
529 }
530 tablet.SetValueAt(rand.Int63(), 2, row)
531 tablet.SetValueAt(rand.Float32(), 3, row)
532 tablet.SetValueAt(fmt.Sprintf("Test Device %d", row+1), 4, row)
533 tablet.SetValueAt(bool(ts%2 == 0), 5, row)
534 tablet.RowSize++
535 }
536 return tablet, nil
537}
538
539func insertTablets() {
540 tablet1, err := createTablet(8)

Callers 4

insertTabletFunction · 0.70
insertAlignedTabletFunction · 0.70
insertTabletsFunction · 0.70
insertAlignedTabletsFunction · 0.70

Calls 3

SetTimestampMethod · 0.95
SetValueAtMethod · 0.95
NewTabletFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…