Example usage for org.apache.hadoop.io ArrayWritable readFields

List of usage examples for org.apache.hadoop.io ArrayWritable readFields

Introduction

In this page you can find the example usage for org.apache.hadoop.io ArrayWritable readFields.

Prototype

@Override
    public void readFields(DataInput in) throws IOException 

Source Link

Usage

From source file:com.mozilla.hadoop.hbase.mapreduce.MultiScanTableMapReduceUtil.java

License:Apache License

/**
 * Converts base64 scans string back into a Scan array
 * @param base64//  ww  w . j a v a2 s . c om
 * @return
 * @throws IOException
 */
public static Scan[] convertStringToScanArray(final String base64) throws IOException {
    final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(Base64.decode(base64)));

    ArrayWritable aw = new ArrayWritable(Scan.class);
    aw.readFields(dis);

    Writable[] writables = aw.get();
    Scan[] scans = new Scan[writables.length];
    for (int i = 0; i < writables.length; i++) {
        scans[i] = (Scan) writables[i];
    }

    return scans;
}

From source file:edu.ub.ahstfg.io.index.ArrayIndex.java

License:Open Source License

@Override
public void readFields(DataInput input) throws IOException {
    ArrayWritable wTerms = new ArrayWritable(Text.class);
    wTerms.readFields(input);
    terms = WritableConverter.arrayWritable2LinkedListString(wTerms);

    MapWritable wTermFreq = new MapWritable();
    wTermFreq.readFields(input);//from  ww w  .  j a  v a2  s  .co m
    termFreq = WritableConverter.mapWritable2HashMapStringLinkedListShort(wTermFreq);

    ArrayWritable wKeywords = new ArrayWritable(Text.class);
    wKeywords.readFields(input);
    keywords = WritableConverter.arrayWritable2LinkedListString(wKeywords);

    MapWritable wKeywordFreq = new MapWritable();
    wKeywordFreq.readFields(input);
    keywordFreq = WritableConverter.mapWritable2HashMapStringLinkedListShort(wKeywordFreq);
}

From source file:edu.ub.ahstfg.io.index.DocumentDescriptor.java

License:Open Source License

@Override
public void readFields(DataInput input) throws IOException {
    Text t = new Text();
    t.readFields(input);//from   www.ja v a 2 s .co m
    url = t.toString();
    ArrayWritable buffer = new ArrayWritable(IntWritable.class);
    buffer.readFields(input);
    termFreq = WritableConverter.arrayWritable2ShortArray(buffer);
    buffer = new ArrayWritable(IntWritable.class);
    buffer.readFields(input);
    keyFreq = WritableConverter.arrayWritable2ShortArray(buffer);
}

From source file:edu.ub.ahstfg.io.index.FeatureDescriptor.java

License:Open Source License

@Override
public void readFields(DataInput input) throws IOException {
    ArrayWritable buffer = new ArrayWritable(Text.class);
    buffer.readFields(input);
    terms = WritableConverter.arrayWritable2StringArray(buffer);
    buffer = new ArrayWritable(Text.class);
    buffer.readFields(input);/*from  www  . java  2s  .c  o  m*/
    keywords = WritableConverter.arrayWritable2StringArray(buffer);
}

From source file:edu.ub.ahstfg.kmeans.document.DocumentCentroid.java

License:Open Source License

@Override
public void readFields(DataInput in) throws IOException {
    ArrayWritable k = new ArrayWritable(IntWritable.class);
    k.readFields(in);
    keywordVector = WritableConverter.arrayWritable2ShortArray(k);
    ArrayWritable t = new ArrayWritable(IntWritable.class);
    t.readFields(in);/*ww w .j  a v a  2  s  .  c om*/
    termVector = WritableConverter.arrayWritable2ShortArray(t);
    DoubleWritable dist = new DoubleWritable();
    dist.readFields(in);
    distance = dist.get();
}