You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2023/02/08 23:06:44 UTC

[GitHub] [arrow] felipecrv commented on a diff in pull request #34079: GH-34077: [Go] Implement RunEndEncoded Scalar

felipecrv commented on code in PR #34079:
URL: https://github.com/apache/arrow/pull/34079#discussion_r1100774478


##########
go/arrow/scalar/scalar.go:
##########
@@ -664,6 +671,28 @@ func GetScalar(arr arrow.Array, idx int) (Scalar, error) {
 		return NewTime64Scalar(arr.Value(idx), arr.DataType()), nil
 	case *array.Timestamp:
 		return NewTimestampScalar(arr.Value(idx), arr.DataType()), nil
+	case *array.RunEndEncoded:
+		physicalIndex := encoded.FindPhysicalIndex(arr.Data(), arr.Offset()+idx)
+		value, err := GetScalar(arr.Values(), physicalIndex)
+		if err != nil {
+			return nil, err
+		}
+
+		var runLength int64
+
+		runEnds := arr.RunEndsArr()
+		switch ends := runEnds.(type) {
+		case *array.Int16:
+			runLength = int64(ends.Value(physicalIndex))
+		case *array.Int32:
+			runLength = int64(ends.Value(physicalIndex))
+		case *array.Int64:
+			runLength = int64(ends.Value(physicalIndex))
+		}

Review Comment:
   @zeroshade Antoine has suggested that I add a RunEndEncoded scalar type instead of adding hacks to make things work without it.
   
   > To me, this scalar makes sense as representing the physical value for a physical index, but not the logical value for a logical index (if that makes...logical sense?)
   
   If you look at the REE array as an array of runs, the scalar that is typed by the REE type is a single run.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org