public static List<Map<String, Serializable>> transformDataTableToGroupByResult(
     DataTable dataTable) {
   List<Map<String, Serializable>> aggregationGroupByResults =
       new ArrayList<Map<String, Serializable>>();
   for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
     String key = dataTable.getString(i, 0);
     Map<String, Serializable> hashMap = (Map<String, Serializable>) dataTable.getObject(i, 1);
     aggregationGroupByResults.add(hashMap);
   }
   return aggregationGroupByResults;
 }
Ejemplo n.º 2
0
 public static Serializable[] extractRowFromDataTable(DataTable dt, int rowId) {
   final Serializable[] row = new Serializable[dt.getDataSchema().size()];
   for (int i = 0; i < dt.getDataSchema().size(); ++i) {
     if (dt.getDataSchema().getColumnType(i).isSingleValue()) {
       switch (dt.getDataSchema().getColumnType(i)) {
         case INT:
           row[i] = dt.getInt(rowId, i);
           break;
         case LONG:
           row[i] = dt.getLong(rowId, i);
           break;
         case DOUBLE:
           row[i] = dt.getDouble(rowId, i);
           break;
         case FLOAT:
           row[i] = dt.getFloat(rowId, i);
           break;
         case STRING:
           row[i] = dt.getString(rowId, i);
           break;
         case SHORT:
           row[i] = dt.getShort(rowId, i);
           break;
         case CHAR:
           row[i] = dt.getChar(rowId, i);
           break;
         case BYTE:
           row[i] = dt.getByte(rowId, i);
           break;
         default:
           row[i] = dt.getObject(rowId, i);
           break;
       }
     } else {
       switch (dt.getDataSchema().getColumnType(i)) {
         case INT_ARRAY:
           row[i] = dt.getIntArray(rowId, i);
           break;
         case LONG_ARRAY:
           row[i] = dt.getLongArray(rowId, i);
           break;
         case DOUBLE_ARRAY:
           row[i] = dt.getDoubleArray(rowId, i);
           break;
         case FLOAT_ARRAY:
           row[i] = dt.getFloatArray(rowId, i);
           break;
         case STRING_ARRAY:
           row[i] = dt.getStringArray(rowId, i);
           break;
         case CHAR_ARRAY:
           row[i] = dt.getCharArray(rowId, i);
           break;
         case BYTE_ARRAY:
           row[i] = dt.getByteArray(rowId, i);
           break;
         default:
           row[i] = dt.getObject(rowId, i);
           break;
       }
     }
   }
   return row;
 }