candiduslynx commented on code in PR #35971:
URL: https://github.com/apache/arrow/pull/35971#discussion_r1221886607
##########
go/arrow/array/extension.go:
##########
@@ -74,28 +74,12 @@ func NewExtensionArrayWithStorage(dt arrow.ExtensionType,
storage arrow.Array) a
panic(fmt.Errorf("arrow/array: storage type %s for extension
type %s, does not match expected type %s", storage.DataType(),
dt.ExtensionName(), dt.StorageType()))
}
- base := ExtensionArrayBase{}
- base.refCount = 1
- base.storage = storage
- storage.Retain()
-
storageData := storage.Data().(*Data)
// create a new data instance with the ExtensionType as the datatype
but referencing the
// same underlying buffers to share them with the storage array.
- baseData := NewData(dt, storageData.length, storageData.buffers,
storageData.childData, storageData.nulls, storageData.offset)
- defer baseData.Release()
- base.array.setData(baseData)
-
- // use the ExtensionType's ArrayType to construct the correctly typed
object
- // to use as the ExtensionArray interface. reflect.New returns a
pointer to
- // the newly created object.
- arr := reflect.New(base.ExtensionType().ArrayType())
- // set the embedded ExtensionArrayBase to the value we created above.
We know
- // that this field will exist because the interface requires embedding
ExtensionArrayBase
- // so we don't have to separately check, this will panic if called on
an ArrayType
- // that doesn't embed ExtensionArrayBase which is what we want.
- arr.Elem().FieldByName("ExtensionArrayBase").Set(reflect.ValueOf(base))
- return arr.Interface().(ExtensionArray)
+ data := NewData(dt, storageData.length, storageData.buffers,
storageData.childData, storageData.nulls, storageData.offset)
Review Comment:
basically, it was a copied code
##########
go/arrow/memory/buffer.go:
##########
@@ -35,7 +35,7 @@ type Buffer struct {
// NewBufferBytes creates a fixed-size buffer from the specified data.
func NewBufferBytes(data []byte) *Buffer {
- return &Buffer{refCount: 0, buf: data, length: len(data)}
+ return &Buffer{refCount: 1, buf: data, length: len(data)}
Review Comment:
for housekeeping
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]