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


Java DataType.DATETIME属性代码示例

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


在下文中一共展示了DataType.DATETIME属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getResult

private Result getResult(ExpressionOperator op) throws ExecException {
    Result res;
    switch (op.getResultType()) {
    case DataType.BAG:
    case DataType.BOOLEAN:
    case DataType.BYTEARRAY:
    case DataType.CHARARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.INTEGER:
    case DataType.LONG:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.DATETIME:
    case DataType.MAP:
    case DataType.TUPLE:
        res = op.getNext(op.getResultType());
        break;
    default:
        String msg = "Invalid result type: "
                + DataType.findType(op.getResultType());
        throw new ExecException(msg, 2270, PigException.BUG);
    }

    return res;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:26,代码来源:POPartialAgg.java

示例3: typeName

public String typeName(byte type) {
    switch(type) {
        case (DataType.INTEGER): return "int";
        case (DataType.LONG): return "long";
        case (DataType.FLOAT): return "float";
        case (DataType.DOUBLE): return "double";
        case (DataType.BYTEARRAY): return "byte[]";
        case (DataType.CHARARRAY): return "String";
        case (DataType.BOOLEAN): return "boolean";
        case (DataType.DATETIME): return "DateTime";
        case (DataType.BIGDECIMAL): return "BigDecimal";
        case (DataType.BIGINTEGER): return "BigInteger";
        case (DataType.TUPLE): return "Tuple";
        case (DataType.BAG): return "DataBag";
        case (DataType.MAP): return "Map";
        default: throw new RuntimeException("Can't return String for given type " + DataType.findTypeName(type));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:SchemaTupleClassGenerator.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: testPOBinCondDateTimeWithNull

@Test
public void testPOBinCondDateTimeWithNull() throws  ExecException, PlanException {
    bag= getBagWithNulls(DataType.DATETIME);
    TestPoBinCondHelper testHelper= new TestPoBinCondHelper(DataType.DATETIME, new DateTime(1L) );

    for (Tuple t : bag) {
       testHelper.getPlan().attachInput(t);

       DateTime value=null;
       if ( t.get(0)!=null){
           value = (DateTime) t.get(0);
       }
       Integer dummy = new Integer(0);
       Integer result=(Integer)testHelper.getOperator().getNextInteger().result;
       int expected;
       int actual;
       if ( value!=null ) {
           expected=value.equals(new DateTime(1L))? 1:0 ;
           actual  = result.intValue();
           assertEquals( expected, actual );
       } else {
           assertNull(result);
       }
   }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:25,代码来源:TestPOBinCond.java

示例6: 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

示例7: findTypeFromNullableWritable

public static byte findTypeFromNullableWritable(PigNullableWritable o) throws ExecException {
    if (o instanceof NullableBooleanWritable)
        return DataType.BOOLEAN;
    else if (o instanceof NullableBytesWritable)
        return DataType.BYTEARRAY;
    else if (o instanceof NullableText)
        return DataType.CHARARRAY;
    else if (o instanceof NullableFloatWritable)
        return DataType.FLOAT;
    else if (o instanceof NullableDoubleWritable)
        return DataType.DOUBLE;
    else if (o instanceof NullableIntWritable)
        return DataType.INTEGER;
    else if (o instanceof NullableLongWritable)
        return DataType.LONG;
    else if (o instanceof NullableBigIntegerWritable)
        return DataType.BIGINTEGER;
    else if (o instanceof NullableBigDecimalWritable)
        return DataType.BIGDECIMAL;
    else if (o instanceof NullableDateTimeWritable)
        return DataType.DATETIME;
    else if (o instanceof NullableBag)
        return DataType.BAG;
    else if (o instanceof NullableTuple)
        return DataType.TUPLE;
    else {
        int errCode = 2044;
        String msg = "Cannot find Pig type for " + o.getClass().getName();
        throw new ExecException(msg, errCode, PigException.BUG);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:31,代码来源:HDataType.java

示例8: parseSimpleType

private Object parseSimpleType(byte[] b, ResourceFieldSchema simpleFieldSchema) throws IOException {
    Object field;
    switch (simpleFieldSchema.getType()) {
    case DataType.INTEGER:
        field = bytesToInteger(b);
        break;
    case DataType.LONG:
        field = bytesToLong(b);
        break;
    case DataType.FLOAT:
        field = bytesToFloat(b);
        break;
    case DataType.DOUBLE:
        field = bytesToDouble(b);
        break;
    case DataType.CHARARRAY:
        field = bytesToCharArray(b);
        break;
    case DataType.BYTEARRAY:
        field = new DataByteArray(b);
        break;
    case DataType.BOOLEAN:
        field = bytesToBoolean(b);
        break;
    case DataType.BIGINTEGER:
        field = bytesToBigInteger(b);
        break;
    case DataType.BIGDECIMAL:
        field = bytesToBigDecimal(b);
    case DataType.DATETIME:
        field = bytesToDateTime(b);
        break;
    default:
        throw new IOException("Unknown simple data type");
    }
    return field;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:37,代码来源:Utf8StorageConverter.java

示例9: getNextBoolean

@Override
public Result getNextBoolean() throws ExecException {
    Result left, right;

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.BOOLEAN:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.LONG:
    case DataType.DATETIME:
    case DataType.CHARARRAY:
    case DataType.TUPLE:
    case DataType.MAP: {
        Result r = accumChild(null, operandType);
        if (r != null) {
            return r;
        }
        left = lhs.getNext(operandType);
        right = rhs.getNext(operandType);
        return doComparison(left, right);
    }
    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:34,代码来源:NotEqualToExpr.java

示例10: getBagWithNulls

private DataBag getBagWithNulls(byte type) {
    DataBag bag = DefaultBagFactory.getInstance().newDefaultBag();
    for(int i = 0; i < 10; i ++) {
        Tuple t = TupleFactory.getInstance().newTuple();
        if (r.nextInt(4)%3 == 0){
            t.append(null);
        }else{
            switch(type) {
                case DataType.BOOLEAN:
                    t.append(r.nextBoolean());
                    break;
                case DataType.INTEGER:
                    t.append(r.nextInt(2));
                    break;
                case DataType.LONG:
                    t.append(r.nextLong() % 2L);
                    break;
                case DataType.FLOAT:
                    t.append( (i % 2 == 0 ? 1.0f : 0.0f));
                    break;
                case DataType.DOUBLE:
                    t.append( (i % 2 == 0 ? 1.0 : 0.0));
                    break;
                case DataType.DATETIME:
                    t.append(new DateTime(r.nextLong() % 2L));
                    break;
            }
        }
        t.append(1);
        t.append(0);
        bag.add(t);
    }
    return bag;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:34,代码来源:TestPOBinCond.java

示例11: objToBytes

@SuppressWarnings("unchecked")
private byte[] objToBytes(Object o, byte type) throws IOException {
    LoadStoreCaster caster = (LoadStoreCaster) caster_;
    if (o == null) return null;
    switch (type) {
    case DataType.BYTEARRAY: return ((DataByteArray) o).get();
    case DataType.BAG: return caster.toBytes((DataBag) o);
    case DataType.CHARARRAY: return caster.toBytes((String) o);
    case DataType.DOUBLE: return caster.toBytes((Double) o);
    case DataType.FLOAT: return caster.toBytes((Float) o);
    case DataType.INTEGER: return caster.toBytes((Integer) o);
    case DataType.LONG: return caster.toBytes((Long) o);
    case DataType.BIGINTEGER: return caster.toBytes((BigInteger) o);
    case DataType.BIGDECIMAL: return caster.toBytes((BigDecimal) o);
    case DataType.BOOLEAN: return caster.toBytes((Boolean) o);
    case DataType.DATETIME: return caster.toBytes((DateTime) o);

    // The type conversion here is unchecked.
    // Relying on DataType.findType to do the right thing.
    case DataType.MAP: return caster.toBytes((Map<String, Object>) o);

    case DataType.NULL: return null;
    case DataType.TUPLE: return caster.toBytes((Tuple) o);
    case DataType.ERROR: throw new IOException("Unable to determine type of " + o.getClass());
    default: throw new IOException("Unable to find a converter for tuple field " + o);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:27,代码来源:HBaseStorage.java

示例12: getNextBoolean

@Override
public Result getNextBoolean() throws ExecException {

    Result res = null;
    switch(operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.CHARARRAY:
    case DataType.BOOLEAN:
    case DataType.LONG:
    case DataType.FLOAT:
    case DataType.DATETIME:
    case DataType.MAP:
    case DataType.TUPLE:
    case DataType.BAG:
        res = expr.getNext(operandType);
        if(res.returnStatus == POStatus.STATUS_OK) {
            if (res.result == null) {
                res.result = true;
            } else {
                res.result = false;
            }
            illustratorMarkup(null, res.result, (Boolean) res.result ? 0 : 1);
        }
        return res;
    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:37,代码来源:POIsNull.java

示例13: getNextBoolean

@Override
public Result getNextBoolean() throws ExecException {
    Result left, right;

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.LONG:
    case DataType.DATETIME:
    case DataType.CHARARRAY: {
        Result r = accumChild(null, operandType);
        if (r != null) {
            return r;
        }
        left = lhs.getNext(operandType);
        right = rhs.getNext(operandType);
        return doComparison(left, right);
    }
    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:LTOrEqualToExpr.java

示例14: buildTuple

public Tuple buildTuple(int rank, JsonNode hit) {
    Tuple tuple = TupleFactory.getInstance().newTuple();

    for (VespaQuerySchema.AliasTypePair tupleElement : tupleSchema) {
        String alias = tupleElement.getAlias();
        Byte type = DataType.findTypeByName(tupleElement.getType());

        // reserved word
        if ("rank".equals(alias)) {
            tuple.append(rank);
        } else {
            JsonNode field = hit;
            String[] path = alias.split("/"); // move outside
            for (String p : path) {
                field = field.get(p);
                if (field == null) {
                    type = DataType.NULL; // effectively skip field as it is not found
                    break;
                }
            }
            switch (type) {
                case DataType.BOOLEAN:
                    tuple.append(field.asBoolean());
                    break;
                case DataType.INTEGER:
                    tuple.append(field.asInt());
                    break;
                case DataType.LONG:
                    tuple.append(field.asLong());
                    break;
                case DataType.FLOAT:
                case DataType.DOUBLE:
                    tuple.append(field.asDouble());
                    break;
                case DataType.DATETIME:
                    tuple.append(field.asText());
                    break;
                case DataType.CHARARRAY:
                    tuple.append(field.asText());
                    break;
                default:
                    // the rest of the data types are currently not supported
            }
        }
    }
    return tuple;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:47,代码来源:VespaQuerySchema.java

示例15: getPigType

/**
 * Defines a mapping of HCatalog type to Pig type; not every mapping is exact, 
 * see {@link #extractPigObject(Object,
 * com.cloudera.recordservice.core.Schema.TypeDesc)}
 * See http://pig.apache.org/docs/r0.12.0/basic.html#data-types
 * See {@link org.apache.hive.hcatalog.pig.HCatBaseStorer#validateSchema(
 * Schema.FieldSchema, HCatFieldSchema, Schema, HCatSchema, int)}
 * for Pig->Hive type mapping.
 */ 
static public byte getPigType(Type type) throws IOException {
  if (type == Type.STRING || type == Type.CHAR || type == Type.VARCHAR) {
    //CHARARRAY is unbounded so Hive->Pig is lossless
    return DataType.CHARARRAY;
  }

  if ((type == Type.INT) || (type == Type.SMALLINT) || (type == Type.TINYINT)) {
    return DataType.INTEGER;
  }

  if (type == Type.ARRAY) {
    return DataType.BAG;
  }

  if (type == Type.STRUCT) {
    return DataType.TUPLE;
  }

  if (type == Type.MAP) {
    return DataType.MAP;
  }

  if (type == Type.BIGINT) {
    return DataType.LONG;
  }

  if (type == Type.FLOAT) {
    return DataType.FLOAT;
  }

  if (type == Type.DOUBLE) {
    return DataType.DOUBLE;
  }

  if (type == Type.BINARY) {
    return DataType.BYTEARRAY;
  }

  if (type == Type.BOOLEAN && pigHasBooleanSupport) {
    return DataType.BOOLEAN;
  }
  if(type == Type.DECIMAL) {
    //Hive is more restrictive, so Hive->Pig works
    return DataType.BIGDECIMAL;
  }
  if(type == Type.DATE || type == Type.TIMESTAMP) {
    //Hive Date is representable as Pig DATETIME
    return DataType.DATETIME;
  }

  throw new PigException("HCatalog column type '" + type.toString()
      + "' is not supported in Pig as a column type", PIG_EXCEPTION_CODE);
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:62,代码来源:PigHCatUtil.java


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