Java Code Examples for org.apache.hadoop.io.IntWritable#write()

The following examples show how to use org.apache.hadoop.io.IntWritable#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomWritableWithCircle.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput paramDataOutput)
    throws IOException
  {
    IntWritable localIntWritable = new IntWritable();

    localIntWritable.set(this.int1);
    localIntWritable.write(paramDataOutput);

    Text localText = new Text();
    localText.set(this.circle);
    localText.write(paramDataOutput);
  }
 
Example 2
Source File: CustomWritableWithChar.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput paramDataOutput)
    throws IOException
  {
    IntWritable localIntWritable = new IntWritable();

    localIntWritable.set(this.int1);
    localIntWritable.write(paramDataOutput);

    localIntWritable.set(this.char1);
    localIntWritable.write(paramDataOutput);
  }
 
Example 3
Source File: CustomerFlowElement.java    From WIFIProbe with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput dataOutput) throws IOException {
    Text text = new Text(wifiProb==null?"":wifiProb);
    text.write(dataOutput);

    IntWritable intWritable = new IntWritable();

    intWritable.set(inNoOutWifi);
    intWritable.write(dataOutput);
    intWritable.set(inNoOutStore);
    intWritable.write(dataOutput);

    intWritable.set(outNoInWifi);
    intWritable.write(dataOutput);
    intWritable.set(outNoInStore);
    intWritable.write(dataOutput);

    intWritable.set(inAndOutWifi);
    intWritable.write(dataOutput);
    intWritable.set(inAndOutStore);
    intWritable.write(dataOutput);

    intWritable.set(stayInWifi);
    intWritable.write(dataOutput);
    intWritable.set(stayInStore);
    intWritable.write(dataOutput);

    DoubleWritable doubleWritable = new DoubleWritable();
    doubleWritable.set(jumpRate);
    doubleWritable.write(dataOutput);
    doubleWritable.set(deepVisit);
    doubleWritable.write(dataOutput);
    doubleWritable.set(inStoreRate);
    doubleWritable.write(dataOutput);
}
 
Example 4
Source File: TestTezMerger.java    From tez with Apache License 2.0 5 votes vote down vote up
private void populateData(IntWritable intKey, LongWritable longVal, DataInputBuffer key,
    DataInputBuffer value)
    throws  IOException {
  DataOutputBuffer k = new DataOutputBuffer();
  DataOutputBuffer v = new DataOutputBuffer();
  intKey.write(k);
  longVal.write(v);
  key.reset(k.getData(), 0, k.getLength());
  value.reset(v.getData(), 0, v.getLength());
  verificationDataSet.put(intKey.get(), longVal.get());
}
 
Example 5
Source File: TestMRCombiner.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public DataInputBuffer getValue() throws IOException {
  DataInputBuffer value = new DataInputBuffer();
  IntWritable intValue = new IntWritable(1);
  DataOutputBuffer out = new DataOutputBuffer();
  intValue.write(out);
  value.reset(out.getData(), out.getLength());
  return value;
}
 
Example 6
Source File: CustomWritable.java    From pxf with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    // 0. Timestamp
    Text tms_text = new Text(tms);
    tms_text.write(out);

    // 1. num, int1, int2
    IntWritable intw = new IntWritable();

    for (int i = 0; i < num.length; i++) {
        intw.set(num[i]);
        intw.write(out);
    }

    intw.set(int1);
    intw.write(out);

    intw.set(int2);
    intw.write(out);

    // 2. st1
    Text txt = new Text();

    for (int i = 0; i < strings.length; i++) {
        txt.set(strings[i]);
        txt.write(out);
    }

    txt.set(st1);
    txt.write(out);

    // 3. doubles
    DoubleWritable dw = new DoubleWritable();
    for (int i = 0; i < dubs.length; i++) {
        dw.set(dubs[i]);
        dw.write(out);
    }

    dw.set(db);
    dw.write(out);

    // 4. floats
    FloatWritable fw = new FloatWritable();
    for (int i = 0; i < fts.length; i++) {
        fw.set(fts[i]);
        fw.write(out);
    }

    fw.set(ft);
    fw.write(out);

    // 5. longs
    LongWritable lw = new LongWritable();
    for (int i = 0; i < lngs.length; i++) {
        lw.set(lngs[i]);
        lw.write(out);
    }
    lw.set(lng);
    lw.write(out);

    // 6. booleans
    BooleanWritable bw = new BooleanWritable();
    for (int i = 0; i < bools.length; ++i) {
        bw.set(bools[i]);
        bw.write(out);
    }
    bw.set(bool);
    bw.write(out);

    // 7. shorts
    ShortWritable sw = new ShortWritable();
    for (int i = 0; i < shrts.length; ++i) {
        sw.set(shrts[i]);
        sw.write(out);
    }
    sw.set(shrt);
    sw.write(out);

    // 8. bytes
    // BytesWritable btsw = new BytesWritable(bts);
    // btsw.write(out);
    BytesWritable btsw = new BytesWritable();
    btsw.setCapacity(bts.length);
    btsw.setSize(bts.length);
    btsw.set(bts, 0, bts.length);
    btsw.write(out);
}
 
Example 7
Source File: FSImageSerialization.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** write the int value */
static void writeInt(int value, DataOutputStream out) throws IOException {
  IntWritable uInt = TL_DATA.get().U_INT;
  uInt.set(value);
  uInt.write(out);
}
 
Example 8
Source File: RawBytesMapApp.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void writeInt(int i) throws IOException {
  dos.writeInt(4);
  IntWritable iw = new IntWritable(i);
  iw.write(dos);
}
 
Example 9
Source File: FSImageSerialization.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** write the int value */
static void writeInt(int value, DataOutputStream out) throws IOException {
  IntWritable uInt = TL_DATA.get().U_INT;
  uInt.set(value);
  uInt.write(out);
}
 
Example 10
Source File: RawBytesMapApp.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void writeInt(int i) throws IOException {
  dos.writeInt(4);
  IntWritable iw = new IntWritable(i);
  iw.write(dos);
}