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
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 14 additions & 8 deletions internal/encoding/block/from_orc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,21 @@ 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 {
return v, true
}
valueInt, ok := value.(int64)
if ok {
return strconv.FormatInt(valueInt, 10), true
switch value.(type) {
case string:
return value.(string), true
case int64:
return strconv.FormatInt(value.(int64), 10), true
case int32:
return strconv.FormatInt(int64(value.(int32)), 10), true
case []uint8:
return string(value.([]uint8)), true
case float32:
return strconv.FormatFloat(float64(value.(float32)), 'E', -1, 64), true
case float64:
return strconv.FormatFloat(value.(float64), 'E', -1, 64), true
}

return "", false
Expand Down
12 changes: 12 additions & 0 deletions internal/encoding/block/from_parquet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ func TestFromParquet_Nested(t *testing.T) {
b, err := FromParquetBy(o, "foo", nil, apply)
assert.NoError(t, err)
assert.Equal(t, 10000, len(b))

b, err = FromParquetBy(o, "bar", nil, apply)
assert.NoError(t, err)
assert.Equal(t, 10000, len(b))

b, err = FromParquetBy(o, "foofoo", nil, apply)
assert.NoError(t, err)
assert.Equal(t, 1, len(b))

b, err = FromParquetBy(o, "barbar", nil, apply)
assert.NoError(t, err)
assert.Equal(t, 10000, len(b))
}