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


Java DataType.CHARARRAY属性代码示例

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


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

示例1: testOutputSchema

@Test
public void testOutputSchema() throws Exception {
 // given
    Schema schema = new Schema();
    schema.add(new FieldSchema(null, DataType.CHARARRAY));
    schema.add(new FieldSchema(null, DataType.CHARARRAY));
    FieldSchema idFieldSchema = new FieldSchema("id", DataType.CHARARRAY);
    schema.add(idFieldSchema);
    FieldSchema dedupFieldSchema = new FieldSchema("dedup", DataType.BOOLEAN);
    schema.add(dedupFieldSchema);
    
    // execute
    Schema resultSchema = idReplacer.outputSchema(schema);
    
    // assert
    assertNotNull(resultSchema);
    assertEquals(1, resultSchema.getFields().size());
    assertEquals(idFieldSchema, resultSchema.getField(0).schema.getField(0));
    assertEquals(dedupFieldSchema, resultSchema.getField(0).schema.getField(1));
}
 
开发者ID:openaire,项目名称:iis,代码行数:20,代码来源:IdReplacerUDFTest.java

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

示例3: testResourceSchemaWithInvalidPigSchema

/**
 * Test one-level Pig Schema: multiple fields for a bag
 */
@Test
public void testResourceSchemaWithInvalidPigSchema() 
throws FrontendException {
    String [] aliases ={"f1", "f2"};
    byte[] types = {DataType.CHARARRAY, DataType.INTEGER};
    Schema level0 = TypeCheckingTestUtil.genFlatSchema(
            aliases,types);
    Schema.FieldSchema fld0 = 
        new Schema.FieldSchema("f0", level0, DataType.BAG);
    Schema level1 = new Schema(fld0);
    try {
        Schema.getPigSchema(new ResourceSchema(level1));
        Assert.fail();
    } catch(FrontendException e) {
        assertTrue(e.getErrorCode()==2218);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:20,代码来源:TestResourceSchema.java

示例4: outputSchema

public Schema outputSchema(Schema input) {
	// Check that we were passed one field
	if ( input.size() != 1 )
		throw new RuntimeException("Excpeted input (String), input need only one field");
	try{
		// Get the types for column and check it.
		// If they are wring, figure out what types were passed and give a good error message.
		if (input.getField(0).type != DataType.CHARARRAY){
			String msg = "Excepted input (String), received schema (";
			msg += DataType.findTypeName(input.getField(0).type);
			msg += ")";
			throw new RuntimeException(msg);
		}
	} catch ( Exception e) {
		throw new RuntimeException(e);
	}
	// Assemble output schema
	Schema output = new Schema();
	FieldSchema paramMap = new FieldSchema("urlparams", DataType.MAP);
	output.add(paramMap);
	return output;
}
 
开发者ID:caesar0301,项目名称:piggybox,代码行数:22,代码来源:ExtractUrlParams.java

示例5: convertToType

/**
 *
 * @param caster LoadCaster to be used to convert the bytes into a field.
 * @param bytes
 * @param fieldSchema schema of Bag or Tuple; pass in null if a simple type.
 * @param dataType type from DataType
 * @return converted object.
 * @throws IOException
 */
public static Object convertToType(LoadCaster caster, byte[] bytes,
        ResourceFieldSchema fieldSchema, byte dataType) throws IOException {
    switch (dataType) {
    case (DataType.BAG): return caster.bytesToBag(bytes, fieldSchema);
    case (DataType.BYTEARRAY): return new DataByteArray(bytes);
    case (DataType.CHARARRAY): return caster.bytesToCharArray(bytes);
    case (DataType.DOUBLE): return caster.bytesToDouble(bytes);
    case (DataType.FLOAT): return caster.bytesToFloat(bytes);
    case (DataType.INTEGER): return caster.bytesToInteger(bytes);
    case (DataType.BIGINTEGER): return caster.bytesToBigInteger(bytes);
    case (DataType.BIGDECIMAL): return caster.bytesToBigDecimal(bytes);
    case (DataType.LONG): return caster.bytesToLong(bytes);
    case (DataType.BOOLEAN): return caster.bytesToBoolean(bytes);
    case (DataType.DATETIME): return caster.bytesToDateTime(bytes);
    case (DataType.MAP): return caster.bytesToMap(bytes, fieldSchema);
    case (DataType.TUPLE): return caster.bytesToTuple(bytes, fieldSchema);
    default: throw new IOException("Unknown type " + dataType);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:28,代码来源:CastUtils.java

示例6: testResourceFlatSchemaCreation2

/**
 * Test that ResourceSchema is correctly created given a
 * pig.Schema and vice versa 
 */
@Test
public void testResourceFlatSchemaCreation2() 
throws ExecException, SchemaMergeException, FrontendException {
    String [] aliases ={"f1", "f2"};
    byte[] types = {DataType.CHARARRAY, DataType.INTEGER};
    
    Schema origSchema = new Schema(
            new Schema.FieldSchema("t1", 
                    new Schema(
                            new Schema.FieldSchema("t0", 
                                    TypeCheckingTestUtil.genFlatSchema(
                                            aliases,types), 
                                            DataType.TUPLE)), DataType.BAG));
                    
    ResourceSchema rsSchema = new ResourceSchema(origSchema);

    Schema genSchema = Schema.getPigSchema(rsSchema);
    assertTrue("generated schema equals original", 
            Schema.equals(genSchema, origSchema, true, false));
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:24,代码来源:TestResourceSchema.java

示例7: getPredicateFields

@Override
public List<String> getPredicateFields(String location, Job job) throws IOException {
    ResourceSchema schema = getSchema(location, job);
    List<String> predicateFields = new ArrayList<String>();
    for (ResourceFieldSchema field : schema.getFields()) {
        switch(field.getType()) {
        case DataType.BOOLEAN:
        case DataType.INTEGER:
        case DataType.LONG:
        case DataType.FLOAT:
        case DataType.DOUBLE:
        case DataType.DATETIME:
        case DataType.CHARARRAY:
        case DataType.BIGINTEGER:
        case DataType.BIGDECIMAL:
            predicateFields.add(field.getName());
            break;
        default:
            // Skip DataType.BYTEARRAY, DataType.TUPLE, DataType.MAP and DataType.BAG
            break;
        }
    }
    return predicateFields;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:24,代码来源:OrcStorage.java

示例8: getArgToFuncMapping

@Override
public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
    List<FuncSpec> funcList = new ArrayList<FuncSpec>();
    Schema s = new Schema(new Schema.FieldSchema(null, DataType.CHARARRAY)); 
    
    Schema s1 = new Schema();
    s1.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
    s1.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
    
    Schema s2 = new Schema();
    s2.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
    s2.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
    s2.add(new Schema.FieldSchema(null, DataType.INTEGER));
    
    funcList.add(new FuncSpec(this.getClass().getName(), s));
    funcList.add(new FuncSpec(this.getClass().getName(), s1));
    funcList.add(new FuncSpec(this.getClass().getName(), s2));
    return funcList;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:19,代码来源:STRSPLIT.java

示例9: outputSchema

@Override
public Schema outputSchema(Schema input) {
    Schema.FieldSchema charFs = new FieldSchema(null, DataType.CHARARRAY);
    Schema.FieldSchema intFs = new FieldSchema(null, DataType.INTEGER);
    Schema.FieldSchema floatFs = new FieldSchema(null, DataType.FLOAT);
    Schema bagSchema = new Schema();
    bagSchema.add(charFs);
    bagSchema.add(intFs);
    bagSchema.add(floatFs);
    Schema.FieldSchema bagFs;
    try {
        bagFs = new Schema.FieldSchema(null, bagSchema, DataType.BAG);
    } catch (FrontendException fee) {
        return null;
    }
    return new Schema(bagFs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:17,代码来源:TestTypeCheckingValidatorNewLP.java

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

示例11: outputSchema

@Override
public Schema outputSchema(Schema input) {
    try {
        return new Schema(new Schema.FieldSchema(getSchemaName(this
                .getClass().getName().toLowerCase(), input),
                DataType.CHARARRAY));
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:10,代码来源:Decode.java

示例12: TOBAG

public TOBAG(String bagColName, String tupleColName, String fieldType) {

        if ( bagColName== null || tupleColName == null  || fieldType == null)  {
	    throw new RuntimeException("The bagColName  and fieldType cannot be null");
        }

    	this.bagColName   = bagColName;	
    	this.tupleColName = tupleColName;	

        if ( fieldType.equalsIgnoreCase( "CHARARRAY" )){ 
             this.fieldType = DataType.CHARARRAY;

        } else if ( fieldType.equalsIgnoreCase( "DOUBLE" )){ 
            this.fieldType = DataType.DOUBLE;

        } else if ( fieldType.equalsIgnoreCase( "FLOAT" )){ 
            this.fieldType = DataType.FLOAT; 

        } else if ( fieldType.equalsIgnoreCase( "BOOLEAN" )){ 
            this.fieldType = DataType.BOOLEAN; 

        } else if ( fieldType.equalsIgnoreCase( "INTEGER" )){ 
            this.fieldType = DataType.INTEGER;

        } else if ( fieldType.equalsIgnoreCase( "LONG" )){ 
            this.fieldType = DataType.LONG; 

        } else if ( fieldType.equalsIgnoreCase( "MAP" )){ 
            this.fieldType = DataType.MAP; 
        } else {
	    throw new RuntimeException("This type"+ fieldType +"is not supported in TOBAG");
        }

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

示例13: testWIthWAL

/**
 * Assert that without -noWAL, the WAL is enabled the WAL
 * @throws IOException
 * @throws ParseException
 */
@Test
public void testWIthWAL() throws IOException, ParseException {
    HBaseStorage hbaseStorage = new HBaseStorage(TESTCOLUMN_A);

    Object key = "somekey";
    byte type = DataType.CHARARRAY;
    Assert.assertTrue(hbaseStorage.createPut(key, type).getWriteToWAL());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:TestHBaseStorage.java

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

示例15: 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.LONG:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    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,代码行数:32,代码来源:GTOrEqualToExpr.java


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