You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Ran Tao (Jira)" <ji...@apache.org> on 2022/05/06 08:19:00 UTC

[jira] [Updated] (FLINK-27529) HybridSourceSplitEnumerator sourceIndex using error Integer check

     [ https://issues.apache.org/jira/browse/FLINK-27529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ran Tao updated FLINK-27529:
----------------------------
    Description: 
Currently HybridSourceSplitEnumerator check readerSourceIndex using Integer type but == operator.  In some case, it will cause error(Integer == only works fine in [-127,128]) we can use Integer.equals instead. But actually readerSourceIndex is primitive int intrinsically,so we can change Integer to int to check sourceIndex instead of Integer.equals method.  it will be more elegant.



{code:java}
@Override
        public Map<Integer, ReaderInfo> registeredReaders() {
            // TODO: not start enumerator until readers are ready?
            Map<Integer, ReaderInfo> readers = realContext.registeredReaders();
            if (readers.size() != readerSourceIndex.size()) {
                return filterRegisteredReaders(readers);
            }
            Integer lastIndex = null;
            for (Integer sourceIndex : readerSourceIndex.values()) {
                if (lastIndex != null && lastIndex != sourceIndex) {
                    return filterRegisteredReaders(readers);
                }
                lastIndex = sourceIndex;
            }
            return readers;
        }

        private Map<Integer, ReaderInfo> filterRegisteredReaders(Map<Integer, ReaderInfo> readers) {
            Map<Integer, ReaderInfo> readersForSource = new HashMap<>(readers.size());
            for (Map.Entry<Integer, ReaderInfo> e : readers.entrySet()) {
                if (readerSourceIndex.get(e.getKey()) == (Integer) sourceIndex) {
                    readersForSource.put(e.getKey(), e.getValue());
                }
            }
            return readersForSource;
        }
{code}


  was:
Currently HybridSourceSplitEnumerator check readerSourceIndex using Integer type but == operator.  In some case, it will cause error(Integer == only works fine in [-127,128]) we can use Integer.equals instead. But actually readerSourceIndex is primitive int intrinsically,so we can change Integer to int to check sourceIndex instead of Integer.equals method.  it will be more elegant.

{code:java}
@Override
        public Map<Integer, ReaderInfo> registeredReaders() {
            // TODO: not start enumerator until readers are ready?
            Map<Integer, ReaderInfo> readers = realContext.registeredReaders();
            if (readers.size() != readerSourceIndex.size()) {
                return filterRegisteredReaders(readers);
            }
            Integer lastIndex = null;
            for (Integer sourceIndex : readerSourceIndex.values()) {
                if (lastIndex != null && lastIndex != sourceIndex) {
                    return filterRegisteredReaders(readers);
                }
                lastIndex = sourceIndex;
            }
            return readers;
        }

        private Map<Integer, ReaderInfo> filterRegisteredReaders(Map<Integer, ReaderInfo> readers) {
            Map<Integer, ReaderInfo> readersForSource = new HashMap<>(readers.size());
            for (Map.Entry<Integer, ReaderInfo> e : readers.entrySet()) {
                if (readerSourceIndex.get(e.getKey()) == (Integer) sourceIndex) {
                    readersForSource.put(e.getKey(), e.getValue());
                }
            }
            return readersForSource;
        }
{code}



> HybridSourceSplitEnumerator sourceIndex using error Integer check
> -----------------------------------------------------------------
>
>                 Key: FLINK-27529
>                 URL: https://issues.apache.org/jira/browse/FLINK-27529
>             Project: Flink
>          Issue Type: Bug
>          Components: Connectors / Common
>    Affects Versions: 1.15.0, 1.14.4, 1.15.1
>            Reporter: Ran Tao
>            Priority: Major
>
> Currently HybridSourceSplitEnumerator check readerSourceIndex using Integer type but == operator.  In some case, it will cause error(Integer == only works fine in [-127,128]) we can use Integer.equals instead. But actually readerSourceIndex is primitive int intrinsically,so we can change Integer to int to check sourceIndex instead of Integer.equals method.  it will be more elegant.
> {code:java}
> @Override
>         public Map<Integer, ReaderInfo> registeredReaders() {
>             // TODO: not start enumerator until readers are ready?
>             Map<Integer, ReaderInfo> readers = realContext.registeredReaders();
>             if (readers.size() != readerSourceIndex.size()) {
>                 return filterRegisteredReaders(readers);
>             }
>             Integer lastIndex = null;
>             for (Integer sourceIndex : readerSourceIndex.values()) {
>                 if (lastIndex != null && lastIndex != sourceIndex) {
>                     return filterRegisteredReaders(readers);
>                 }
>                 lastIndex = sourceIndex;
>             }
>             return readers;
>         }
>         private Map<Integer, ReaderInfo> filterRegisteredReaders(Map<Integer, ReaderInfo> readers) {
>             Map<Integer, ReaderInfo> readersForSource = new HashMap<>(readers.size());
>             for (Map.Entry<Integer, ReaderInfo> e : readers.entrySet()) {
>                 if (readerSourceIndex.get(e.getKey()) == (Integer) sourceIndex) {
>                     readersForSource.put(e.getKey(), e.getValue());
>                 }
>             }
>             return readersForSource;
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)