本文整理汇总了Java中org.apache.pig.data.DataType.BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.BOOLEAN属性的具体用法?Java DataType.BOOLEAN怎么用?Java DataType.BOOLEAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.pig.data.DataType
的用法示例。
在下文中一共展示了DataType.BOOLEAN属性的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));
}
示例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));
}
示例3: getPredicateFields
@Override
public List<String> getPredicateFields(String s, Job job) throws IOException {
if(!job.getConfiguration().getBoolean(ENABLE_PREDICATE_FILTER_PUSHDOWN, DEFAULT_PREDICATE_PUSHDOWN_ENABLED)) {
return null;
}
List<String> fields = new ArrayList<String>();
for(FieldSchema field : schema.getFields()) {
switch(field.type) {
case DataType.BOOLEAN:
case DataType.INTEGER:
case DataType.LONG:
case DataType.FLOAT:
case DataType.DOUBLE:
case DataType.CHARARRAY:
fields.add(field.alias);
break;
default:
// Skip BYTEARRAY, TUPLE, MAP, BAG, DATETIME, BIGINTEGER, BIGDECIMAL
break;
}
}
return fields;
}
示例4: 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;
}
示例5: 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));
}
}
示例6: 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);
}
}
示例7: 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;
}
}
示例8: 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);
}
}
示例9: convertToElephantBirdCompatibleSchema
private void convertToElephantBirdCompatibleSchema(Schema schema) {
if (schema == null) {
return;
}
for(FieldSchema fieldSchema:schema.getFields()){
if (fieldSchema.type== DataType.BOOLEAN) {
fieldSchema.type=DataType.INTEGER;
}
convertToElephantBirdCompatibleSchema(fieldSchema.schema);
}
}
示例10: 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);
}
}
}
示例11: getNext
/**
* Implementations that call into the different versions of getNext are often
* identical, differing only in the signature of the getNext() call they make.
* This method allows to cut down on some of the copy-and-paste.
* @param dataType Describes the type of obj; a byte from DataType.
*
* @return result Result of applying this Operator to the Object.
* @throws ExecException
*/
public Result getNext(byte dataType) throws ExecException {
try {
switch (dataType) {
case DataType.BAG:
return getNextDataBag();
case DataType.BOOLEAN:
return getNextBoolean();
case DataType.BYTEARRAY:
return getNextDataByteArray();
case DataType.CHARARRAY:
return getNextString();
case DataType.DOUBLE:
return getNextDouble();
case DataType.FLOAT:
return getNextFloat();
case DataType.INTEGER:
return getNextInteger();
case DataType.LONG:
return getNextLong();
case DataType.BIGINTEGER:
return getNextBigInteger();
case DataType.BIGDECIMAL:
return getNextBigDecimal();
case DataType.DATETIME:
return getNextDateTime();
case DataType.MAP:
return getNextMap();
case DataType.TUPLE:
return getNextTuple();
default:
throw new ExecException("Unsupported type for getNext: " + DataType.findTypeName(dataType));
}
} catch (RuntimeException e) {
throw new ExecException("Exception while executing " + this.toString() + ": " + e.toString(), e);
}
}
示例12: getFieldSchema
@Override
public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException {
if (fieldSchema!=null)
return fieldSchema;
fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN);
uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
return fieldSchema;
}
示例13: 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);
}
}
示例14: testDeserialize__boolean
@Test
public void testDeserialize__boolean() throws IOException {
byte[] input = "true|_".getBytes();
FieldSchema schema = new FieldSchema("", DataType.BOOLEAN);
PigStreamingUDF sp = new PigStreamingUDF(schema);
Object out = sp.deserialize(input, 0, input.length);
Assert.assertEquals(tf.newTuple(Boolean.TRUE), out);
}
示例15: getNextBoolean
@Override
public Result getNextBoolean() throws ExecException {
try {
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);
}
}
} catch (RuntimeException e) {
throw new ExecException("exception while executing " + this.toString() + ": " + e.toString(), 2067, PigException.BUG, e);
}
}