-
Notifications
You must be signed in to change notification settings - Fork 0
/
put.go
36 lines (30 loc) · 764 Bytes
/
put.go
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
34
35
36
package meddb
import "math/big"
type PutOp struct {
rowId []byte
cols map[string]*Cell
}
func NewPutOp(rowId []byte) *PutOp {
return &PutOp{rowId: rowId, cols: make(map[string]*Cell)}
}
func (op *PutOp) AddCol(colId []byte, data []byte) error {
if _, ok := op.cols[string(colId)]; ok {
return &ColIdAlreadyExists{ColId: colId}
}
op.cols[string(colId)] = NewCell(data)
return nil
}
func (op *PutOp) AddColVer(colId []byte, verId int64, data []byte) error {
if _, ok := op.cols[string(colId)]; ok {
return &ColIdAlreadyExists{ColId: colId}
}
op.cols[string(colId)] = NewCellVer(verId, data)
return nil
}
func (op *PutOp) fillVer(verId int64) {
for _, cell := range op.cols {
if cell.VerId == nil {
cell.VerId = big.NewInt(verId)
}
}
}