Skip to content

Commit

Permalink
implementing bree index: added new serialization method to Value type.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryogrid committed Aug 21, 2024
1 parent 63b5b2b commit d364ef3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/types/column_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,27 @@ func (v Value) Serialize() []byte {
return []byte{}
}

// no length info and isNull info
func (v Value) SerializeOnlyVal() []byte {
switch v.valueType {
case Integer:
buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, v.ToInteger())
return buf.Bytes()
case Float:
buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, v.ToFloat())
return buf.Bytes()
case Varchar:
return []byte(v.ToVarchar())
case Boolean:
buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, v.ToBoolean())
return buf.Bytes()
}
return []byte{}
}

// Size returns the size in bytes that the type will occupy inside the tuple
func (v Value) Size() uint32 {
// all type occupies the whether NULL or not + 1 byte for the info storage
Expand Down

0 comments on commit d364ef3

Please sign in to comment.