Skip to content

Commit

Permalink
Merge pull request #239 from taosdata/enh/xftan/TD-26329-3.0
Browse files Browse the repository at this point in the history
enh: varbinary and geometry over WebSocket and http
  • Loading branch information
huskar-t authored Feb 6, 2024
2 parents 82b81c6 + 7528538 commit f2642fc
Show file tree
Hide file tree
Showing 3 changed files with 363 additions and 864 deletions.
21 changes: 21 additions & 0 deletions taosRestful/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@ func marshalBody(body io.Reader, bufferSize int) (*common.TDEngineRestfulResp, e
row[column] = iter.ReadUint32()
case common.TSDB_DATA_TYPE_UBIGINT:
row[column] = iter.ReadUint64()
case common.TSDB_DATA_TYPE_VARBINARY, common.TSDB_DATA_TYPE_GEOMETRY:
data := iter.ReadStringAsSlice()
if len(data)%2 != 0 {
iter.ReportError("read varbinary", fmt.Sprintf("invalid length %s", string(data)))
}
value := make([]byte, len(data)/2)
for i := 0; i < len(data); i += 2 {
value[i/2] = hexCharToDigit(data[i])<<4 | hexCharToDigit(data[i+1])
}
row[column] = value
default:
row[column] = nil
iter.Skip()
Expand Down Expand Up @@ -366,3 +376,14 @@ func lower(b byte) byte {
}
return b
}

func hexCharToDigit(char byte) uint8 {
switch {
case char >= '0' && char <= '9':
return char - '0'
case char >= 'a' && char <= 'f':
return char - 'a' + 10
default:
panic("assertion failed: invalid hex char")
}
}
Loading

0 comments on commit f2642fc

Please sign in to comment.