You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by StephanEwen <gi...@git.apache.org> on 2015/09/22 15:54:09 UTC

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

GitHub user StephanEwen opened a pull request:

    https://github.com/apache/flink/pull/1166

    [FLINK-2734] [streaming] Fix ArrayKeySelector

    The `ArrayKeySelector` is broken and returns wrong values in all cases except for `[0]` as a single only key position.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/StephanEwen/incubator-flink array_key_selector

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/1166.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1166
    
----
commit 1764d256f6d25346ef54d148d87210f919249e22
Author: Stephan Ewen <se...@apache.org>
Date:   2015-09-22T13:51:13Z

    [FLINK-2734] [streaming] Fix ArrayKeySelector

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1166#discussion_r40178507
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java ---
    @@ -152,10 +119,9 @@ public ArrayKeySelector(int... fields) {
     
     		@Override
     		public Tuple getKey(IN value) throws Exception {
    -			key = (Tuple) tupleClasses[fields.length - 1].newInstance();
    +			Tuple key = Tuple.getTupleClass(fields.length).newInstance();
     			for (int i = 0; i < fields.length; i++) {
    -				int pos = fields[i];
    --- End diff --
    
    How far are we with the release candidate? We might still be able to include it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by uce <gi...@git.apache.org>.
Github user uce commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1166#discussion_r40152579
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/util/keys/ArrayKeySelectorTest.java ---
    @@ -0,0 +1,74 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.streaming.util.keys;
    +
    +import org.apache.flink.api.java.tuple.Tuple1;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.junit.Test;
    +
    +import static org.junit.Assert.*;
    +
    +public class ArrayKeySelectorTest {
    +
    +	@Test
    +	public void testObjectArrays() {
    +		try {
    +			Object[] array1 = { "a", "b", "c", "d", "e" };
    +			Object[] array2 = { "v", "w", "x", "y", "z" };
    +			
    +			KeySelectorUtil.ArrayKeySelector<Object[]> singleFieldSelector = new KeySelectorUtil.ArrayKeySelector<>(1);
    +			
    +			assertEquals(new Tuple1<>("b"), singleFieldSelector.getKey(array1));
    +			assertEquals(new Tuple1<>("w"), singleFieldSelector.getKey(array2));
    +
    +			KeySelectorUtil.ArrayKeySelector<Object[]> twoFieldsSelector = new KeySelectorUtil.ArrayKeySelector<>(3, 0);
    +			
    +			assertEquals(new Tuple2<>("d", "a"), twoFieldsSelector.getKey(array1));
    +			assertEquals(new Tuple2<>("y", "v"), twoFieldsSelector.getKey(array2));
    +			
    +		}
    +		catch (Exception e) {
    +			e.printStackTrace();
    +			fail(e.getMessage());
    +		}
    --- End diff --
    
    I don't think we need the try-catch block here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:

    https://github.com/apache/flink/pull/1166#issuecomment-142636571
  
    Manually merged!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen closed the pull request at:

    https://github.com/apache/flink/pull/1166


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:

    https://github.com/apache/flink/pull/1166#issuecomment-142356224
  
    The failed tests refer to an earlier version of the code.
    
    The current version passe, see here: https://travis-ci.org/StephanEwen/incubator-flink/builds/81597319


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by uce <gi...@git.apache.org>.
Github user uce commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1166#discussion_r40154386
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java ---
    @@ -152,10 +119,9 @@ public ArrayKeySelector(int... fields) {
     
     		@Override
     		public Tuple getKey(IN value) throws Exception {
    -			key = (Tuple) tupleClasses[fields.length - 1].newInstance();
    +			Tuple key = Tuple.getTupleClass(fields.length).newInstance();
     			for (int i = 0; i < fields.length; i++) {
    -				int pos = fields[i];
    --- End diff --
    
    This was the bug... Wow. That's super critical... I am wondering whether this should be part of 0.10 milestone 1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2734] [streaming] Fix ArrayKeySelector

Posted by uce <gi...@git.apache.org>.
Github user uce commented on the pull request:

    https://github.com/apache/flink/pull/1166#issuecomment-142442964
  
    +1 good catch and good test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---