You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ze...@apache.org on 2022/08/22 15:01:26 UTC

[arrow] branch master updated: ARROW-17482: [Go] Remove ValueDescr types (#13930)

This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f6670895f ARROW-17482: [Go] Remove ValueDescr types (#13930)
5f6670895f is described below

commit 5f6670895f50b6a71d274c1b46615a3bdc9fa2f8
Author: Matt Topol <zo...@gmail.com>
AuthorDate: Mon Aug 22 11:01:17 2022 -0400

    ARROW-17482: [Go] Remove ValueDescr types (#13930)
    
    Authored-by: Matt Topol <zo...@gmail.com>
    Signed-off-by: Matt Topol <zo...@gmail.com>
---
 dev/release/rat_exclude_files.txt     |  1 -
 go/arrow/compute/datum.go             | 74 -----------------------------------
 go/arrow/compute/expression.go        | 25 +++---------
 go/arrow/compute/no_exec.go           |  2 +-
 go/arrow/compute/valueshape_string.go | 25 ------------
 5 files changed, 7 insertions(+), 120 deletions(-)

diff --git a/dev/release/rat_exclude_files.txt b/dev/release/rat_exclude_files.txt
index 316ff7b556..5aaf64039a 100644
--- a/dev/release/rat_exclude_files.txt
+++ b/dev/release/rat_exclude_files.txt
@@ -143,7 +143,6 @@ go/arrow/cdata/test/go.sum
 go/arrow/unionmode_string.go
 go/arrow/compute/go.sum
 go/arrow/compute/datumkind_string.go
-go/arrow/compute/valueshape_string.go
 go/*.tmpldata
 go/*.s
 go/parquet/internal/gen-go/parquet/GoUnusedProtection__.go
diff --git a/go/arrow/compute/datum.go b/go/arrow/compute/datum.go
index 1a0260ff8c..31c02ce4f8 100644
--- a/go/arrow/compute/datum.go
+++ b/go/arrow/compute/datum.go
@@ -18,37 +18,14 @@ package compute
 
 import (
 	"fmt"
-	"strings"
 
 	"github.com/apache/arrow/go/v10/arrow"
 	"github.com/apache/arrow/go/v10/arrow/array"
 	"github.com/apache/arrow/go/v10/arrow/scalar"
 )
 
-//go:generate go run golang.org/x/tools/cmd/stringer -type=ValueShape -linecomment
 //go:generate go run golang.org/x/tools/cmd/stringer -type=DatumKind -linecomment
 
-// ValueShape is a brief description of the shape of a value (array, scalar or otherwise)
-type ValueShape int8
-
-const (
-	// either Array or Scalar
-	ShapeAny    ValueShape = iota // any
-	ShapeArray                    // array
-	ShapeScalar                   // scalar
-)
-
-// ValueDescr is a descriptor type giving both the shape and the datatype of a value
-// but without the data.
-type ValueDescr struct {
-	Shape ValueShape
-	Type  arrow.DataType
-}
-
-func (v *ValueDescr) String() string {
-	return fmt.Sprintf("%s [%s]", v.Shape, v.Type)
-}
-
 // DatumKind is an enum used for denoting which kind of type a datum is encapsulating
 type DatumKind int
 
@@ -82,8 +59,6 @@ type Datum interface {
 // a slice with 1 element for Array, and the slice of chunks for a chunked array.
 type ArrayLikeDatum interface {
 	Datum
-	Shape() ValueShape
-	Descr() ValueDescr
 	NullN() int64
 	Type() arrow.DataType
 	Chunks() []arrow.Array
@@ -114,12 +89,10 @@ type ScalarDatum struct {
 }
 
 func (ScalarDatum) Kind() DatumKind         { return KindScalar }
-func (ScalarDatum) Shape() ValueShape       { return ShapeScalar }
 func (ScalarDatum) Len() int64              { return 1 }
 func (ScalarDatum) Chunks() []arrow.Array   { return nil }
 func (d *ScalarDatum) Type() arrow.DataType { return d.Value.DataType() }
 func (d *ScalarDatum) String() string       { return d.Value.String() }
-func (d *ScalarDatum) Descr() ValueDescr    { return ValueDescr{ShapeScalar, d.Value.DataType()} }
 func (d *ScalarDatum) ToScalar() (scalar.Scalar, error) {
 	return d.Value, nil
 }
@@ -155,11 +128,9 @@ type ArrayDatum struct {
 }
 
 func (ArrayDatum) Kind() DatumKind           { return KindArray }
-func (ArrayDatum) Shape() ValueShape         { return ShapeArray }
 func (d *ArrayDatum) Type() arrow.DataType   { return d.Value.DataType() }
 func (d *ArrayDatum) Len() int64             { return int64(d.Value.Len()) }
 func (d *ArrayDatum) NullN() int64           { return int64(d.Value.NullN()) }
-func (d *ArrayDatum) Descr() ValueDescr      { return ValueDescr{ShapeArray, d.Value.DataType()} }
 func (d *ArrayDatum) String() string         { return fmt.Sprintf("Array:{%s}", d.Value.DataType()) }
 func (d *ArrayDatum) MakeArray() arrow.Array { return array.MakeFromData(d.Value) }
 func (d *ArrayDatum) Chunks() []arrow.Array  { return []arrow.Array{d.MakeArray()} }
@@ -191,11 +162,9 @@ type ChunkedDatum struct {
 }
 
 func (ChunkedDatum) Kind() DatumKind          { return KindChunked }
-func (ChunkedDatum) Shape() ValueShape        { return ShapeArray }
 func (d *ChunkedDatum) Type() arrow.DataType  { return d.Value.DataType() }
 func (d *ChunkedDatum) Len() int64            { return int64(d.Value.Len()) }
 func (d *ChunkedDatum) NullN() int64          { return int64(d.Value.NullN()) }
-func (d *ChunkedDatum) Descr() ValueDescr     { return ValueDescr{ShapeArray, d.Value.DataType()} }
 func (d *ChunkedDatum) String() string        { return fmt.Sprintf("Array:{%s}", d.Value.DataType()) }
 func (d *ChunkedDatum) Chunks() []arrow.Array { return d.Value.Chunks() }
 
@@ -258,46 +227,6 @@ func (d *TableDatum) Equals(other Datum) bool {
 }
 
 // CollectionDatum is a slice of Datums
-type CollectionDatum []Datum
-
-func (CollectionDatum) Kind() DatumKind { return KindCollection }
-func (c CollectionDatum) Len() int64    { return int64(len(c)) }
-func (c CollectionDatum) String() string {
-	var b strings.Builder
-	b.WriteString("Collection(")
-	for i, d := range c {
-		if i > 0 {
-			b.WriteString(", ")
-		}
-		b.WriteString(d.String())
-	}
-	b.WriteByte(')')
-	return b.String()
-}
-
-func (c CollectionDatum) Release() {
-	for _, v := range c {
-		v.Release()
-	}
-}
-
-func (c CollectionDatum) Equals(other Datum) bool {
-	rhs, ok := other.(CollectionDatum)
-	if !ok {
-		return false
-	}
-
-	if len(c) != len(rhs) {
-		return false
-	}
-
-	for i := range c {
-		if !c[i].Equals(rhs[i]) {
-			return false
-		}
-	}
-	return true
-}
 
 // NewDatum will construct the appropriate Datum type based on what is passed in
 // as the argument.
@@ -327,8 +256,6 @@ func NewDatum(value interface{}) Datum {
 	case arrow.Table:
 		v.Retain()
 		return &TableDatum{v}
-	case []Datum:
-		return CollectionDatum(v)
 	case scalar.Scalar:
 		return &ScalarDatum{v}
 	default:
@@ -342,5 +269,4 @@ var (
 	_ ArrayLikeDatum = (*ChunkedDatum)(nil)
 	_ TableLikeDatum = (*RecordDatum)(nil)
 	_ TableLikeDatum = (*TableDatum)(nil)
-	_ Datum          = (CollectionDatum)(nil)
 )
diff --git a/go/arrow/compute/expression.go b/go/arrow/compute/expression.go
index 8e895fc0c2..2dd4ab626a 100644
--- a/go/arrow/compute/expression.go
+++ b/go/arrow/compute/expression.go
@@ -58,9 +58,6 @@ type Expression interface {
 	// FieldRef returns a pointer to the underlying field reference, or nil if
 	// this expression is not a field reference.
 	FieldRef() *FieldRef
-	// Descr returns the shape of this expression will evaluate to including the type
-	// and whether it will be an Array, Scalar, or either.
-	Descr() ValueDescr
 	// Type returns the datatype this expression will evaluate to.
 	Type() arrow.DataType
 
@@ -146,14 +143,6 @@ func (l *Literal) IsSatisfiable() bool {
 	return true
 }
 
-func (l *Literal) Descr() ValueDescr {
-	if ad, ok := l.Literal.(ArrayLikeDatum); ok {
-		return ad.Descr()
-	}
-
-	return ValueDescr{ShapeAny, nil}
-}
-
 func (l *Literal) Hash() uint64 {
 	if l.IsScalarExpr() {
 		return scalar.Hash(hashSeed, l.Literal.(*ScalarDatum).Value)
@@ -183,7 +172,7 @@ type Parameter struct {
 	ref *FieldRef
 
 	// post bind props
-	descr ValueDescr
+	dt    arrow.DataType
 	index int
 
 	bound boundRef
@@ -191,12 +180,11 @@ type Parameter struct {
 
 func (Parameter) IsNullLiteral() bool     { return false }
 func (p *Parameter) boundExpr() boundRef  { return p.bound }
-func (p *Parameter) Type() arrow.DataType { return p.descr.Type }
+func (p *Parameter) Type() arrow.DataType { return p.dt }
 func (p *Parameter) IsBound() bool        { return p.Type() != nil }
 func (p *Parameter) IsScalarExpr() bool   { return p.ref != nil }
 func (p *Parameter) IsSatisfiable() bool  { return p.Type() == nil || p.Type().ID() != arrow.NULL }
 func (p *Parameter) FieldRef() *FieldRef  { return p.ref }
-func (p *Parameter) Descr() ValueDescr    { return p.descr }
 func (p *Parameter) Hash() uint64         { return p.ref.Hash(hashSeed) }
 
 func (p *Parameter) String() string {
@@ -219,7 +207,7 @@ func (p *Parameter) Equals(other Expression) bool {
 }
 
 func (p *Parameter) Bind(ctx context.Context, mem memory.Allocator, schema *arrow.Schema) (Expression, error) {
-	bound, descr, index, _, err := bindExprSchema(ctx, mem, p, schema)
+	bound, dt, index, _, err := bindExprSchema(ctx, mem, p, schema)
 	if err != nil {
 		return nil, err
 	}
@@ -227,7 +215,7 @@ func (p *Parameter) Bind(ctx context.Context, mem memory.Allocator, schema *arro
 	return &Parameter{
 		ref:   p.ref,
 		index: index,
-		descr: descr,
+		dt:    dt,
 		bound: bound,
 	}, nil
 }
@@ -325,7 +313,7 @@ func optionsToString(fn FunctionOptions) string {
 type Call struct {
 	funcName string
 	args     []Expression
-	descr    ValueDescr
+	dt       arrow.DataType
 	options  FunctionOptions
 
 	cachedHash uint64
@@ -335,8 +323,7 @@ type Call struct {
 func (c *Call) boundExpr() boundRef  { return c.bound }
 func (c *Call) IsNullLiteral() bool  { return false }
 func (c *Call) FieldRef() *FieldRef  { return nil }
-func (c *Call) Descr() ValueDescr    { return c.descr }
-func (c *Call) Type() arrow.DataType { return c.descr.Type }
+func (c *Call) Type() arrow.DataType { return c.dt }
 func (c *Call) IsSatisfiable() bool  { return c.Type() == nil || c.Type().ID() != arrow.NULL }
 
 func (c *Call) String() string {
diff --git a/go/arrow/compute/no_exec.go b/go/arrow/compute/no_exec.go
index 0237fe7a69..f2f8b69fd6 100644
--- a/go/arrow/compute/no_exec.go
+++ b/go/arrow/compute/no_exec.go
@@ -40,6 +40,6 @@ func (boundRef) release() {}
 
 // when compiled without the c++ library (the build tags control whether it looks for it)
 // then we do not have pure go implementation of the expression binding currently.
-func bindExprSchema(context.Context, memory.Allocator, Expression, *arrow.Schema) (boundRef, ValueDescr, int, Expression, error) {
+func bindExprSchema(context.Context, memory.Allocator, Expression, *arrow.Schema) (boundRef, arrow.DataType, int, Expression, error) {
 	panic("arrow/compute: bind expression not implemented")
 }
diff --git a/go/arrow/compute/valueshape_string.go b/go/arrow/compute/valueshape_string.go
deleted file mode 100644
index 1381d2ed39..0000000000
--- a/go/arrow/compute/valueshape_string.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Code generated by "stringer -type=ValueShape -linecomment"; DO NOT EDIT.
-
-package compute
-
-import "strconv"
-
-func _() {
-	// An "invalid array index" compiler error signifies that the constant values have changed.
-	// Re-run the stringer command to generate them again.
-	var x [1]struct{}
-	_ = x[ShapeAny-0]
-	_ = x[ShapeArray-1]
-	_ = x[ShapeScalar-2]
-}
-
-const _ValueShape_name = "anyarrayscalar"
-
-var _ValueShape_index = [...]uint8{0, 3, 8, 14}
-
-func (i ValueShape) String() string {
-	if i < 0 || i >= ValueShape(len(_ValueShape_index)-1) {
-		return "ValueShape(" + strconv.FormatInt(int64(i), 10) + ")"
-	}
-	return _ValueShape_name[_ValueShape_index[i]:_ValueShape_index[i+1]]
-}