ext-data-source/test/src/main/java/com/cloudera/impala/extdatasource/AllTypesDataSource.java
/**
   * Adds a row to the set of columns. For all numeric types the value is set to the
   * row index (mod the size for integer types). For strings it is just a string
   * containing the row index and every 5th result is null.
   */
Adds a row to the set of columns. For all numeric types the value is set to the
row index (mod the size for integer types). For strings it is just a string
containing the row index and every 5th result is null.
Adds a row to the set of columns . For all numeric types the value is set to the row index ( mod the size for integer types ) . For strings it is just a string containing the row index and every 5th result is null .
private void addRow(List<TColumnData> cols) {
    for (int i = 0; i < cols.size(); ++i) {
      TColumnDesc colDesc = schema_.getCols().get(i);
      TColumnData colData = cols.get(i);
      TColumnType type = colDesc.getType();
      switch (type.getType()) {
        case TINYINT:
          colData.addToIs_null(false);
          colData.addToByte_vals((byte) (currRow_ % 10));
          break;
        case SMALLINT:
          colData.addToIs_null(false);
          colData.addToShort_vals((short) (currRow_ % 100));
          break;
        case INT:
          colData.addToIs_null(false);
          colData.addToInt_vals(currRow_);
          break;
        case BIGINT:
          colData.addToIs_null(false);
          colData.addToLong_vals((long) currRow_ * 10);
          break;
        case DOUBLE:
          colData.addToIs_null(false);
          colData.addToDouble_vals(currRow_);
          break;
        case FLOAT:
          colData.addToIs_null(false);
          colData.addToDouble_vals((float) (1.1 * currRow_));
          break;
        case STRING:
          if (currRow_ % 5 == 0) {
            colData.addToIs_null(true);
          } else {
            colData.addToIs_null(false);
            colData.addToString_vals(String.valueOf(currRow_));
          }
          break;
        case BOOLEAN:
          colData.addToIs_null(false);
          colData.addToBool_vals(currRow_ % 2 == 0);
          break;
        case TIMESTAMP:
          colData.addToIs_null(false);
          colData.addToBinary_vals(
            SerializationUtils.encodeTimestamp(new Timestamp(currRow_)));
          break;
        case DECIMAL:
          colData.addToIs_null(false);
          BigInteger maxUnscaled = BigInteger.TEN.pow(type.getPrecision());
          BigInteger val = maxUnscaled.subtract(BigInteger.valueOf(currRow_ + 1));
          val = val.mod(maxUnscaled);
          if (currRow_ % 2 == 0) val = val.negate();
          colData.addToBinary_vals(SerializationUtils.encodeDecimal(new BigDecimal(val)));
          break;
        case BINARY:
        case CHAR:
        case DATE:
        case DATETIME:
        case INVALID_TYPE:
        case NULL_TYPE:
        default:
          throw new UnsupportedOperationException("Unsupported column type: " +
              colDesc.getType().getType());
      }
    }
  }
private void addRow ( List < TColumnData > cols ) { for ( int i = 0 ; i < cols . size ( ) ; ++ i ) { TColumnDesc colDesc = schema_ . getCols ( ) . get ( i ) ; TColumnData colData = cols . get ( i ) ; TColumnType type = colDesc . getType ( ) ; switch ( type . getType ( ) ) { case TINYINT : colData . addToIs_null ( false ) ; colData . addToByte_vals ( ( byte ) ( currRow_ % 10 ) ) ; break ; case SMALLINT : colData . addToIs_null ( false ) ; colData . addToShort_vals ( ( short ) ( currRow_ % 100 ) ) ; break ; case INT : colData . addToIs_null ( false ) ; colData . addToInt_vals ( currRow_ ) ; break ; case BIGINT : colData . addToIs_null ( false ) ; colData . addToLong_vals ( ( long ) currRow_ * 10 ) ; break ; case DOUBLE : colData . addToIs_null ( false ) ; colData . addToDouble_vals ( currRow_ ) ; break ; case FLOAT : colData . addToIs_null ( false ) ; colData . addToDouble_vals ( ( float ) ( 1.1 * currRow_ ) ) ; break ; case STRING : if ( currRow_ % 5 == 0 ) { colData . addToIs_null ( true ) ; } else { colData . addToIs_null ( false ) ; colData . addToString_vals ( String . valueOf ( currRow_ ) ) ; } break ; case BOOLEAN : colData . addToIs_null ( false ) ; colData . addToBool_vals ( currRow_ % 2 == 0 ) ; break ; case TIMESTAMP : colData . addToIs_null ( false ) ; colData . addToBinary_vals ( SerializationUtils . encodeTimestamp ( new Timestamp ( currRow_ ) ) ) ; break ; case DECIMAL : colData . addToIs_null ( false ) ; BigInteger maxUnscaled = BigInteger . TEN . pow ( type . getPrecision ( ) ) ; BigInteger val = maxUnscaled . subtract ( BigInteger . valueOf ( currRow_ + 1 ) ) ; val = val . mod ( maxUnscaled ) ; if ( currRow_ % 2 == 0 ) val = val . negate ( ) ; colData . addToBinary_vals ( SerializationUtils . encodeDecimal ( new BigDecimal ( val ) ) ) ; break ; case BINARY : case CHAR : case DATE : case DATETIME : case INVALID_TYPE : case NULL_TYPE : default : throw new UnsupportedOperationException ( "Unsupported column type: " + colDesc . getType ( ) . getType ( ) ) ; } } }
Adds a row to the set of columns.
Adds a row to the set of columns .
// Unsupported.