forked from marcboeker/go-duckdb
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathrow.go
More file actions
33 lines (27 loc) · 898 Bytes
/
row.go
File metadata and controls
33 lines (27 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package duckdb
import (
"github.com/duckdb/duckdb-go/v2/mapping"
)
// Row represents one row in duckdb.
// It references the internal vectors.
type Row struct {
chunk *DataChunk
r mapping.IdxT
}
// IsProjected returns whether the column is projected.
func (r Row) IsProjected(colIdx int) bool {
if len(r.chunk.projection) == 0 || colIdx < 0 || colIdx >= len(r.chunk.projection) {
return false
}
return r.chunk.projection[colIdx] != -1
}
// SetRowValue sets the value at colIdx to val.
// Returns an error on failure, and nil for non-projected columns.
func SetRowValue[T any](row Row, colIdx int, val T) error {
return SetChunkValue(*row.chunk, colIdx, int(row.r), val)
}
// SetRowValue sets the value at colIdx to val.
// Returns an error on failure, and nil for non-projected columns.
func (r Row) SetRowValue(colIdx int, val any) error {
return SetRowValue(r, colIdx, val)
}