private void insertSkewedValInBatch(List<Long> stringListIds, Map<Long, Long> stringListIdToSdId)
      throws MetaException {
    int rowCount = stringListIds.size();
    String columns = "(\"SD_ID_OID\",\"STRING_LIST_ID_EID\",\"INTEGER_IDX\")";
    int columnCount = 3;
    BatchExecutionContext batchExecutionContext = new BatchExecutionContext() {
      int colIndex = 0;
      long prevSdId = -1;
      final Iterator<Long> it = stringListIds.iterator();
      @Override
      public void execute(String batchQueryText, int batchRowCount) throws MetaException {
        Object[] params = new Object[batchRowCount * columnCount];
        int paramIndex = 0;
        for (int index = 0; index < batchRowCount; index++) {
          Long stringListId = it.next();
          Long sdId = stringListIdToSdId.get(stringListId);
          params[paramIndex++] = sdId;
          params[paramIndex++] = stringListId;
          if (prevSdId != sdId) {
            colIndex = 0;
          }
          params[paramIndex++] = colIndex++;
          prevSdId = sdId;
        }
        executeQuery(batchQueryText, params);
      }
    };
    insertInBatch("\"SKEWED_VALUES\"", columns, columnCount, rowCount, batchExecutionContext);
  }
Interface to execute multiple row insert query in batch for direct SQL
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlInsertPart.java