func importCSVOnTable(bigtableClientConnData gbigtable.ClientConnectionData, csvFilePath string, tableName string) { client := gbigtable.OpenClient( gbigtable.GetContext(300*time.Second), bigtableClientConnData) bgTable := gbigtable.OpenTable( tableName, client) fmt.Println("Start processCSVFile ...") var strColumns []string csvprocessor.ProcessCSVFile(csvFilePath, ',', func(headerData []string) { strColumns = headerData }, func(lineData []string) { gbigtable.WriteRow( gbigtable.GetContext(300*time.Second), bgTable, "__", lineData[0], strColumns, lineData, 1) }) defer client.Close() }
func printRowFromTable(bigtableClientConnData gbigtable.ClientConnectionData, tableName string, rowKey string) { client := gbigtable.OpenClient( gbigtable.GetContext(300*time.Second), bigtableClientConnData) table := gbigtable.OpenTable( tableName, client) ctx := gbigtable.GetContext(300 * time.Second) dtRow := gbigtable.ReadRow(ctx, table, rowKey) jsonString, err := json.Marshal(dtRow) fmt.Println(string(jsonString), err) defer client.Close() }
func printFilteredRowsFromTable(bigtableClientConnData gbigtable.ClientConnectionData, tableName string, rowRange bigtable.RowRange, opts []bigtable.ReadOption) { client := gbigtable.OpenClient( gbigtable.GetContext(300*time.Second), bigtableClientConnData) table := gbigtable.OpenTable( tableName, client) ctx := gbigtable.GetContext(300 * time.Second) gbigtable.ReadRows(ctx, table, rowRange, func(dtRow gbigtable.DtRow) { jsonString, err := json.Marshal(dtRow) fmt.Println(string(jsonString), err) }, opts...) defer client.Close() }
func printAllRowsFromTable(bigtableClientConnData gbigtable.ClientConnectionData, tableName string) { client := gbigtable.OpenClient( gbigtable.GetContext(300*time.Second), bigtableClientConnData) table := gbigtable.OpenTable( tableName, client) ctx := gbigtable.GetContext(300 * time.Second) gbigtable.ReadAllRows(ctx, table, func(dtRow gbigtable.DtRow) { jsonString, err := json.Marshal(dtRow) fmt.Println(string(jsonString), err) }) defer client.Close() }