Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5613

Add assert for number of args for metadata methods at CacheGeneratorUtil

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.34.0
    • 1.38.0
    • core

    Description

      The problem is that it implicitly implies that method should have 2+ args based on org.apache.calcite.rel.metadata.janino.CacheGeneratorUtil.CacheKeyStrategy#safeArgList.

      At the same time different libs like JaCoCo could generate extra methods like private static boolean[] org.apache.calcite.rel.metadata.BuiltInMetadata$Predicates$Handler.$jacocoInit().

      It took several hours to realize it.... since currently it complains like

      java.lang.IllegalArgumentException: fromIndex(2) > toIndex(0)
      	at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
      	at java.base/java.util.AbstractList.subList(AbstractList.java:497)
      	at org.apache.calcite.rel.metadata.janino.CacheGeneratorUtil$CacheKeyStrategy$1.safeArgList(CacheGeneratorUtil.java:213)
      	at org.apache.calcite.rel.metadata.janino.CacheGeneratorUtil$CacheKeyStrategy$1.cacheKeyBlock(CacheGeneratorUtil.java:205)
      ...
      

      The idea is to put assert something like that

      assert method.getParameterCount() >= 2 : method.toString();
      

      to simplify the process of finding the root cause

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Sergey Nuyanzin Sergey Nuyanzin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: