MCPcopy
hub / github.com/uber/aresdb / ingestDataForTable

Function ingestDataForTable

examples/examples.go:187–215  ·  view source on GitHub ↗
(connector client.Connector, tableName string, dataPath string)

Source from the content-addressed store, hash-verified

185}
186
187func ingestDataForTable(connector client.Connector, tableName string, dataPath string) {
188 file, err := os.Open(dataPath)
189 panicIfErr(err)
190 defer file.Close()
191
192 csvReader := csv.NewReader(file)
193 columnNames, err := csvReader.Read()
194 panicIfErr(err)
195
196 rows := make([]client.Row, 0)
197 var record []string
198
199 for record, err = csvReader.Read(); err != io.EOF; record, err = csvReader.Read() {
200 panicIfErr(err)
201 row := make(client.Row, 0, len(record))
202 for _, value := range record {
203 if strings.HasPrefix(value, "{") && strings.HasSuffix(value, "}") {
204 row = append(row, parseAndGenerateRandomTime(value))
205 } else {
206 row = append(row, value)
207 }
208 }
209 rows = append(rows, row)
210 }
211 rowsInserted, err := connector.Insert(tableName, columnNames, rows)
212 panicIfErr(err)
213
214 fmt.Printf("%d rows inserted into %s\n", rowsInserted, tableName)
215}
216
217func main() {
218 rootCmd := &cobra.Command{

Callers 1

ingestDataForDataSetFunction · 0.85

Calls 6

panicIfErrFunction · 0.85
OpenMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.65
InsertMethod · 0.65

Tested by

no test coverage detected