List of usage examples for org.apache.hadoop.io WritableUtils writeVInt
public static void writeVInt(DataOutput stream, int i) throws IOException
From source file:org.apache.hama.pipes.protocol.UplinkReader.java
License:Apache License
public void seqFileClose() throws IOException { int fileID = WritableUtils.readVInt(this.inStream); LOG.debug("GOT MessageType.SEQFILE_CLOSE - FileID: " + fileID); boolean result = false; if (this.sequenceFileReaders.containsKey(fileID)) { this.sequenceFileReaders.get(fileID).getKey().close(); this.sequenceFileReaders.remove(fileID); result = true;//ww w. java 2 s . c o m } else if (this.sequenceFileWriters.containsKey(fileID)) { this.sequenceFileWriters.get(fileID).getKey().close(); this.sequenceFileWriters.remove(fileID); result = true; } else { // no fileID stored LOG.error("MessageType.SEQFILE_CLOSE: FileID " + fileID + " not found!"); } // RESPOND WritableUtils.writeVInt(this.outStream, MessageType.SEQFILE_CLOSE.code); WritableUtils.writeVInt(this.outStream, result ? 1 : 0); binProtocol.flush(); LOG.debug("Responded MessageType.SEQFILE_CLOSE - Result: " + result); }
From source file:org.apache.jena.grande.mapreduce.io.NodeWritable.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, length); out.write(bytes, 0, length); }
From source file:org.apache.jena.hadoop.rdf.types.AbstractNodeTupleWritable.java
License:Apache License
@Override public void write(DataOutput output) throws IOException { // Determine how many nodes Node[] ns = this.createNodes(this.tuple); WritableUtils.writeVInt(output, ns.length); // Write out nodes NodeWritable nw = new NodeWritable(); for (int i = 0; i < ns.length; i++) { nw.set(ns[i]);//from w w w . j a v a 2 s .com nw.write(output); } }
From source file:org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable.java
License:Apache License
@Override public void write(DataOutput output) throws IOException { // Write size, then count, then characteristics WritableUtils.writeVInt(output, this.characteristics.size()); this.count.write(output); for (CharacteristicWritable characteristic : this.characteristics.values()) { characteristic.write(output);// w w w . j a v a 2s . c om } }
From source file:org.apache.mrql.Bag.java
License:Apache License
/** the output serializer for Bag. * Stream-based Bags are serialized lazily (without having to cache the Bag in memory) *///www. j ava2 s . com final public void write(DataOutput out) throws IOException { if (materialized()) { out.writeByte(MRContainer.BAG); WritableUtils.writeVInt(out, size()); for (MRData e : this) e.write(out); } else { out.writeByte(MRContainer.LAZY_BAG); for (MRData e : this) e.write(out); out.writeByte(MRContainer.END_OF_LAZY_BAG); } }
From source file:org.apache.mrql.Bag.java
License:Apache License
private void writeObject(ObjectOutputStream out) throws IOException { materialize();// www . j a va2 s .c o m WritableUtils.writeVInt(out, size()); for (MRData e : this) e.write(out); }
From source file:org.apache.mrql.MR_int.java
License:Apache License
final public void write(DataOutput out) throws IOException { out.writeByte(MRContainer.INT); WritableUtils.writeVInt(out, value); }
From source file:org.apache.mrql.Tuple.java
License:Apache License
final public void write(DataOutput out) throws IOException { if (tuple.length == 0) out.writeByte(MRContainer.NULL); else if (tuple.length == 2) { out.writeByte(MRContainer.PAIR); tuple[0].write(out);/*from w ww .j ava2 s.c om*/ tuple[1].write(out); } else if (tuple.length == 3) { out.writeByte(MRContainer.TRIPLE); tuple[0].write(out); tuple[1].write(out); tuple[2].write(out); } else { out.writeByte(MRContainer.TUPLE); WritableUtils.writeVInt(out, tuple.length); for (short i = 0; i < tuple.length; i++) tuple[i].write(out); } }
From source file:org.apache.nutch.indexer.IndexDocument.java
License:Apache License
public void write(DataOutput out) throws IOException { out.writeByte(VERSION);/* ww w . ja va 2s. c om*/ WritableUtils.writeVInt(out, fields.size()); for (Map.Entry<String, IndexField> entry : fields.entrySet()) { Text.writeString(out, entry.getKey()); IndexField field = entry.getValue(); field.write(out); } out.writeFloat(weight); documentMeta.write(out); }
From source file:org.apache.nutch.indexer.NutchDocument.java
License:Apache License
public void write(DataOutput out) throws IOException { out.writeByte(VERSION);/*w w w. j a v a 2 s . com*/ WritableUtils.writeVInt(out, fields.size()); for (Map.Entry<String, List<String>> entry : fields.entrySet()) { Text.writeString(out, entry.getKey()); List<String> values = entry.getValue(); WritableUtils.writeVInt(out, values.size()); for (String value : values) { Text.writeString(out, value); } } out.writeFloat(score); documentMeta.write(out); }