Skip to content

Commit

Permalink
update struct codec
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed May 26, 2024
1 parent 757b0b2 commit c15afa8
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 232 deletions.
2 changes: 1 addition & 1 deletion bson/bson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestMapCodec(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
mapRegistry := NewRegistryBuilder()
mapRegistry.RegisterKindEncoder(reflect.Map, func() ValueEncoder { return tc.codec })
mapRegistry.RegisterKindEncoder(reflect.Map, func(*Registry) ValueEncoder { return tc.codec })
buf := new(bytes.Buffer)
vw := NewValueWriter(buf)
enc := NewEncoderWithRegistry(mapRegistry.Build(), vw)
Expand Down
64 changes: 32 additions & 32 deletions bson/default_value_decoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ func registerDefaultDecoders(rb *RegistryBuilder) {
panic(errors.New("argument to RegisterDefaultDecoders must not be nil"))
}

numDecoder := func() ValueDecoder { return &numCodec{} }
numDecoder := func(*Registry) ValueDecoder { return &numCodec{} }
rb.
RegisterTypeDecoder(tD, func() ValueDecoder { return ValueDecoderFunc(dDecodeValue) }).
RegisterTypeDecoder(tBinary, func() ValueDecoder { return &decodeAdapter{binaryDecodeValue, binaryDecodeType} }).
RegisterTypeDecoder(tUndefined, func() ValueDecoder { return &decodeAdapter{undefinedDecodeValue, undefinedDecodeType} }).
RegisterTypeDecoder(tDateTime, func() ValueDecoder { return &decodeAdapter{dateTimeDecodeValue, dateTimeDecodeType} }).
RegisterTypeDecoder(tNull, func() ValueDecoder { return &decodeAdapter{nullDecodeValue, nullDecodeType} }).
RegisterTypeDecoder(tRegex, func() ValueDecoder { return &decodeAdapter{regexDecodeValue, regexDecodeType} }).
RegisterTypeDecoder(tDBPointer, func() ValueDecoder { return &decodeAdapter{dbPointerDecodeValue, dbPointerDecodeType} }).
RegisterTypeDecoder(tTimestamp, func() ValueDecoder { return &decodeAdapter{timestampDecodeValue, timestampDecodeType} }).
RegisterTypeDecoder(tMinKey, func() ValueDecoder { return &decodeAdapter{minKeyDecodeValue, minKeyDecodeType} }).
RegisterTypeDecoder(tMaxKey, func() ValueDecoder { return &decodeAdapter{maxKeyDecodeValue, maxKeyDecodeType} }).
RegisterTypeDecoder(tJavaScript, func() ValueDecoder { return &decodeAdapter{javaScriptDecodeValue, javaScriptDecodeType} }).
RegisterTypeDecoder(tSymbol, func() ValueDecoder { return &decodeAdapter{symbolDecodeValue, symbolDecodeType} }).
RegisterTypeDecoder(tByteSlice, func() ValueDecoder { return &byteSliceCodec{} }).
RegisterTypeDecoder(tTime, func() ValueDecoder { return &timeCodec{} }).
RegisterTypeDecoder(tEmpty, func() ValueDecoder { return &emptyInterfaceCodec{} }).
RegisterTypeDecoder(tCoreArray, func() ValueDecoder { return &arrayCodec{} }).
RegisterTypeDecoder(tOID, func() ValueDecoder { return &decodeAdapter{objectIDDecodeValue, objectIDDecodeType} }).
RegisterTypeDecoder(tDecimal, func() ValueDecoder { return &decodeAdapter{decimal128DecodeValue, decimal128DecodeType} }).
RegisterTypeDecoder(tJSONNumber, func() ValueDecoder { return &decodeAdapter{jsonNumberDecodeValue, jsonNumberDecodeType} }).
RegisterTypeDecoder(tURL, func() ValueDecoder { return &decodeAdapter{urlDecodeValue, urlDecodeType} }).
RegisterTypeDecoder(tCoreDocument, func() ValueDecoder { return ValueDecoderFunc(coreDocumentDecodeValue) }).
RegisterTypeDecoder(tCodeWithScope, func() ValueDecoder { return &decodeAdapter{codeWithScopeDecodeValue, codeWithScopeDecodeType} }).
RegisterKindDecoder(reflect.Bool, func() ValueDecoder { return &decodeAdapter{booleanDecodeValue, booleanDecodeType} }).
RegisterTypeDecoder(tD, func(*Registry) ValueDecoder { return ValueDecoderFunc(dDecodeValue) }).
RegisterTypeDecoder(tBinary, func(*Registry) ValueDecoder { return &decodeAdapter{binaryDecodeValue, binaryDecodeType} }).
RegisterTypeDecoder(tUndefined, func(*Registry) ValueDecoder { return &decodeAdapter{undefinedDecodeValue, undefinedDecodeType} }).
RegisterTypeDecoder(tDateTime, func(*Registry) ValueDecoder { return &decodeAdapter{dateTimeDecodeValue, dateTimeDecodeType} }).
RegisterTypeDecoder(tNull, func(*Registry) ValueDecoder { return &decodeAdapter{nullDecodeValue, nullDecodeType} }).
RegisterTypeDecoder(tRegex, func(*Registry) ValueDecoder { return &decodeAdapter{regexDecodeValue, regexDecodeType} }).
RegisterTypeDecoder(tDBPointer, func(*Registry) ValueDecoder { return &decodeAdapter{dbPointerDecodeValue, dbPointerDecodeType} }).
RegisterTypeDecoder(tTimestamp, func(*Registry) ValueDecoder { return &decodeAdapter{timestampDecodeValue, timestampDecodeType} }).
RegisterTypeDecoder(tMinKey, func(*Registry) ValueDecoder { return &decodeAdapter{minKeyDecodeValue, minKeyDecodeType} }).
RegisterTypeDecoder(tMaxKey, func(*Registry) ValueDecoder { return &decodeAdapter{maxKeyDecodeValue, maxKeyDecodeType} }).
RegisterTypeDecoder(tJavaScript, func(*Registry) ValueDecoder { return &decodeAdapter{javaScriptDecodeValue, javaScriptDecodeType} }).
RegisterTypeDecoder(tSymbol, func(*Registry) ValueDecoder { return &decodeAdapter{symbolDecodeValue, symbolDecodeType} }).
RegisterTypeDecoder(tByteSlice, func(*Registry) ValueDecoder { return &byteSliceCodec{} }).
RegisterTypeDecoder(tTime, func(*Registry) ValueDecoder { return &timeCodec{} }).
RegisterTypeDecoder(tEmpty, func(*Registry) ValueDecoder { return &emptyInterfaceCodec{} }).
RegisterTypeDecoder(tCoreArray, func(*Registry) ValueDecoder { return &arrayCodec{} }).
RegisterTypeDecoder(tOID, func(*Registry) ValueDecoder { return &decodeAdapter{objectIDDecodeValue, objectIDDecodeType} }).
RegisterTypeDecoder(tDecimal, func(*Registry) ValueDecoder { return &decodeAdapter{decimal128DecodeValue, decimal128DecodeType} }).
RegisterTypeDecoder(tJSONNumber, func(*Registry) ValueDecoder { return &decodeAdapter{jsonNumberDecodeValue, jsonNumberDecodeType} }).
RegisterTypeDecoder(tURL, func(*Registry) ValueDecoder { return &decodeAdapter{urlDecodeValue, urlDecodeType} }).
RegisterTypeDecoder(tCoreDocument, func(*Registry) ValueDecoder { return ValueDecoderFunc(coreDocumentDecodeValue) }).
RegisterTypeDecoder(tCodeWithScope, func(*Registry) ValueDecoder { return &decodeAdapter{codeWithScopeDecodeValue, codeWithScopeDecodeType} }).
RegisterKindDecoder(reflect.Bool, func(*Registry) ValueDecoder { return &decodeAdapter{booleanDecodeValue, booleanDecodeType} }).
RegisterKindDecoder(reflect.Int, numDecoder).
RegisterKindDecoder(reflect.Int8, numDecoder).
RegisterKindDecoder(reflect.Int16, numDecoder).
Expand All @@ -77,12 +77,12 @@ func registerDefaultDecoders(rb *RegistryBuilder) {
RegisterKindDecoder(reflect.Uint64, numDecoder).
RegisterKindDecoder(reflect.Float32, numDecoder).
RegisterKindDecoder(reflect.Float64, numDecoder).
RegisterKindDecoder(reflect.Array, func() ValueDecoder { return ValueDecoderFunc(arrayDecodeValue) }).
RegisterKindDecoder(reflect.Map, func() ValueDecoder { return &mapCodec{} }).
RegisterKindDecoder(reflect.Slice, func() ValueDecoder { return &sliceCodec{} }).
RegisterKindDecoder(reflect.String, func() ValueDecoder { return &stringCodec{} }).
RegisterKindDecoder(reflect.Struct, func() ValueDecoder { return newStructCodec(rb.StructTagHandler()) }).
RegisterKindDecoder(reflect.Ptr, func() ValueDecoder { return &pointerCodec{} }).
RegisterKindDecoder(reflect.Array, func(*Registry) ValueDecoder { return ValueDecoderFunc(arrayDecodeValue) }).
RegisterKindDecoder(reflect.Map, func(*Registry) ValueDecoder { return &mapCodec{} }).
RegisterKindDecoder(reflect.Slice, func(*Registry) ValueDecoder { return &sliceCodec{} }).
RegisterKindDecoder(reflect.String, func(*Registry) ValueDecoder { return &stringCodec{} }).
RegisterKindDecoder(reflect.Struct, func(*Registry) ValueDecoder { return newStructCodec(nil) }).
RegisterKindDecoder(reflect.Ptr, func(*Registry) ValueDecoder { return &pointerCodec{} }).
RegisterTypeMapEntry(TypeDouble, tFloat64).
RegisterTypeMapEntry(TypeString, tString).
RegisterTypeMapEntry(TypeArray, tA).
Expand All @@ -104,8 +104,8 @@ func registerDefaultDecoders(rb *RegistryBuilder) {
RegisterTypeMapEntry(TypeMaxKey, tMaxKey).
RegisterTypeMapEntry(Type(0), tD).
RegisterTypeMapEntry(TypeEmbeddedDocument, tD).
RegisterInterfaceDecoder(tValueUnmarshaler, func() ValueDecoder { return ValueDecoderFunc(valueUnmarshalerDecodeValue) }).
RegisterInterfaceDecoder(tUnmarshaler, func() ValueDecoder { return ValueDecoderFunc(unmarshalerDecodeValue) })
RegisterInterfaceDecoder(tValueUnmarshaler, func(*Registry) ValueDecoder { return ValueDecoderFunc(valueUnmarshalerDecodeValue) }).
RegisterInterfaceDecoder(tUnmarshaler, func(*Registry) ValueDecoder { return ValueDecoderFunc(unmarshalerDecodeValue) })
}

// dDecodeValue is the ValueDecoderFunc for D instances.
Expand Down
10 changes: 5 additions & 5 deletions bson/default_value_decoders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

var (
defaultTestStructCodec = newStructCodec(DefaultStructTagHandler())
defaultTestStructCodec = newStructCodec(nil)
)

func TestDefaultValueDecoders(t *testing.T) {
Expand Down Expand Up @@ -3417,7 +3417,7 @@ func TestDefaultValueDecoders(t *testing.T) {
t.Skip()
}
want := errors.New("DecodeValue failure error")
llc := func() ValueDecoder { return &llCodec{t: t, err: want} }
llc := func(*Registry) ValueDecoder { return &llCodec{t: t, err: want} }
reg := newTestRegistryBuilder().
RegisterTypeDecoder(reflect.TypeOf(tc.val), llc).
RegisterTypeMapEntry(tc.bsontype, reflect.TypeOf(tc.val)).
Expand All @@ -3430,7 +3430,7 @@ func TestDefaultValueDecoders(t *testing.T) {

t.Run("Success", func(t *testing.T) {
want := tc.val
llc := func() ValueDecoder { return &llCodec{t: t, decodeval: tc.val} }
llc := func(*Registry) ValueDecoder { return &llCodec{t: t, decodeval: tc.val} }
reg := newTestRegistryBuilder().
RegisterTypeDecoder(reflect.TypeOf(tc.val), llc).
RegisterTypeMapEntry(tc.bsontype, reflect.TypeOf(tc.val)).
Expand Down Expand Up @@ -3575,7 +3575,7 @@ func TestDefaultValueDecoders(t *testing.T) {
return decodeValueError
}
emptyInterfaceErrorRegistry := newTestRegistryBuilder().
RegisterTypeDecoder(tEmpty, func() ValueDecoder { return ValueDecoderFunc(emptyInterfaceErrorDecode) }).
RegisterTypeDecoder(tEmpty, func(*Registry) ValueDecoder { return ValueDecoderFunc(emptyInterfaceErrorDecode) }).
Build()

// Set up a document {foo: 10} and an error that would happen if the value were decoded into interface{}
Expand Down Expand Up @@ -3630,7 +3630,7 @@ func TestDefaultValueDecoders(t *testing.T) {
// Use a registry that has all default decoders with the custom interface{} decoder that always errors.
nestedRegistryBuilder := newTestRegistryBuilder()
registerDefaultDecoders(nestedRegistryBuilder)
nestedRegistryBuilder.RegisterTypeDecoder(tEmpty, func() ValueDecoder { return ValueDecoderFunc(emptyInterfaceErrorDecode) })
nestedRegistryBuilder.RegisterTypeDecoder(tEmpty, func(*Registry) ValueDecoder { return ValueDecoderFunc(emptyInterfaceErrorDecode) })
nestedErr := &DecodeError{
keys: []string{"fourth", "1", "third", "randomKey", "second", "first"},
wrapped: decodeValueError,
Expand Down
69 changes: 37 additions & 32 deletions bson/default_value_encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@ func registerDefaultEncoders(rb *RegistryBuilder) {
panic(errors.New("argument to RegisterDefaultEncoders must not be nil"))
}

numEncoder := func() ValueEncoder { return &numCodec{} }
numEncoder := func(*Registry) ValueEncoder { return &numCodec{} }
rb.
RegisterTypeEncoder(tByteSlice, func() ValueEncoder { return &byteSliceCodec{} }).
RegisterTypeEncoder(tTime, func() ValueEncoder { return &timeCodec{} }).
RegisterTypeEncoder(tEmpty, func() ValueEncoder { return &emptyInterfaceCodec{} }).
RegisterTypeEncoder(tCoreArray, func() ValueEncoder { return &arrayCodec{} }).
RegisterTypeEncoder(tOID, func() ValueEncoder { return ValueEncoderFunc(objectIDEncodeValue) }).
RegisterTypeEncoder(tDecimal, func() ValueEncoder { return ValueEncoderFunc(decimal128EncodeValue) }).
RegisterTypeEncoder(tJSONNumber, func() ValueEncoder { return ValueEncoderFunc(jsonNumberEncodeValue) }).
RegisterTypeEncoder(tURL, func() ValueEncoder { return ValueEncoderFunc(urlEncodeValue) }).
RegisterTypeEncoder(tJavaScript, func() ValueEncoder { return ValueEncoderFunc(javaScriptEncodeValue) }).
RegisterTypeEncoder(tSymbol, func() ValueEncoder { return ValueEncoderFunc(symbolEncodeValue) }).
RegisterTypeEncoder(tBinary, func() ValueEncoder { return ValueEncoderFunc(binaryEncodeValue) }).
RegisterTypeEncoder(tUndefined, func() ValueEncoder { return ValueEncoderFunc(undefinedEncodeValue) }).
RegisterTypeEncoder(tDateTime, func() ValueEncoder { return ValueEncoderFunc(dateTimeEncodeValue) }).
RegisterTypeEncoder(tNull, func() ValueEncoder { return ValueEncoderFunc(nullEncodeValue) }).
RegisterTypeEncoder(tRegex, func() ValueEncoder { return ValueEncoderFunc(regexEncodeValue) }).
RegisterTypeEncoder(tDBPointer, func() ValueEncoder { return ValueEncoderFunc(dbPointerEncodeValue) }).
RegisterTypeEncoder(tTimestamp, func() ValueEncoder { return ValueEncoderFunc(timestampEncodeValue) }).
RegisterTypeEncoder(tMinKey, func() ValueEncoder { return ValueEncoderFunc(minKeyEncodeValue) }).
RegisterTypeEncoder(tMaxKey, func() ValueEncoder { return ValueEncoderFunc(maxKeyEncodeValue) }).
RegisterTypeEncoder(tCoreDocument, func() ValueEncoder { return ValueEncoderFunc(coreDocumentEncodeValue) }).
RegisterTypeEncoder(tCodeWithScope, func() ValueEncoder { return ValueEncoderFunc(codeWithScopeEncodeValue) }).
RegisterKindEncoder(reflect.Bool, func() ValueEncoder { return ValueEncoderFunc(booleanEncodeValue) }).
RegisterTypeEncoder(tByteSlice, func(*Registry) ValueEncoder { return &byteSliceCodec{} }).
RegisterTypeEncoder(tTime, func(*Registry) ValueEncoder { return &timeCodec{} }).
RegisterTypeEncoder(tEmpty, func(*Registry) ValueEncoder { return &emptyInterfaceCodec{} }).
RegisterTypeEncoder(tCoreArray, func(*Registry) ValueEncoder { return &arrayCodec{} }).
RegisterTypeEncoder(tOID, func(*Registry) ValueEncoder { return ValueEncoderFunc(objectIDEncodeValue) }).
RegisterTypeEncoder(tDecimal, func(*Registry) ValueEncoder { return ValueEncoderFunc(decimal128EncodeValue) }).
RegisterTypeEncoder(tJSONNumber, func(*Registry) ValueEncoder { return ValueEncoderFunc(jsonNumberEncodeValue) }).
RegisterTypeEncoder(tURL, func(*Registry) ValueEncoder { return ValueEncoderFunc(urlEncodeValue) }).
RegisterTypeEncoder(tJavaScript, func(*Registry) ValueEncoder { return ValueEncoderFunc(javaScriptEncodeValue) }).
RegisterTypeEncoder(tSymbol, func(*Registry) ValueEncoder { return ValueEncoderFunc(symbolEncodeValue) }).
RegisterTypeEncoder(tBinary, func(*Registry) ValueEncoder { return ValueEncoderFunc(binaryEncodeValue) }).
RegisterTypeEncoder(tUndefined, func(*Registry) ValueEncoder { return ValueEncoderFunc(undefinedEncodeValue) }).
RegisterTypeEncoder(tDateTime, func(*Registry) ValueEncoder { return ValueEncoderFunc(dateTimeEncodeValue) }).
RegisterTypeEncoder(tNull, func(*Registry) ValueEncoder { return ValueEncoderFunc(nullEncodeValue) }).
RegisterTypeEncoder(tRegex, func(*Registry) ValueEncoder { return ValueEncoderFunc(regexEncodeValue) }).
RegisterTypeEncoder(tDBPointer, func(*Registry) ValueEncoder { return ValueEncoderFunc(dbPointerEncodeValue) }).
RegisterTypeEncoder(tTimestamp, func(*Registry) ValueEncoder { return ValueEncoderFunc(timestampEncodeValue) }).
RegisterTypeEncoder(tMinKey, func(*Registry) ValueEncoder { return ValueEncoderFunc(minKeyEncodeValue) }).
RegisterTypeEncoder(tMaxKey, func(*Registry) ValueEncoder { return ValueEncoderFunc(maxKeyEncodeValue) }).
RegisterTypeEncoder(tCoreDocument, func(*Registry) ValueEncoder { return ValueEncoderFunc(coreDocumentEncodeValue) }).
RegisterTypeEncoder(tCodeWithScope, func(*Registry) ValueEncoder { return ValueEncoderFunc(codeWithScopeEncodeValue) }).
RegisterKindEncoder(reflect.Bool, func(*Registry) ValueEncoder { return ValueEncoderFunc(booleanEncodeValue) }).
RegisterKindEncoder(reflect.Int, numEncoder).
RegisterKindEncoder(reflect.Int8, numEncoder).
RegisterKindEncoder(reflect.Int16, numEncoder).
Expand All @@ -91,15 +91,20 @@ func registerDefaultEncoders(rb *RegistryBuilder) {
RegisterKindEncoder(reflect.Uint64, numEncoder).
RegisterKindEncoder(reflect.Float32, numEncoder).
RegisterKindEncoder(reflect.Float64, numEncoder).
RegisterKindEncoder(reflect.Array, func() ValueEncoder { return ValueEncoderFunc(arrayEncodeValue) }).
RegisterKindEncoder(reflect.Map, func() ValueEncoder { return &mapCodec{} }).
RegisterKindEncoder(reflect.Slice, func() ValueEncoder { return &sliceCodec{} }).
RegisterKindEncoder(reflect.String, func() ValueEncoder { return &stringCodec{} }).
RegisterKindEncoder(reflect.Struct, func() ValueEncoder { return newStructCodec(rb.StructTagHandler()) }).
RegisterKindEncoder(reflect.Ptr, func() ValueEncoder { return &pointerCodec{} }).
RegisterInterfaceEncoder(tValueMarshaler, func() ValueEncoder { return ValueEncoderFunc(valueMarshalerEncodeValue) }).
RegisterInterfaceEncoder(tMarshaler, func() ValueEncoder { return ValueEncoderFunc(marshalerEncodeValue) }).
RegisterInterfaceEncoder(tProxy, func() ValueEncoder { return ValueEncoderFunc(proxyEncodeValue) })
RegisterKindEncoder(reflect.Array, func(*Registry) ValueEncoder { return ValueEncoderFunc(arrayEncodeValue) }).
RegisterKindEncoder(reflect.Map, func(*Registry) ValueEncoder { return &mapCodec{} }).
RegisterKindEncoder(reflect.Slice, func(*Registry) ValueEncoder { return &sliceCodec{} }).
RegisterKindEncoder(reflect.String, func(*Registry) ValueEncoder { return &stringCodec{} }).
RegisterKindEncoder(reflect.Struct, func(reg *Registry) ValueEncoder {
// reflect.Struct is 25 that is bigger than reflect.Map, 21, in the kind array,
// so Map will be registered earlier than Struct.
enc, _ := reg.lookupKindEncoder(reflect.Map)
return newStructCodec(enc.(mapElementsEncoder))
}).
RegisterKindEncoder(reflect.Ptr, func(*Registry) ValueEncoder { return &pointerCodec{} }).
RegisterInterfaceEncoder(tValueMarshaler, func(*Registry) ValueEncoder { return ValueEncoderFunc(valueMarshalerEncodeValue) }).
RegisterInterfaceEncoder(tMarshaler, func(*Registry) ValueEncoder { return ValueEncoderFunc(marshalerEncodeValue) }).
RegisterInterfaceEncoder(tProxy, func(*Registry) ValueEncoder { return ValueEncoderFunc(proxyEncodeValue) })
}

// booleanEncodeValue is the ValueEncoderFunc for bool types.
Expand Down
6 changes: 3 additions & 3 deletions bson/map_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ func (mc *mapCodec) EncodeValue(reg EncoderRegistry, vw ValueWriter, val reflect
return err
}

err = mc.mapEncodeValue(reg, dw, val, nil)
err = mc.encodeMapElements(reg, dw, val, nil)
if err != nil {
return err
}
return dw.WriteDocumentEnd()
}

// mapEncodeValue handles encoding of the values of a map. The collisionFn returns
// encodeMapElements handles encoding of the values of a map. The collisionFn returns
// true if the provided key exists, this is mainly used for inline maps in the
// struct codec.
func (mc *mapCodec) mapEncodeValue(reg EncoderRegistry, dw DocumentWriter, val reflect.Value, collisionFn func(string) bool) error {
func (mc *mapCodec) encodeMapElements(reg EncoderRegistry, dw DocumentWriter, val reflect.Value, collisionFn func(string) bool) error {

elemType := val.Type().Elem()
encoder, err := reg.LookupEncoder(elemType)
Expand Down
2 changes: 1 addition & 1 deletion bson/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestCachingEncodersNotSharedAcrossRegistries(t *testing.T) {
return vw.WriteInt32(int32(val.Int()) * -1)
}
customReg := NewRegistryBuilder().
RegisterTypeEncoder(tInt32, func() ValueEncoder { return encodeInt32 }).
RegisterTypeEncoder(tInt32, func(*Registry) ValueEncoder { return encodeInt32 }).
Build()

// Helper function to run the test and make assertions. The provided original value should result in the document
Expand Down
Loading

0 comments on commit c15afa8

Please sign in to comment.