Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestSerializeForInMemoryInt32(t *testing.T) {

// Verify all values
for i, expected := range []int32{1, 2, 3} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

Pass the correct feature count and default size.

numFeatures=3 and []byte{0,0,0} are placeholders that don’t match actual feature counts or data type sizes. This can hide bitmap-path defects and will fail when defaults are returned for larger numeric types. Please pass the real count and a default sized via dataType.Size().

Also applies to: 124-124, 279-279, 336-336, 492-492, 549-549, 705-705, 762-762, 917-917, 978-978, 1146-1146, 1203-1203, 1359-1359, 1416-1416

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@online-feature-store/internal/data/blocks/cache_storage_datablock_v2_test.go`
at line 67, Tests call ddb.GetNumericScalarFeature(i, 3, []byte{0,0,0}) with
hardcoded numFeatures and default bytes which are wrong; replace the placeholder
3 and []byte{0,0,0} with the actual feature count and a default-sized slice
derived from the feature's dataType.Size(). Locate calls to
GetNumericScalarFeature (and similar numeric scalar lookup helpers) and pass the
real feature count variable used in the test and construct the default value as
make([]byte, dataType.Size()) or equivalent so bitmap-path and larger numeric
types get correct-sized defaults.

require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt32(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestSerializeForInMemoryInt32(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 1000, 5000, 9999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt32(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestSerializeForInMemoryInt32(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureInt32ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestSerializeForInMemoryInt8(t *testing.T) {

// Verify all values
for i, expected := range []int8{1, 2, 3} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt8(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -333,7 +333,7 @@ func TestSerializeForInMemoryInt8(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt8(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -404,7 +404,7 @@ func TestSerializeForInMemoryInt8(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureInt8ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -489,7 +489,7 @@ func TestSerializeForInMemoryInt16(t *testing.T) {

// Verify all values
for i, expected := range []int16{1000, 2000, 3000} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt16(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -546,7 +546,7 @@ func TestSerializeForInMemoryInt16(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt16(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -617,7 +617,7 @@ func TestSerializeForInMemoryInt16(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureInt16ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestSerializeForInMemoryInt64(t *testing.T) {

// Verify all values
for i, expected := range []int64{1000000000000, 2000000000000, 3000000000000} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt64(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -759,7 +759,7 @@ func TestSerializeForInMemoryInt64(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeInt64(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -830,7 +830,7 @@ func TestSerializeForInMemoryInt64(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 499}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureInt64ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -914,7 +914,7 @@ func TestSerializeForInMemoryFP8(t *testing.T) {

// Verify all values
for i, expected := range []float32{1.0, 2.0, 4.0} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFP8E4M3(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -975,7 +975,7 @@ func TestSerializeForInMemoryFP8(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFP8E4M3(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1054,7 +1054,7 @@ func TestSerializeForInMemoryFP8(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureFp8E4M3ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1143,7 +1143,7 @@ func TestSerializeForInMemoryFP32(t *testing.T) {

// Verify all values
for i, expected := range []float32{1.234, 2.345, 3.456} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFloat32(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1200,7 +1200,7 @@ func TestSerializeForInMemoryFP32(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFloat32(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1271,7 +1271,7 @@ func TestSerializeForInMemoryFP32(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureFp32ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1356,7 +1356,7 @@ func TestSerializeForInMemoryFP64(t *testing.T) {

// Verify all values
for i, expected := range []float64{1.23456789, 2.34567890, 3.45678901} {
feature, err := ddb.GetNumericScalarFeature(i)
feature, err := ddb.GetNumericScalarFeature(i, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFloat64(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1413,7 +1413,7 @@ func TestSerializeForInMemoryFP64(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetNumericScalarFeature(pos)
feature, err := ddb.GetNumericScalarFeature(pos, 3, []byte{0, 0, 0})
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeFloat64(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1484,7 +1484,7 @@ func TestSerializeForInMemoryFP64(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 399}
for _, pos := range testPositions {
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths)
feature, err := ddb.GetNumericVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureFp64ToConcatenatedString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1569,7 +1569,7 @@ func TestSerializeForInMemoryString(t *testing.T) {

// Verify all values
for i, expected := range []string{"hello", "world", "test"} {
feature, err := ddb.GetStringScalarFeature(i, 3)
feature, err := ddb.GetStringScalarFeature(i, 3, nil)
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1628,7 +1628,7 @@ func TestSerializeForInMemoryString(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 100, 500, 999}
for _, pos := range testPositions {
feature, err := ddb.GetStringScalarFeature(pos, 1000)
feature, err := ddb.GetStringScalarFeature(pos, 1000, nil)
require.NoError(t, err)
value, err := HelperScalarFeatureToTypeString(feature)
require.NoError(t, err)
Expand Down Expand Up @@ -1700,7 +1700,7 @@ func TestSerializeForInMemoryString(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 399}
for _, pos := range testPositions {
feature, err := ddb.GetStringVectorFeature(pos, 400, vectorLengths)
feature, err := ddb.GetStringVectorFeature(pos, 400, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureStringToConcatenatedString(feature, int(vectorLengths[pos]))
require.NoError(t, err)
Expand Down Expand Up @@ -1912,7 +1912,7 @@ func TestSerializeForInMemoryBool(t *testing.T) {
// Test random positions
testPositions := []int{0, 42, 123, 456, 789, 999}
for _, pos := range testPositions {
feature, err := ddb.GetBoolVectorFeature(pos, vectorLengths)
feature, err := ddb.GetBoolVectorFeature(pos, vectorLengths, nil)
require.NoError(t, err)
result, err := HelperVectorFeatureBoolToConcatenatedString(feature)
require.NoError(t, err)
Expand Down
Loading
Loading