Example usage for org.apache.hadoop.io VLongWritable write

List of usage examples for org.apache.hadoop.io VLongWritable write

Introduction

In this page you can find the example usage for org.apache.hadoop.io VLongWritable write.

Prototype

@Override
    public void write(DataOutput out) throws IOException 

Source Link

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);/*from  w w w. j av  a 2 s. com*/
        vInt.write(out);
        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:cosmos.accumulo.GroupByRowSuffixIterator.java

License:Apache License

public static Value getValue(final VLongWritable w) {
    if (w == null) {
        throw new IllegalArgumentException("Writable cannot be null");
    }//from  w w  w .j  ava 2  s.c o  m
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(byteStream);

    // We could also close it, but we know that VLongWritable and BAOS don't need it.
    try {
        w.write(out);
    } catch (IOException e) {
        // If this ever happens, some seriously screwed up is happening or someone subclasses VLongWritable
        // and made it do crazy stuff.
        throw new RuntimeException(e);
    }

    return new Value(byteStream.toByteArray());
}

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);/*from  w ww. j a  v  a  2s  .  co m*/
        vInt.write(out);
        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);// w  w  w .  ja v a 2  s .  c  om
        vInt.write(out);
        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);
            }
        }
    }
}