Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-4070

Optimize Check Max Collection Length for New Collections

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 1.12.0
    • 1.13.0
    • java
    • None

    Description

      To squeeze out a little more performance, the following 'checkMaxCollectionLength()' method can be streamlined given: the first parameter is always 0L and the second parameter is always greater than or equal to zero.

        public long readArrayStart() throws IOException {
          collectionCount = SystemLimitException.checkMaxCollectionLength(0L, doReadItemCount());
          return collectionCount;
        }
      
        /**
         * A block with count zero indicates
         * the end of the array. If a block's count is negative, its absolute value is
         * used, and the count is followed immediately by a long block size indicating
         * the number of bytes in the block.
         */
      protected long doReadItemCount() throws IOException {
          long result = readLong();
          if (result < 0L) {
            // Consume byte-count if present
            readLong();
            result = -result;
          }
          return result;
        }
      

      This gets called for every Array start and therefore is a hot path.

      Attachments

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: