List of usage examples for org.apache.hadoop.io VLongWritable set
public void set(long value)
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);// ww w. ja v 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:com.jfolson.hive.serde.RTypedBytesWritableInput.java
License:Apache License
public VLongWritable readVLong(VLongWritable lw) throws IOException { if (lw == null) { lw = new VLongWritable(); }/*from ww w.jav a 2 s . c o m*/ lw.set(in.readLong()); return lw; }
From source file:edu.uci.ics.pregelix.example.converter.VLongIdInputVertexConverter.java
License:Apache License
private void setVertexId(AFlatValuePointable vertexIdPointable, VLongWritable vid) throws HyracksDataException { byte[] data = vertexIdPointable.getByteArray(); int start = vertexIdPointable.getStartOffset() + 1; // Considers the AsterixDB type tag. switch (vertexIdTypeTag) { case INT8: {//w w w . ja v a 2 s . co m long id = AInt8SerializerDeserializer.getByte(data, start); vid.set(id); break; } case INT16: { long id = AInt16SerializerDeserializer.getShort(data, start); vid.set(id); break; } case INT32: { long id = AInt32SerializerDeserializer.getInt(data, start); vid.set(id); break; } case INT64: { long id = AInt64SerializerDeserializer.getLong(data, start); vid.set(id); break; } case STRING: { inputStream.setByteArray(data, start); try { vid.set(Long.parseLong(dataInput.readUTF())); } catch (IOException e) { throw new HyracksDataException(e); } break; } default: { throw new NotImplementedException("No printer for type " + vertexIdTypeTag); } } }
From source file:edu.uci.ics.pregelix.example.inputformat.TextGraphSampleVertexInputFormat.java
License:Apache License
@SuppressWarnings("unchecked") @Override//from w ww.j av a 2 s . c o m public Vertex<VLongWritable, BooleanWritable, NullWritable, BooleanWritable> getCurrentVertex() throws IOException, InterruptedException { pool.reset(); if (vertex == null) { vertex = BspUtils.createVertex(getContext().getConfiguration()); } vertex.getMsgList().clear(); vertex.getEdges().clear(); vertex.reset(); Text line = getRecordReader().getCurrentValue(); String lineStr = line.toString(); StringTokenizer tokenizer = new StringTokenizer(lineStr); if (tokenizer.hasMoreTokens()) { /** * set the src vertex id */ long src = Long.parseLong(tokenizer.nextToken()); vertexId.set(src); vertex.setVertexId(vertexId); long dest = -1L; /** * set up edges */ while (tokenizer.hasMoreTokens()) { dest = Long.parseLong(tokenizer.nextToken()); VLongWritable destId = pool.allocate(); destId.set(dest); vertex.addEdge(destId, value); } } vertex.setVertexValue(value); return vertex; }
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 .jav a2 s. c o 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);//from w w w.j a va2 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); } } } }