Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-23307

Cache ColumnIndex in HiveBaseResultSet

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.2
    • 4.0.0-alpha-1
    • JDBC
    • None

    Description

        public int findColumn(String columnName) throws SQLException {
          int columnIndex = 0;
          boolean findColumn = false;
          for (String normalizedColumnName : normalizedColumnNames) {
            ++columnIndex;
            String[] names = normalizedColumnName.split("\\.");
            String name = names[names.length -1];
            if (name.equalsIgnoreCase(columnName) || normalizedColumnName.equalsIgnoreCase(columnName)) {
              findColumn = true;
              break;
            }
          }
          if (!findColumn) {
            throw new SQLException("Could not find " + columnName + " in " + normalizedColumnNames);
          } else {
            return columnIndex;
          }
        }
      

      Cache the column name to column index map to avoid having to look it up again and again for each row O(n^2)

      Attachments

        1. HIVE-23307.1.patch
          7 kB
          David Mollitor

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: