当前位置: 首页>>代码示例>>Java>>正文


Java DataType.BYTE属性代码示例

本文整理汇总了Java中org.apache.pig.data.DataType.BYTE属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.BYTE属性的具体用法?Java DataType.BYTE怎么用?Java DataType.BYTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.pig.data.DataType的用法示例。


在下文中一共展示了DataType.BYTE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKettleType

private static String getKettleType( byte type ) {

    switch ( type ) {
      case DataType.BYTE:
      case DataType.BYTEARRAY:
        return "Binary";
      case DataType.BOOLEAN:
        return "Boolean";
      case DataType.CHARARRAY:
      case DataType.BIGCHARARRAY:
        return "String";
      case DataType.DATETIME:
        return "Timestamp";
      case DataType.INTEGER:
      case DataType.LONG:
        return "Integer";
      case DataType.BIGINTEGER:
      case DataType.BIGDECIMAL:
        return "BigNumber";
      case DataType.FLOAT:
      case DataType.DOUBLE:
        return "Number";
      default:
        return "Binary"; // TODO is this right?
    }
  }
 
开发者ID:mattyb149,项目名称:pdi-pig-udfs,代码行数:26,代码来源:RunKettleTrans.java

示例2: primitiveComparator

/**
 * Comparator for primitive types.
 * 
 * @param index
 *          Index in the source tuple.
 * @param type
 *          One of the constants defined in {@link DataType} for primitive
 *          types.
 * @return Comparator expression.
 */
public static ComparatorExpr primitiveComparator(int index, int type) {
  switch (type) {
    case DataType.BOOLEAN:
      return new BooleanExpr(index);
    case DataType.BYTE:
      return new ByteExpr(index);
    case DataType.BYTEARRAY:
      return new BytesExpr(index);
    case DataType.CHARARRAY:
      return new StringExpr(index);
    case DataType.DOUBLE:
      return new DoubleExpr(index);
    case DataType.FLOAT:
      return new FloatExpr(index);
    case DataType.INTEGER:
      return new IntExpr(index);
    case DataType.LONG:
      return new LongExpr(index);
    case DataType.DATETIME:
      return new DateTimeExpr(index);
    default:
      throw new RuntimeException("Not a prmitive PIG type");
  }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:34,代码来源:ExprUtils.java

示例3: sqlDataTypeFromPigDataType

protected int sqlDataTypeFromPigDataType(byte pigDataType) {
    switch(pigDataType) {
    case DataType.INTEGER:
        return java.sql.Types.INTEGER;
    case DataType.LONG:
        return java.sql.Types.BIGINT;
    case DataType.FLOAT:
        return java.sql.Types.FLOAT;
    case DataType.DOUBLE:
        return java.sql.Types.DOUBLE;
    case DataType.BOOLEAN:
        return java.sql.Types.BOOLEAN;
    case DataType.DATETIME:
        return java.sql.Types.DATE;
    case DataType.BYTEARRAY:
    case DataType.CHARARRAY:
    case DataType.BYTE:
        return java.sql.Types.VARCHAR;
    default:
        log.warn("Can not find SQL data type for " + pigDataType + " returning VARCHAR");
        return java.sql.Types.VARCHAR;
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:23,代码来源:DBStorage.java

示例4: translateWritableToPigDataType

protected Object translateWritableToPigDataType(Writable w, byte dataType) {
  switch(dataType) {
    case DataType.CHARARRAY: return ((Text) w).toString();
    case DataType.BYTEARRAY:
          BytesWritable bw = (BytesWritable) w;
          // Make a copy
          return new DataByteArray(bw.getBytes(), 0, bw.getLength());
    case DataType.BOOLEAN: return ((BooleanWritable) w).get();
    case DataType.INTEGER: return ((IntWritable) w).get();
    case DataType.LONG: return ((LongWritable) w).get();
    case DataType.FLOAT: return ((FloatWritable) w).get();
    case DataType.DOUBLE: return ((DoubleWritable) w).get();
    case DataType.BYTE: return ((ByteWritable) w).get();
    case DataType.DATETIME: return ((DateTimeWritable) w).get();
  }

  return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:SequenceFileLoader.java

示例5: getTypedObject

private TypedObject getTypedObject(Object data, FieldDetail detail) throws ExecException {
    if (data == null) {
        return null;
    }
    byte type = detail.type;
    switch (type) {
        case DataType.BOOLEAN:
            return TypeSystem.asTypedObject(DataType.toBoolean(data, type));
        case DataType.INTEGER:
        case DataType.LONG:
            return TypeSystem.asTypedObject(DataType.toLong(data, type));
        case DataType.FLOAT:
        case DataType.DOUBLE:
            return TypeSystem.asTypedObject(DataType.toDouble(data, type));
        case DataType.DATETIME:
            return TypeSystem.asTypedObject(new Timestamp(DataType.toDateTime(data, type).getMillis()));
        case DataType.BYTE:
        case DataType.BYTEARRAY:
        case DataType.CHARARRAY:
            return TypeSystem.asTypedObject(DataType.toString(data, type));
        case DataType.BIGINTEGER:
        case DataType.BIGDECIMAL:
            return TypeSystem.asTypedObject(DataType.toBigDecimal(data, type));
        default:
            //TUPLE, BAG, MAP, INTERNALMAP, GENERIC_WRITABLECOMPARABLE, ERROR, UNKNOWN, NULL and anything else
            return null;
    }
}
 
开发者ID:yahoo,项目名称:validatar,代码行数:28,代码来源:Sty.java

示例6: inferPigDataType

protected byte inferPigDataType(Type t) {
  if (t == DataByteArray.class) return DataType.BYTEARRAY;
  else if (t == Text.class) return DataType.CHARARRAY;
  else if (t == IntWritable.class) return DataType.INTEGER;
  else if (t == LongWritable.class) return DataType.LONG;
  else if (t == FloatWritable.class) return DataType.FLOAT;
  else if (t == DoubleWritable.class) return DataType.DOUBLE;
  else if (t == BooleanWritable.class) return DataType.BOOLEAN;
  else if (t == ByteWritable.class) return DataType.BYTE;
  else if (t == DateTimeWritable.class) return DataType.DATETIME;
  // not doing maps or other complex types for now
  else return DataType.ERROR;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:SequenceFileLoader.java

示例7: translateWritableToPigDataType

protected Object translateWritableToPigDataType(Writable w, byte dataType) {
  switch(dataType) {
    case DataType.CHARARRAY: return ((Text) w).toString();
    case DataType.BYTEARRAY: return((DataByteArray) w).get();
    case DataType.BOOLEAN: return ((BooleanWritable) w).get();
    case DataType.INTEGER: return ((IntWritable) w).get();
    case DataType.LONG: return ((LongWritable) w).get();
    case DataType.FLOAT: return ((FloatWritable) w).get();
    case DataType.DOUBLE: return ((DoubleWritable) w).get();
    case DataType.BYTE: return ((ByteWritable) w).get();
    case DataType.DATETIME: return ((DateTimeWritable) w).get();
  }
  
  return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:SequenceFileLoader.java

示例8: inferPigDataType

protected byte inferPigDataType(Type t) {
  if (t == BytesWritable.class) return DataType.BYTEARRAY;
  else if (t == Text.class) return DataType.CHARARRAY;
  else if (t == IntWritable.class) return DataType.INTEGER;
  else if (t == LongWritable.class) return DataType.LONG;
  else if (t == FloatWritable.class) return DataType.FLOAT;
  else if (t == DoubleWritable.class) return DataType.DOUBLE;
  else if (t == BooleanWritable.class) return DataType.BOOLEAN;
  else if (t == ByteWritable.class) return DataType.BYTE;
  else if (t == DateTimeWritable.class) return DataType.DATETIME;
  // not doing maps or other complex types for now
  else return DataType.ERROR;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:13,代码来源:SequenceFileLoader.java

示例9: updateUnion

static void updateUnion(final DataBag bag, final Union union) throws ExecException {
  //Bag is not empty. process each innerTuple in the bag
  for (final Tuple innerTuple: bag) {
    final Object f0 = innerTuple.get(0); // consider only field 0
    if (f0 == null) {
      continue;
    }
    final byte type = innerTuple.getType(0);

    switch (type) {
      case DataType.NULL:
        break;
      case DataType.BYTE:
        union.update((byte) f0);
        break;
      case DataType.INTEGER:
        union.update((int) f0);
        break;
      case DataType.LONG:
        union.update((long) f0);
        break;
      case DataType.FLOAT:
        union.update((float) f0);
        break;
      case DataType.DOUBLE:
        union.update((double) f0);
        break;
      case DataType.BYTEARRAY: {
        final DataByteArray dba = (DataByteArray) f0;
        union.update(dba.get());
        break;
      }
      case DataType.CHARARRAY: {
        final String str = (String) f0;
        // conversion to char[] avoids costly UTF-8 encoding
        union.update(str.toCharArray());
        break;
      }
      default:
        throw new IllegalArgumentException("Field 0 of innerTuple must be one of "
            + "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. "
            + "Given Type = " + DataType.findTypeName(type)
            + ", Object = " + f0.toString());
    }
  }
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:46,代码来源:DataToSketch.java

示例10: updateSketch

static void updateSketch(
    final DataBag bag, final ArrayOfDoublesUpdatableSketch sketch, final int numValues)
        throws ExecException {
  if (bag == null) {
    throw new IllegalArgumentException("InputTuple.Field0: Bag may not be null");
  }
  final double[] values = new double[numValues];
  for (final Tuple tuple: bag) {
    if (tuple.size() != numValues + 1) {
      throw new IllegalArgumentException("Inner tuple of input bag must have " + (numValues + 1)
          + " fields.");
    }

    final Object key = tuple.get(0);
    if (key == null) { continue; }
    for (int i = 0; i < numValues; i++) {
      values[i] = (Double) tuple.get(i + 1);
    }

    switch (tuple.getType(0)) {
    case DataType.BYTE:
      sketch.update(((Byte) key).longValue(), values);
      break;
    case DataType.INTEGER:
      sketch.update(((Integer) key).longValue(), values);
      break;
    case DataType.LONG:
      sketch.update((Long) key, values);
      break;
    case DataType.FLOAT:
      sketch.update((Float) key, values);
      break;
    case DataType.DOUBLE:
      sketch.update((Double) key, values);
      break;
    case DataType.BYTEARRAY:
      final DataByteArray dba = (DataByteArray) key;
      if (dba.size() != 0) {
        sketch.update(dba.get(), values);
      }
      break;
    case DataType.CHARARRAY:
      final String s = key.toString();
      if (!s.isEmpty()) {
        sketch.update(s, values);
      }
      break;
    default:
      throw new IllegalArgumentException("Field 0 must be one of "
          + "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. " + "Type = "
          + DataType.findTypeName(tuple.getType(0)) + ", Object = " + key.toString());
    }
  }
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:54,代码来源:DataToArrayOfDoublesSketchBase.java

示例11: updateSketch

static <U, S extends UpdatableSummary<U>> void updateSketch(final DataBag bag,
      final UpdatableSketch<U, S> sketch) throws ExecException {
  if (bag == null) {
    throw new IllegalArgumentException("InputTuple.Field0: Bag may not be null");
  }
  for (final Tuple tuple: bag) {
    if (tuple.size() != 2) {
      throw new IllegalArgumentException("Inner tuple of input bag must have 2 fields.");
    }

    final Object key = tuple.get(0);
    if (key == null) { continue; }
    @SuppressWarnings("unchecked")
    final U value = (U) tuple.get(1);

    switch (tuple.getType(0)) {
    case DataType.BYTE:
      sketch.update(((Byte) key).longValue(), value);
      break;
    case DataType.INTEGER:
      sketch.update(((Integer) key).longValue(), value);
      break;
    case DataType.LONG:
      sketch.update((Long) key, value);
      break;
    case DataType.FLOAT:
      sketch.update((Float) key, value);
      break;
    case DataType.DOUBLE:
      sketch.update((Double) key, value);
      break;
    case DataType.BYTEARRAY:
      final DataByteArray dba = (DataByteArray) key;
      if (dba.size() != 0) {
        sketch.update(dba.get(), value);
      }
      break;
    case DataType.CHARARRAY:
      final String s = key.toString();
      if (!s.isEmpty()) {
        sketch.update(s, value);
      }
      break;
    default:
      throw new IllegalArgumentException("Field 0 must be one of "
          + "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. " + "Type = "
          + DataType.findTypeName(tuple.getType(0)) + ", Object = " + key.toString());
    }
  }
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:50,代码来源:DataToSketch.java

示例12: updateUnion

/*************************************************************************************************
 * Updates a union with the data from the given bag.
 *
 * @param bag A bag of tuples to insert.
 * @param union the union to update
 */
private static void updateUnion(final DataBag bag, final Union union) {
  //Bag is not empty. process each innerTuple in the bag
  for (Tuple innerTuple : bag) {
    final Object f0 = extractFieldAtIndex(innerTuple, 0); //consider only field 0
    if (f0 == null) {
      continue;
    }
    final Byte type = extractTypeAtIndex(innerTuple, 0);
    if (type == null) {
      continue;
    }

    switch (type) {
      case DataType.NULL:
        break;
      case DataType.BYTE:
        union.update((byte) f0);
        break;
      case DataType.INTEGER:
        union.update((int) f0);
        break;
      case DataType.LONG:
        union.update((long) f0);
        break;
      case DataType.FLOAT:
        union.update((float) f0);
        break;
      case DataType.DOUBLE:
        union.update((double) f0);
        break;
      case DataType.BYTEARRAY: {
        final DataByteArray dba = (DataByteArray) f0;
        union.update(dba.get()); //checks null, empty
        break;
      }
      case DataType.CHARARRAY: {
        union.update(f0.toString()); //checks null, empty
        break;
      }
      default: // types not handled
        throw new IllegalArgumentException("Field 0 of innerTuple must be one of "
            + "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. "
            + "Given Type = " + DataType.findTypeName(type)
            + ", Object = " + f0.toString());
    } //End switch
  } //End for
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:53,代码来源:DataToSketch.java

示例13: pickTest

/**
 * To show that it does not have any type specific
 * code
 */
private void pickTest(byte t, boolean[] inner) throws ExecException, IOException {
    Random r = new Random();
    switch (t) {
    case DataType.BAG:
        runTest(GenRandomData.genRandSmallTupDataBag(r, 10, 100), inner, DataType.BAG);
        break;
    case DataType.BOOLEAN:
        runTest(r.nextBoolean(), inner, DataType.BOOLEAN);
        break;
    case DataType.BYTEARRAY:
        runTest(GenRandomData.genRandDBA(r), inner, DataType.BYTEARRAY);
        break;
    case DataType.BIGCHARARRAY: {
        String s = GenRandomData.genRandString(r);
        for (; s.length() < 65535;) {
            s += GenRandomData.genRandString(r);
        }
        runTest(s, inner, DataType.CHARARRAY);
        break;
    }
    case DataType.CHARARRAY:
        runTest(GenRandomData.genRandString(r), inner, DataType.CHARARRAY);
        break;
    case DataType.DOUBLE:
        runTest(r.nextDouble(), inner, DataType.DOUBLE);
        break;
    case DataType.FLOAT:
        runTest(r.nextFloat(), inner, DataType.FLOAT);
        break;
    case DataType.INTEGER:
        runTest(r.nextInt(), inner, DataType.INTEGER);
        break;
    case DataType.LONG:
        runTest(r.nextLong(), inner, DataType.LONG);
        break;
    case DataType.DATETIME:
        runTest(new DateTime(r.nextLong()), inner, DataType.DATETIME);
        break;
    case DataType.MAP:
    case DataType.INTERNALMAP:
    case DataType.BYTE:
        return; // map not key type
    case DataType.TUPLE:
        runTest(GenRandomData.genRandSmallBagTuple(r, 10, 100), inner, DataType.TUPLE);
        break;
    case DataType.BIGINTEGER:
        runTest(new BigInteger(256, r), inner, DataType.BIGINTEGER);
        break;
    case DataType.BIGDECIMAL:
        runTest(new BigDecimal(r.nextDouble()), inner, DataType.BIGDECIMAL);
        break;
    default:
        fail("No test case for type " + DataType.findTypeName(t));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:59,代码来源:TestPackage.java


注:本文中的org.apache.pig.data.DataType.BYTE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。