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


Java DataType.BIGCHARARRAY属性代码示例

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


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

示例1: convertPrimitiveType

/**
 * Convert Pig primitive type to Avro type
 * 
 */
protected static Schema convertPrimitiveType(byte pigType) throws IOException {

    if (pigType == DataType.BOOLEAN) {
        return AvroStorageUtils.BooleanSchema;
    } else if (pigType == DataType.BYTEARRAY) {
        return AvroStorageUtils.BytesSchema;
    } else if (pigType == DataType.CHARARRAY
                                    || pigType == DataType.BIGCHARARRAY) {
        return AvroStorageUtils.StringSchema;
    } else if (pigType == DataType.DOUBLE) {
        return AvroStorageUtils.DoubleSchema;
    } else if (pigType == DataType.FLOAT) {
        return AvroStorageUtils.FloatSchema;
    } else if (pigType == DataType.INTEGER) {
        return AvroStorageUtils.IntSchema;
    } else if (pigType == DataType.LONG) {
        return AvroStorageUtils.LongSchema;
    } else
        throw new IOException("unsupported pig type:"
                                        + DataType.findTypeName(pigType));

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:26,代码来源:PigSchema2Avro.java

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

示例3: convert

@Override
public void convert(Object from, BytesArray to) {

    // expect PigTuple holding a Tuple with only one field - chararray or bytearray
    Assert.isTrue(from instanceof PigTuple,
            String.format("Unexpected object type, expecting [%s], given [%s]", PigTuple.class, from.getClass()));

    PigTuple pt = (PigTuple) from;
    ResourceFieldSchema schema = pt.getSchema();

    // unwrap the tuple
    ResourceSchema tupleSchema = schema.getSchema();

    // empty tuple shortcut
    if (tupleSchema == null) {
        // write empty doc
        to.bytes("{}");
        return;
    }

    ResourceFieldSchema[] fields = tupleSchema.getFields();
    Assert.isTrue(fields.length == 1, "When using JSON input, only one field is expected");

    Object object;
    byte type;

    try {
        object = pt.getTuple().get(0);
        type = pt.getTuple().getType(0);
    } catch (Exception ex) {
        throw new EsHadoopIllegalStateException("Encountered exception while processing tuple", ex);
    }


    if (type == DataType.BIGCHARARRAY || type == DataType.CHARARRAY) {
        to.bytes(object.toString());
        return;
    }
    if (type == DataType.BYTEARRAY) {
        DataByteArray dba = (DataByteArray) object;
        to.bytes(dba.get(), dba.size());
        return;
    }

    throw new EsHadoopIllegalArgumentException(String.format("Cannot handle Pig type [%s]; expecting [%s,%s]", object.getClass(), String.class, DataByteArray.class));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:46,代码来源:PigBytesConverter.java

示例4: isCompatible

/**
 * Check whether Avro type is compatible with Pig type
 * 
 */
protected static boolean isCompatible(Schema avroSchema, ResourceFieldSchema pigSchema) {

    Schema.Type avroType = avroSchema.getType();
    byte pigType = pigSchema.getType();

    if (avroType.equals(Schema.Type.UNION)) {
        return true;
    } else if (pigType == DataType.TUPLE) {
        /* Tuple is compatible with any type; for users may want to
           get rid of the tuple wrapper */
        return true;
    }
    return  (avroType.equals(Schema.Type.ARRAY) && pigType == DataType.BAG)
                  || (avroType.equals(Schema.Type.MAP) && pigType == DataType.MAP)
                  || (avroType.equals(Schema.Type.STRING) 
                                                  && pigType == DataType.CHARARRAY 
                                                  || pigType == DataType.BIGCHARARRAY)
                  || (avroType.equals(Schema.Type.ENUM) 
                                                  && pigType == DataType.CHARARRAY)
                  || (avroType.equals(Schema.Type.BOOLEAN) 
                                                  && pigType == DataType.BOOLEAN 
                                                  || pigType == DataType.INTEGER)
                  || (avroType.equals(Schema.Type.BYTES) 
                                                  && pigType == DataType.BYTEARRAY)
                  || (avroType.equals(Schema.Type.DOUBLE) 
                                                  && pigType == DataType.DOUBLE
                                                  || pigType == DataType.FLOAT
                                                  || pigType == DataType.INTEGER 
                                                  || pigType == DataType.LONG)
                  || (avroType.equals(Schema.Type.FLOAT)
                                                  && pigType == DataType.FLOAT
                                                  || pigType == DataType.INTEGER 
                                                  || pigType == DataType.LONG)
                  || (avroType.equals(Schema.Type.FIXED) 
                                                  && pigType == DataType.BYTEARRAY)
                  || (avroType.equals(Schema.Type.INT) 
                                                  && pigType == DataType.INTEGER)
                  || (avroType.equals(Schema.Type.LONG)
                                                  && pigType == DataType.LONG 
                                                  || pigType == DataType.INTEGER);

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:46,代码来源:PigSchema2Avro.java

示例5: 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.BIGCHARARRAY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。