Skip to content

Commit 5f66708

Browse files
authored
ARROW-17482: [Go] Remove ValueDescr types (#13930)
Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
1 parent 258173d commit 5f66708

5 files changed

Lines changed: 7 additions & 120 deletions

File tree

‎dev/release/rat_exclude_files.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ go/arrow/cdata/test/go.sum
143143
go/arrow/unionmode_string.go
144144
go/arrow/compute/go.sum
145145
go/arrow/compute/datumkind_string.go
146-
go/arrow/compute/valueshape_string.go
147146
go/*.tmpldata
148147
go/*.s
149148
go/parquet/internal/gen-go/parquet/GoUnusedProtection__.go

‎go/arrow/compute/datum.go‎

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,14 @@ package compute
1818

1919
import (
2020
"fmt"
21-
"strings"
2221

2322
"github.com/apache/arrow/go/v10/arrow"
2423
"github.com/apache/arrow/go/v10/arrow/array"
2524
"github.com/apache/arrow/go/v10/arrow/scalar"
2625
)
2726

28-
//go:generate go run golang.org/x/tools/cmd/stringer -type=ValueShape -linecomment
2927
//go:generate go run golang.org/x/tools/cmd/stringer -type=DatumKind -linecomment
3028

31-
// ValueShape is a brief description of the shape of a value (array, scalar or otherwise)
32-
type ValueShape int8
33-
34-
const (
35-
// either Array or Scalar
36-
ShapeAny ValueShape = iota // any
37-
ShapeArray // array
38-
ShapeScalar // scalar
39-
)
40-
41-
// ValueDescr is a descriptor type giving both the shape and the datatype of a value
42-
// but without the data.
43-
type ValueDescr struct {
44-
Shape ValueShape
45-
Type arrow.DataType
46-
}
47-
48-
func (v *ValueDescr) String() string {
49-
return fmt.Sprintf("%s [%s]", v.Shape, v.Type)
50-
}
51-
5229
// DatumKind is an enum used for denoting which kind of type a datum is encapsulating
5330
type DatumKind int
5431

@@ -82,8 +59,6 @@ type Datum interface {
8259
// a slice with 1 element for Array, and the slice of chunks for a chunked array.
8360
type ArrayLikeDatum interface {
8461
Datum
85-
Shape() ValueShape
86-
Descr() ValueDescr
8762
NullN() int64
8863
Type() arrow.DataType
8964
Chunks() []arrow.Array
@@ -114,12 +89,10 @@ type ScalarDatum struct {
11489
}
11590

11691
func (ScalarDatum) Kind() DatumKind { return KindScalar }
117-
func (ScalarDatum) Shape() ValueShape { return ShapeScalar }
11892
func (ScalarDatum) Len() int64 { return 1 }
11993
func (ScalarDatum) Chunks() []arrow.Array { return nil }
12094
func (d *ScalarDatum) Type() arrow.DataType { return d.Value.DataType() }
12195
func (d *ScalarDatum) String() string { return d.Value.String() }
122-
func (d *ScalarDatum) Descr() ValueDescr { return ValueDescr{ShapeScalar, d.Value.DataType()} }
12396
func (d *ScalarDatum) ToScalar() (scalar.Scalar, error) {
12497
return d.Value, nil
12598
}
@@ -155,11 +128,9 @@ type ArrayDatum struct {
155128
}
156129

157130
func (ArrayDatum) Kind() DatumKind { return KindArray }
158-
func (ArrayDatum) Shape() ValueShape { return ShapeArray }
159131
func (d *ArrayDatum) Type() arrow.DataType { return d.Value.DataType() }
160132
func (d *ArrayDatum) Len() int64 { return int64(d.Value.Len()) }
161133
func (d *ArrayDatum) NullN() int64 { return int64(d.Value.NullN()) }
162-
func (d *ArrayDatum) Descr() ValueDescr { return ValueDescr{ShapeArray, d.Value.DataType()} }
163134
func (d *ArrayDatum) String() string { return fmt.Sprintf("Array:{%s}", d.Value.DataType()) }
164135
func (d *ArrayDatum) MakeArray() arrow.Array { return array.MakeFromData(d.Value) }
165136
func (d *ArrayDatum) Chunks() []arrow.Array { return []arrow.Array{d.MakeArray()} }
@@ -191,11 +162,9 @@ type ChunkedDatum struct {
191162
}
192163

193164
func (ChunkedDatum) Kind() DatumKind { return KindChunked }
194-
func (ChunkedDatum) Shape() ValueShape { return ShapeArray }
195165
func (d *ChunkedDatum) Type() arrow.DataType { return d.Value.DataType() }
196166
func (d *ChunkedDatum) Len() int64 { return int64(d.Value.Len()) }
197167
func (d *ChunkedDatum) NullN() int64 { return int64(d.Value.NullN()) }
198-
func (d *ChunkedDatum) Descr() ValueDescr { return ValueDescr{ShapeArray, d.Value.DataType()} }
199168
func (d *ChunkedDatum) String() string { return fmt.Sprintf("Array:{%s}", d.Value.DataType()) }
200169
func (d *ChunkedDatum) Chunks() []arrow.Array { return d.Value.Chunks() }
201170

@@ -258,46 +227,6 @@ func (d *TableDatum) Equals(other Datum) bool {
258227
}
259228

260229
// CollectionDatum is a slice of Datums
261-
type CollectionDatum []Datum
262-
263-
func (CollectionDatum) Kind() DatumKind { return KindCollection }
264-
func (c CollectionDatum) Len() int64 { return int64(len(c)) }
265-
func (c CollectionDatum) String() string {
266-
var b strings.Builder
267-
b.WriteString("Collection(")
268-
for i, d := range c {
269-
if i > 0 {
270-
b.WriteString(", ")
271-
}
272-
b.WriteString(d.String())
273-
}
274-
b.WriteByte(')')
275-
return b.String()
276-
}
277-
278-
func (c CollectionDatum) Release() {
279-
for _, v := range c {
280-
v.Release()
281-
}
282-
}
283-
284-
func (c CollectionDatum) Equals(other Datum) bool {
285-
rhs, ok := other.(CollectionDatum)
286-
if !ok {
287-
return false
288-
}
289-
290-
if len(c) != len(rhs) {
291-
return false
292-
}
293-
294-
for i := range c {
295-
if !c[i].Equals(rhs[i]) {
296-
return false
297-
}
298-
}
299-
return true
300-
}
301230

302231
// NewDatum will construct the appropriate Datum type based on what is passed in
303232
// as the argument.
@@ -327,8 +256,6 @@ func NewDatum(value interface{}) Datum {
327256
case arrow.Table:
328257
v.Retain()
329258
return &TableDatum{v}
330-
case []Datum:
331-
return CollectionDatum(v)
332259
case scalar.Scalar:
333260
return &ScalarDatum{v}
334261
default:
@@ -342,5 +269,4 @@ var (
342269
_ ArrayLikeDatum = (*ChunkedDatum)(nil)
343270
_ TableLikeDatum = (*RecordDatum)(nil)
344271
_ TableLikeDatum = (*TableDatum)(nil)
345-
_ Datum = (CollectionDatum)(nil)
346272
)

‎go/arrow/compute/expression.go‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ type Expression interface {
5858
// FieldRef returns a pointer to the underlying field reference, or nil if
5959
// this expression is not a field reference.
6060
FieldRef() *FieldRef
61-
// Descr returns the shape of this expression will evaluate to including the type
62-
// and whether it will be an Array, Scalar, or either.
63-
Descr() ValueDescr
6461
// Type returns the datatype this expression will evaluate to.
6562
Type() arrow.DataType
6663

@@ -146,14 +143,6 @@ func (l *Literal) IsSatisfiable() bool {
146143
return true
147144
}
148145

149-
func (l *Literal) Descr() ValueDescr {
150-
if ad, ok := l.Literal.(ArrayLikeDatum); ok {
151-
return ad.Descr()
152-
}
153-
154-
return ValueDescr{ShapeAny, nil}
155-
}
156-
157146
func (l *Literal) Hash() uint64 {
158147
if l.IsScalarExpr() {
159148
return scalar.Hash(hashSeed, l.Literal.(*ScalarDatum).Value)
@@ -183,20 +172,19 @@ type Parameter struct {
183172
ref *FieldRef
184173

185174
// post bind props
186-
descr ValueDescr
175+
dt arrow.DataType
187176
index int
188177

189178
bound boundRef
190179
}
191180

192181
func (Parameter) IsNullLiteral() bool { return false }
193182
func (p *Parameter) boundExpr() boundRef { return p.bound }
194-
func (p *Parameter) Type() arrow.DataType { return p.descr.Type }
183+
func (p *Parameter) Type() arrow.DataType { return p.dt }
195184
func (p *Parameter) IsBound() bool { return p.Type() != nil }
196185
func (p *Parameter) IsScalarExpr() bool { return p.ref != nil }
197186
func (p *Parameter) IsSatisfiable() bool { return p.Type() == nil || p.Type().ID() != arrow.NULL }
198187
func (p *Parameter) FieldRef() *FieldRef { return p.ref }
199-
func (p *Parameter) Descr() ValueDescr { return p.descr }
200188
func (p *Parameter) Hash() uint64 { return p.ref.Hash(hashSeed) }
201189

202190
func (p *Parameter) String() string {
@@ -219,15 +207,15 @@ func (p *Parameter) Equals(other Expression) bool {
219207
}
220208

221209
func (p *Parameter) Bind(ctx context.Context, mem memory.Allocator, schema *arrow.Schema) (Expression, error) {
222-
bound, descr, index, _, err := bindExprSchema(ctx, mem, p, schema)
210+
bound, dt, index, _, err := bindExprSchema(ctx, mem, p, schema)
223211
if err != nil {
224212
return nil, err
225213
}
226214

227215
return &Parameter{
228216
ref: p.ref,
229217
index: index,
230-
descr: descr,
218+
dt: dt,
231219
bound: bound,
232220
}, nil
233221
}
@@ -325,7 +313,7 @@ func optionsToString(fn FunctionOptions) string {
325313
type Call struct {
326314
funcName string
327315
args []Expression
328-
descr ValueDescr
316+
dt arrow.DataType
329317
options FunctionOptions
330318

331319
cachedHash uint64
@@ -335,8 +323,7 @@ type Call struct {
335323
func (c *Call) boundExpr() boundRef { return c.bound }
336324
func (c *Call) IsNullLiteral() bool { return false }
337325
func (c *Call) FieldRef() *FieldRef { return nil }
338-
func (c *Call) Descr() ValueDescr { return c.descr }
339-
func (c *Call) Type() arrow.DataType { return c.descr.Type }
326+
func (c *Call) Type() arrow.DataType { return c.dt }
340327
func (c *Call) IsSatisfiable() bool { return c.Type() == nil || c.Type().ID() != arrow.NULL }
341328

342329
func (c *Call) String() string {

‎go/arrow/compute/no_exec.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ func (boundRef) release() {}
4040

4141
// when compiled without the c++ library (the build tags control whether it looks for it)
4242
// then we do not have pure go implementation of the expression binding currently.
43-
func bindExprSchema(context.Context, memory.Allocator, Expression, *arrow.Schema) (boundRef, ValueDescr, int, Expression, error) {
43+
func bindExprSchema(context.Context, memory.Allocator, Expression, *arrow.Schema) (boundRef, arrow.DataType, int, Expression, error) {
4444
panic("arrow/compute: bind expression not implemented")
4545
}

‎go/arrow/compute/valueshape_string.go‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)