beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [beam] branch master updated: [BEAM-6652] Restrict map usage.
Date Mon, 11 Feb 2019 23:26:35 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new db84f31  [BEAM-6652] Restrict map usage.
     new 4e21e20  Merge pull request #7814 from lostluck/restrictMap
db84f31 is described below

commit db84f3102a887facfafdc98864e8b506a02ef608
Author: Robert Burke <robert@frantil.com>
AuthorDate: Mon Feb 11 22:08:38 2019 +0000

    [BEAM-6652] Restrict map usage.
---
 sdks/go/pkg/beam/core/typex/class.go      | 12 ++++++++++--
 sdks/go/pkg/beam/core/typex/class_test.go |  4 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/sdks/go/pkg/beam/core/typex/class.go b/sdks/go/pkg/beam/core/typex/class.go
index cb34ad7..8d58368 100644
--- a/sdks/go/pkg/beam/core/typex/class.go
+++ b/sdks/go/pkg/beam/core/typex/class.go
@@ -122,8 +122,16 @@ func isConcrete(t reflect.Type, visited map[uintptr]bool) bool {
 		return false // no unserializable types
 
 	case reflect.Map:
-		return isConcrete(t.Elem(), visited) && isConcrete(t.Key(), visited)
-
+		// TODO(BEAM-6652): 2019.02.11
+		// Maps have random default iteration order, and the "default coder"
+		// doesn't ensure a specific encoding order for key/value pairs in maps.
+		// To ensure correctness we're better off restricting map usage from
+		// casual users, until the default coder handles the random iteration
+		// order properly.
+		// Power users can continue to handle map coding themselves, though
+		// it remains their responsibility to encode them consistently.
+		// return isConcrete(t.Elem(), visited) && isConcrete(t.Key(), visited)
+		return false
 	case reflect.Array, reflect.Slice, reflect.Ptr:
 		return isConcrete(t.Elem(), visited)
 
diff --git a/sdks/go/pkg/beam/core/typex/class_test.go b/sdks/go/pkg/beam/core/typex/class_test.go
index 8fc250f..be74254 100644
--- a/sdks/go/pkg/beam/core/typex/class_test.go
+++ b/sdks/go/pkg/beam/core/typex/class_test.go
@@ -51,7 +51,7 @@ func TestClassOf(t *testing.T) {
 		}{}), Concrete},
 		{reflect.TypeOf(struct{ A []int }{}), Concrete},
 		{reflect.TypeOf(reflect.Value{}), Concrete}, // ok: private fields
-		{reflect.TypeOf(map[string]int{}), Concrete},
+		{reflect.TypeOf(map[string]int{}), Invalid},
 		{reflect.TypeOf(map[string]func(){}), Invalid},
 		{reflect.TypeOf(map[error]int{}), Invalid},
 		{reflect.TypeOf([4]int{}), Concrete},
@@ -73,8 +73,8 @@ func TestClassOf(t *testing.T) {
 		// Recursive types.
 		{reflect.TypeOf(RecursivePtrTest{}), Concrete},
 		{reflect.TypeOf(RecursiveSliceTest{}), Concrete},
-		{reflect.TypeOf(RecursiveMapTest{}), Concrete},
 		{reflect.TypeOf(RecursivePtrArrayTest{}), Concrete},
+		{reflect.TypeOf(RecursiveMapTest{}), Invalid},
 		{reflect.TypeOf(RecursiveBadTest{}), Invalid},
 
 		{reflect.TypeOf([]X{}), Container},


Mime
View raw message