コード例 #1
0
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()
}
コード例 #2
0
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()
}
コード例 #3
0
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()
}
コード例 #4
0
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()
}