Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Range Of Data Types Supported As Hash Keys #75

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion internal/encoding/block/from_orc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func convertToJSON(value interface{}) (string, bool) {
return string(json.RawMessage(b)), true
}

// convertToString converst value to string because currently all the keys in Badger are stored in the form of string before hashing to the byte array
// convertToString converts value to string because currently all the keys in Badger are stored in the form of string before hashing to the byte array
atris marked this conversation as resolved.
Show resolved Hide resolved
func convertToString(value interface{}) (string, bool) {
v, ok := value.(string)
if ok {
Expand All @@ -148,5 +148,26 @@ func convertToString(value interface{}) (string, bool) {
return strconv.FormatInt(valueInt, 10), true
}

valueInt32, ok := value.(int32)
atris marked this conversation as resolved.
Show resolved Hide resolved
if ok {
return strconv.FormatInt(int64(valueInt32), 10), true
}

valueByteArray := string(value.([]uint8))

if valueByteArray != "" {
return valueByteArray, true
}

valueFloat32, ok := value.(float32)
if ok {
return strconv.FormatFloat(float64(valueFloat32), 'E', -1, 64), true
}

valueFloat64, ok := value.(float64)
if ok {
return strconv.FormatFloat(valueFloat64, 'E', -1, 64), true
}

return "", false
}