mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-10 07:01:01 +00:00
Add test helper for inserting to time quantum fields
This commit is contained in:
parent
fbf546f131
commit
4dc3e49a0d
1 changed files with 30 additions and 0 deletions
|
|
@ -164,6 +164,36 @@ func (c *Cluster) ImportKeyKey(t testing.TB, index, field string, valAndRecKeys
|
|||
}
|
||||
}
|
||||
|
||||
// TimeQuantumKey is a string key and a string+key value
|
||||
type TimeQuantumKey struct {
|
||||
RowKey string
|
||||
ColKey string
|
||||
Ts int64
|
||||
}
|
||||
|
||||
// ImportTimeQuantumKey imports data into an index where the index is keyd
|
||||
// and the field is a time-quantum
|
||||
func (c *Cluster) ImportTimeQuantumKey(t testing.TB, index, field string, entries []TimeQuantumKey) {
|
||||
t.Helper()
|
||||
importRequest := &pilosa.ImportRequest{
|
||||
Index: index,
|
||||
Field: field,
|
||||
RowKeys: make([]string, len(entries)),
|
||||
ColumnKeys: make([]string, len(entries)),
|
||||
Timestamps: make([]int64, len(entries)),
|
||||
}
|
||||
for i, entry := range entries {
|
||||
importRequest.ColumnKeys[i] = entry.ColKey
|
||||
importRequest.RowKeys[i] = entry.RowKey
|
||||
importRequest.Timestamps[i] = entry.Ts
|
||||
|
||||
}
|
||||
err := c.Nodes[0].API.Import(context.Background(), nil, importRequest)
|
||||
if err != nil {
|
||||
t.Fatalf("importing keykey data: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// IntKey is a string key and a signed integer value.
|
||||
type IntKey struct {
|
||||
Val int64
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue