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 2023/04/22 17:13:57 UTC
[arrow] branch main updated: GH-35256: [Go] Add ToMap to Metadata (#35257)
This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 8601aac9ee GH-35256: [Go] Add ToMap to Metadata (#35257)
8601aac9ee is described below
commit 8601aac9ee2c35eb38d70f2fa90f8cb82c4dafc5
Author: Yevgeny Pats <ye...@gmail.com>
AuthorDate: Sat Apr 22 13:13:50 2023 -0400
GH-35256: [Go] Add ToMap to Metadata (#35257)
### Rationale for this change
### What changes are included in this PR?
### Are these changes tested?
### Are there any user-facing changes?
* Closes: #35256
* Closes: #35256
Authored-by: Yevgeny Pats <16...@users.noreply.github.com>
Signed-off-by: Matthew Topol <zo...@gmail.com>
---
go/arrow/schema.go | 7 +++++++
go/arrow/schema_test.go | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/go/arrow/schema.go b/go/arrow/schema.go
index c10530ba82..f1051dac09 100644
--- a/go/arrow/schema.go
+++ b/go/arrow/schema.go
@@ -66,6 +66,13 @@ func MetadataFrom(kv map[string]string) Metadata {
func (md Metadata) Len() int { return len(md.keys) }
func (md Metadata) Keys() []string { return md.keys }
func (md Metadata) Values() []string { return md.values }
+func (md Metadata) ToMap() map[string]string {
+ m := make(map[string]string, len(md.keys))
+ for i := range md.keys {
+ m[md.keys[i]] = md.values[i]
+ }
+ return m
+}
func (md Metadata) String() string {
o := new(strings.Builder)
diff --git a/go/arrow/schema_test.go b/go/arrow/schema_test.go
index 201353d128..9914d8e67a 100644
--- a/go/arrow/schema_test.go
+++ b/go/arrow/schema_test.go
@@ -22,6 +22,7 @@ import (
"testing"
"github.com/apache/arrow/go/v12/arrow/endian"
+ "github.com/stretchr/testify/assert"
)
func TestMetadata(t *testing.T) {
@@ -99,6 +100,9 @@ func TestMetadata(t *testing.T) {
if got, want := tc.md.String(), tc.serialize; got != want {
t.Fatalf("invalid stringer: got=%q, want=%q", got, want)
}
+ if len(tc.kvs) != 0 {
+ assert.Equal(t, tc.kvs, md.ToMap())
+ }
})
}