本文整理匯總了Java中org.apache.hadoop.io.ArrayWritable.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayWritable.get方法的具體用法?Java ArrayWritable.get怎麽用?Java ArrayWritable.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.io.ArrayWritable
的用法示例。
在下文中一共展示了ArrayWritable.get方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStructFieldData
import org.apache.hadoop.io.ArrayWritable; //導入方法依賴的package包/類
@Override
public Object getStructFieldData(final Object data, final StructField fieldRef) {
if (data == null) {
return null;
}
if (data instanceof ArrayWritable) {
final ArrayWritable arr = (ArrayWritable) data;
return arr.get()[((StructFieldImpl) fieldRef).getIndex()];
}
//since setStructFieldData and create return a list, getStructFieldData should be able to
//handle list data. This is required when table serde is ParquetHiveSerDe and partition serde
//is something else.
if (data instanceof List) {
return ((List) data).get(((StructFieldImpl) fieldRef).getIndex());
}
throw new UnsupportedOperationException("Cannot inspect " + data.getClass().getCanonicalName());
}
示例2: writeArray
import org.apache.hadoop.io.ArrayWritable; //導入方法依賴的package包/類
public void writeArray(ArrayWritable aw) throws IOException {
Writable[] writables = aw.get();
out.writeVectorHeader(writables.length);
for (Writable writable : writables) {
write(writable);
}
}
示例3: getStructFieldsDataAsList
import org.apache.hadoop.io.ArrayWritable; //導入方法依賴的package包/類
@Override
public List<Object> getStructFieldsDataAsList(final Object data) {
if (data == null) {
return null;
}
if (data instanceof ArrayWritable) {
final ArrayWritable arr = (ArrayWritable) data;
final Object[] arrWritable = arr.get();
return new ArrayList<Object>(Arrays.asList(arrWritable));
}
throw new UnsupportedOperationException("Cannot inspect " + data.getClass().getCanonicalName());
}
示例4: write
import org.apache.hadoop.io.ArrayWritable; //導入方法依賴的package包/類
@Override
public void write(Writable w) throws IOException {
ArrayWritable datas = (ArrayWritable) w;
for (int colId = 0; colId < sqlTypes.length; colId++) {
SQLType type = sqlTypes[colId];
Writable currentValue = datas.get()[colId];
switch (type) {
case INT:
if (currentValue == null) {
rowBuilder.appendInt(0);
} else {
rowBuilder.appendInt(((IntWritable) currentValue).get());
}
break;
case BIGINT:
if (currentValue == null) {
rowBuilder.appendLong(0L);
} else {
rowBuilder.appendLong(((LongWritable) currentValue).get());
}
break;
case FLOAT:
if (currentValue == null) {
rowBuilder.appendFloat(0f);
} else {
rowBuilder.appendFloat(((FloatWritable) currentValue).get());
}
break;
case DOUBLE:
if (currentValue == null) {
rowBuilder.appendDouble(0d);
} else {
rowBuilder.appendDouble(((DoubleWritable) currentValue).get());
}
break;
case VARCHAR:
if (currentValue == null) {
rowBuilder.appendString("");
} else {
Text v = (Text) currentValue;
rowBuilder.appendUTF8String(v.getBytes(), 0, v.getLength());
}
break;
case DATE:
if (currentValue == null) {
rowBuilder.appendLong(0);
} else {
rowBuilder.appendLong(DateTimeUtil.getEpochMillisecond(((DateWritable) currentValue).get()));
}
break;
case DATETIME:
if (currentValue == null) {
rowBuilder.appendLong(0);
} else {
rowBuilder.appendLong(DateTimeUtil.getEpochMillisecond(((TimestampWritable) currentValue).getTimestamp()));
}
break;
default:
throw new IOException("can't recognize this type [" + type + "]");
}
}
segmentGen.add(rowBuilder.buildAndReset());
}