zeroshade commented on code in PR #34631:
URL: https://github.com/apache/arrow/pull/34631#discussion_r1159930557
##########
go/parquet/pqarrow/encode_arrow_test.go:
##########
@@ -126,7 +126,7 @@ func makeDateTimeTypesTable(mem memory.Allocator, expected
bool, addFieldMeta bo
}
func TestWriteArrowCols(t *testing.T) {
- mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+ mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
Review Comment:
why the switch to `NewGoAllocator` over `DefaultAllocator` ?
##########
go/parquet/pqarrow/column_readers.go:
##########
@@ -543,21 +543,26 @@ func transferBinary(rdr file.RecordReader, dt
arrow.DataType) *arrow.Chunked {
return transferDictionary(brdr,
&arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int32, ValueType: dt})
}
chunks := brdr.GetBuilderChunks()
- if dt == arrow.BinaryTypes.String || dt ==
arrow.BinaryTypes.LargeString {
- // convert chunks from binary to string without copying data,
- // just changing the interpretation of the metadata
- for idx := range chunks {
- chunks[idx] = array.MakeFromData(chunks[idx].Data())
- defer chunks[idx].Data().Release()
- defer chunks[idx].Release()
- }
- } else if dt.ID() == arrow.EXTENSION && len(chunks) > 0 &&
arrow.StorageTypeEqual(chunks[0].DataType(), dt) &&
!arrow.TypeEqual(chunks[0].DataType(), dt) {
- // convert chunks from the underlying storage type to extension
type without copying data
- etype := dt.(arrow.ExtensionType)
-
- for idx := range chunks {
- chunks[idx] = array.NewExtensionArrayWithStorage(etype,
chunks[idx])
- defer chunks[idx].Release()
+ storage := dt
+ if dt.ID() == arrow.EXTENSION {
+ storage = dt.(arrow.ExtensionType).StorageType()
+ }
+ if storage == arrow.BinaryTypes.String || storage ==
arrow.BinaryTypes.LargeString || dt.ID() == arrow.EXTENSION {
Review Comment:
Interesting, I guess I completely forgot about the `fixed size binary`
handling when i made my suggestion. Hmm. you might be able to pull this out
into a switch then to make it a bit cleaner:
```go
switch {
case dt.ID() == arrow.EXTENSION:
etype := dt.(arrow.ExtensionType)
for idx, chk := range chunks {
chunks[idx] = array.NewExtensionArrayWithStorage(etype, chk)
chk.Release() // NewExtensionArrayWithStorage will call
retain on chk, so it still needs to be released
defer chunks[idx].Release()
}
case dt == arrow.BinaryTypes.String || dt == arrow.BinaryTypes.LargeString:
for idx := range chunks {
prev := chunks[idx]
chunks[idx] = array.MakeFromData(chunks[idx].Data())
prev.Release()
defer chunks[idx].Release()
}
}
```
what do you think?
--
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]