本文整理汇总了Java中org.apache.pig.data.DataType.TUPLE属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.TUPLE属性的具体用法?Java DataType.TUPLE怎么用?Java DataType.TUPLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.pig.data.DataType
的用法示例。
在下文中一共展示了DataType.TUPLE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outputSchema
/**
* The output is a Sketch Result Tuple Schema.
*/
@Override
public Schema outputSchema(final Schema input) {
if (input != null) {
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Estimate", DataType.DOUBLE));
tupleSchema.add(new Schema.FieldSchema("UpperBound", DataType.DOUBLE));
tupleSchema.add(new Schema.FieldSchema("LowerBound", DataType.DOUBLE));
return new Schema(new Schema.FieldSchema(getSchemaName(this
.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
}
catch (final FrontendException e) {
// fall through
}
}
return null;
}
示例2: outputSchema
/**
* The output consists of two longs, or 128 bits, plus the result of the modulo division if
* specified.
*/
@Override
public Schema outputSchema(final Schema input) {
if (input != null) {
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Hash0", DataType.LONG));
tupleSchema.add(new Schema.FieldSchema("Hash1", DataType.LONG));
tupleSchema.add(new Schema.FieldSchema("ModuloResult", DataType.INTEGER));
return new Schema(new Schema.FieldSchema(getSchemaName(this
.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
}
catch (final FrontendException e) {
//fall through
}
}
return null;
}
示例3: testOutputSchemaForBagToTupleStringUDF
@Test
public void testOutputSchemaForBagToTupleStringUDF() throws Exception {
FieldSchema tupSch = new FieldSchema(null, DataType.TUPLE);
tupSch.schema = new Schema();
tupSch.schema.add(new FieldSchema(null, DataType.INTEGER));
tupSch.schema.add(new FieldSchema(null, DataType.CHARARRAY));
FieldSchema bagSch = new FieldSchema(null, DataType.BAG);
bagSch.schema = new Schema(tupSch);
Schema inputSch = new Schema();
inputSch.add(bagSch);
inputSch.add(new FieldSchema(null, DataType.CHARARRAY));
BagToString udf = new BagToString();
Schema outputSchema = udf.outputSchema(inputSch);
assertEquals("schema of BagToTuple input", outputSchema.getField(0).type,
DataType.CHARARRAY);
}
示例4: consumeComplexType
private Object consumeComplexType(PushbackInputStream in, ResourceFieldSchema complexFieldSchema) throws IOException {
Object field;
switch (complexFieldSchema.getType()) {
case DataType.BAG:
field = consumeBag(in, complexFieldSchema);
break;
case DataType.TUPLE:
field = consumeTuple(in, complexFieldSchema);
break;
case DataType.MAP:
field = consumeMap(in, complexFieldSchema);
break;
default:
throw new IOException("Unknown complex data type");
}
return field;
}
示例5: outputSchema
public Schema outputSchema(Schema input) {
try {
ArrayList<Schema.FieldSchema> tupleFields = new ArrayList<Schema.FieldSchema>(3);
tupleFields.add(new Schema.FieldSchema("item_A", DataType.CHARARRAY));
tupleFields.add(new Schema.FieldSchema("item_B", DataType.CHARARRAY));
tupleFields.add(new Schema.FieldSchema("weight", DataType.FLOAT));
return new Schema(
new Schema.FieldSchema("ii_terms",
new Schema(
new Schema.FieldSchema(null,
new Schema(tupleFields),
DataType.TUPLE)),
DataType.BAG)
);
} catch (FrontendException e) {
throw new RuntimeException(e);
}
}
示例6: outputSchema
@Override
public Schema outputSchema(Schema input) {
try {
// subschema describing the fields in the tuples of the bag
List<Schema.FieldSchema> tokenFs = new ArrayList<Schema.FieldSchema>();
//tokenFs.add(new Schema.FieldSchema(null, this.fieldType ));
tokenFs.add(new Schema.FieldSchema( this.tupleColName.toUpperCase(), this.fieldType ));
Schema tupleSchema = new Schema( tokenFs );
Schema.FieldSchema tupleFs = new Schema.FieldSchema( this.bagColName.toUpperCase(), tupleSchema, DataType.TUPLE);
Schema bagSchema = new Schema(tupleFs);
bagSchema.setTwoLevelAccessRequired(true);
Schema.FieldSchema bagFs = new Schema.FieldSchema( null, bagSchema, DataType.BAG);
return new Schema(bagFs);
} catch (FrontendException e) {
throw new RuntimeException("Unable to create schema for BAG.");
}
}
示例7: outputSchema
@Override
public Schema outputSchema(Schema input) {
initialize();
try {
Schema tupleSchema = new Schema();
for (String fieldName: requestedFields) {
tupleSchema.add(new Schema.FieldSchema(fieldName, DataType.CHARARRAY));
}
return new Schema(new Schema.FieldSchema("UserAgent", tupleSchema, DataType.TUPLE));
} catch (Exception e) {
return null;
}
}
示例8: toCanonicalType
private Type toCanonicalType(final LogicalSchema.LogicalFieldSchema field) {
if (PigTypeMapping.getPIG_TO_CANONICAL().containsKey(field.type)) {
return PigTypeMapping.getPIG_TO_CANONICAL().get(field.type);
}
switch (field.type) {
case DataType.MAP:
return toCanonicalMapType(field);
case DataType.BAG:
return toCanonicalArrayType(field);
case DataType.TUPLE:
return toCanonicalRowType(field);
default:
}
throw new IllegalArgumentException(String.format("Invalid for Pig converter: '%s'", field.toString()));
}
示例9: toCanonicalArrayType
private Type toCanonicalArrayType(final LogicalSchema.LogicalFieldSchema field) {
final LogicalSchema.LogicalFieldSchema subField = field.schema.getField(0);
final Type elementType;
if (subField.type == DataType.TUPLE
&& !TypeUtils.isNullOrEmpty(subField.schema.getFields())
&& NAME_ARRAY_ELEMENT.equals(subField.schema.getFields().get(0).alias)) {
elementType = toCanonicalType(subField.schema.getFields().get(0));
} else {
elementType = toCanonicalType(subField);
}
return new ArrayType(elementType);
}
示例10: outputSchema
@Override
public Schema outputSchema(Schema input) {
try {
return new Schema(new Schema.FieldSchema(getSchemaName(getClass().getName().toLowerCase().replace('.', '_'), input),
getRecordSchema(input), DataType.TUPLE));
} catch (FrontendException ex) {
return null;
}
}
示例11: outputSchema
/**
* The output is a Sketch Result Tuple Schema.
*/
@Override
public Schema outputSchema(final Schema input) {
if (input == null) { return null; }
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Estimate", DataType.DOUBLE));
tupleSchema.add(new Schema.FieldSchema("LowerBound", DataType.DOUBLE));
tupleSchema.add(new Schema.FieldSchema("UpperBound", DataType.DOUBLE));
return new Schema(new Schema.FieldSchema(getSchemaName(this
.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
示例12: outputSchema
@Override
public Schema outputSchema(final Schema inputSchema) {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("item", DataType.CHARARRAY));
tupleSchema.add(new Schema.FieldSchema("estimate", DataType.LONG));
tupleSchema.add(new Schema.FieldSchema("lower_bound", DataType.LONG));
tupleSchema.add(new Schema.FieldSchema("upper_bound", DataType.LONG));
try {
final Schema bagSchema = new Schema(new Schema.FieldSchema("item_tuple", tupleSchema, DataType.TUPLE));
return new Schema(new Schema.FieldSchema("bag_of_item_tuples", bagSchema, DataType.BAG));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
示例13: outputSchema
@Override
public Schema outputSchema(final Schema input) {
if (input == null) { return null; }
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(
this.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
示例14: outputSchema
@Override
public Schema outputSchema(final Schema input) {
if (input == null) {
return null;
}
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(
this.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
示例15: outputSchema
@Override
public Schema outputSchema(final Schema input) {
if (input != null) {
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(this
.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
}
catch (final FrontendException e) {
// fall through
}
}
return null;
}