Example usage for org.apache.hadoop.io VIntWritable set

List of usage examples for org.apache.hadoop.io VIntWritable set

Introduction

In this page you can find the example usage for org.apache.hadoop.io VIntWritable set.

Prototype

public void set(int value) 

Source Link

Document

Set the value of this VIntWritable.

Usage

From source file:com.cg.mapreduce.fpgrowth.mahout.fpm.TransactionTree.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeBoolean(representedAsList);
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
    if (representedAsList) {
        int transactionSetSize = transactionSet.size();
        vInt.set(transactionSetSize);
        vInt.write(out);//from   ww w .  j a  va2 s .com
        for (Pair<IntArrayList, Long> transaction : transactionSet) {
            vLong.set(transaction.getSecond());
            vLong.write(out);

            vInt.set(transaction.getFirst().size());
            vInt.write(out);

            IntArrayList items = transaction.getFirst();
            for (int idx = 0; idx < items.size(); idx++) {
                int item = items.get(idx);
                vInt.set(item);
                vInt.write(out);
            }
        }
    } else {
        vInt.set(nodes);
        vInt.write(out);
        for (int i = 0; i < nodes; i++) {
            vInt.set(attribute[i]);
            vInt.write(out);
            vLong.set(nodeCount[i]);
            vLong.write(out);
            vInt.set(childCount[i]);
            vInt.write(out);
            int max = childCount[i];
            for (int j = 0; j < max; j++) {
                vInt.set(nodeChildren[i][j]);
                vInt.write(out);
            }
        }
    }
}

From source file:com.jfolson.hive.serde.RTypedBytesWritableInput.java

License:Apache License

public VIntWritable readVInt(VIntWritable iw) throws IOException {
    if (iw == null) {
        iw = new VIntWritable();
    }//from  w  w  w  . j  a v a 2s  .c o  m
    iw.set(in.readInt());
    return iw;
}

From source file:org.apache.mahout.fpm.pfpgrowth.TransactionTree.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeBoolean(representedAsList);
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
    if (representedAsList) {
        int transactionSetSize = transactionSet.size();
        vInt.set(transactionSetSize);
        vInt.write(out);//from   w  w  w.ja v  a 2 s. c o m
        for (int i = 0; i < transactionSetSize; i++) {
            Pair<List<Integer>, Long> transaction = transactionSet.get(i);

            vLong.set(transaction.getSecond());
            vLong.write(out);

            vInt.set(transaction.getFirst().size());
            vInt.write(out);

            for (Integer item : transaction.getFirst()) {
                vInt.set(item);
                vInt.write(out);
            }
        }
    } else {
        vInt.set(nodes);
        vInt.write(out);
        for (int i = 0; i < nodes; i++) {
            vInt.set(attribute[i]);
            vInt.write(out);
            vLong.set(nodeCount[i]);
            vLong.write(out);
            vInt.set(childCount[i]);
            vInt.write(out);
            for (int j = 0, k = childCount[i]; j < k; j++) {
                vInt.set(nodeChildren[i][j]);
                vInt.write(out);
            }
        }
    }
}

From source file:PFPGrowth_in_SPARK.TransactionTree.java

License:Apache License

public void write(DataOutput out) throws IOException {
    out.writeBoolean(representedAsList);
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
    if (representedAsList) {
        int transactionSetSize = transactionSet.size();
        vInt.set(transactionSetSize);
        vInt.write(out);/* ww w  . ja  va 2  s. co m*/
        for (Pair<IntArrayList, Long> transaction : transactionSet) {
            vLong.set(transaction.getSecond());
            vLong.write(out);

            vInt.set(transaction.getFirst().size());
            vInt.write(out);

            IntArrayList items = transaction.getFirst();
            for (int idx = 0; idx < items.size(); idx++) {
                int item = items.get(idx);
                vInt.set(item);
                vInt.write(out);
            }
        }
    } else {
        vInt.set(nodes);
        vInt.write(out);
        for (int i = 0; i < nodes; i++) {
            vInt.set(attribute[i]);
            vInt.write(out);
            vLong.set(nodeCount[i]);
            vLong.write(out);
            vInt.set(childCount[i]);
            vInt.write(out);
            int max = childCount[i];
            for (int j = 0; j < max; j++) {
                vInt.set(nodeChildren[i][j]);
                vInt.write(out);
            }
        }
    }
}