MCPcopy Create free account
hub / github.com/brimdata/super / TestObjectProjectMetadata

Function TestObjectProjectMetadata

csup/object_test.go:16–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestObjectProjectMetadata(t *testing.T) {
17 var b bytes.Buffer
18 w := csup.NewSerializer(sio.NopCloser(&b))
19 sctx := super.NewContext()
20 supValues := []string{
21 "{a:1,b:{c:4,d:0.7}}",
22 "{a:2,b:{c:5,d:0.8}}",
23 "{a:3,b:{c:6,d:0.9}}",
24 }
25 builder := vector.NewDynamicBuilder()
26 for _, s := range supValues {
27 builder.Write(sup.MustParseValue(sctx, s))
28 }
29 require.NoError(t, w.Push(builder.Build(sctx)))
30 require.NoError(t, w.Close())
31 csupBytes := b.Bytes()
32
33 o, err := csup.NewObject(bytes.NewReader(csupBytes))
34 require.NoError(t, err)
35 p := field.NewProjection(field.DottedList("b.d,a"))
36 values := o.ProjectMetadata(super.NewContext(), p)
37 require.Len(t, values, 1)
38 require.Equal(t, "{b:{d:{min:0.7,max:0.9}},a:{min:1,max:3}}", sup.FormatValue(values[0]))
39}

Callers

nothing calls this directly

Calls 15

WriteMethod · 0.95
PushMethod · 0.95
BuildMethod · 0.95
CloseMethod · 0.95
ProjectMetadataMethod · 0.95
NewSerializerFunction · 0.92
NopCloserFunction · 0.92
NewContextFunction · 0.92
NewDynamicBuilderFunction · 0.92
MustParseValueFunction · 0.92
NewObjectFunction · 0.92
NewProjectionFunction · 0.92

Tested by

no test coverage detected