Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-9429

Radish HSCAN implementation cannot handle values for COUNT greater than Integer.MAX_VALUE / 2

    XMLWordPrintableJSON

Details

    Description

      The below code is the current implementation of HSCAN in RedisHash. When the value of count passed to this method is greater than Integer.MAX_VALUE / 2 the condition of the while loop suffers from integer overflow and the loop does not execute correctly.

        public ImmutablePair<Integer, List<byte[]>> hscan(Pattern matchPattern, int count, int cursor) {
      
          ArrayList<byte[]> resultList = new ArrayList<>(count + 2);
          do {
            cursor = hash.scan(cursor, 1,
                (list, key, value) -> addIfMatching(matchPattern, list, key, value), resultList);
          } while (cursor != 0 && resultList.size() < (count * 2));
      
          return new ImmutablePair<>(cursor, resultList);
      

      This could be fixed by changing the type of resultList to List<ImmutablePair<byte[] byte[]>> and modifying the addIfMatching() method to populate the list with {{ImmutablePair}}s of keys and values rather than a single continuous list of interleaved keys and values.

      Attachments

        Issue Links

          Activity

            People

              donalevans Donal Evans
              donalevans Donal Evans
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: