當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayWritable.get方法代碼示例

本文整理匯總了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());
}
 
開發者ID:shunfei,項目名稱:indexr,代碼行數:21,代碼來源:ArrayWritableObjectInspector.java

示例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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:TypedBytesWritableOutput.java

示例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());
}
 
開發者ID:shunfei,項目名稱:indexr,代碼行數:15,代碼來源:ArrayWritableObjectInspector.java

示例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());
}
 
開發者ID:shunfei,項目名稱:indexr,代碼行數:64,代碼來源:IndexRRecordWriter.java


注:本文中的org.apache.hadoop.io.ArrayWritable.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。