List of usage examples for org.apache.hadoop.io VIntWritable write
@Override public void write(DataOutput out) throws IOException
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);/*www . j av 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); } } } }
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 w w.j av a 2 s. com*/ 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);/*from w w w . j a v a2s .co m*/ 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); } } } }