List of usage examples for org.apache.hadoop.io WritableUtils readVInt
public static int readVInt(DataInput stream) throws IOException
From source file:edu.umd.cloud9.collection.line.TextDocument.java
License:Apache License
/** * Serializes this object./*from w w w . j av a 2 s .c om*/ */ public void readFields(DataInput in) throws IOException { mDocid = in.readUTF(); int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); mContents = new String(bytes); }
From source file:edu.umd.cloud9.collection.medline.MedlineCitation.java
License:Apache License
/** * Serializes this object./* www . j a va 2 s .com*/ */ public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); MedlineCitation.readCitation(this, new String(bytes)); }
From source file:edu.umd.cloud9.collection.spinn3r.Spinn3rItem.java
License:Apache License
public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length);/* w w w. j ava 2 s . c o m*/ Spinn3rItem.readItem(this, new String(bytes)); }
From source file:edu.umd.cloud9.collection.trecweb.TrecWebDocument.java
License:Apache License
/** * Serializes this object.// www . jav a 2 s .c o m */ public void readFields(DataInput in) throws IOException { docid = in.readUTF(); int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); content = new String(bytes, "UTF-8"); }
From source file:edu.umd.cloud9.collection.wikipedia.WikipediaPage.java
License:Apache License
/** * Serializes this object.//from ww w .ja v a 2 s. c om */ public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); WikipediaPage.readPage(this, new String(bytes, "UTF-8")); language = in.readUTF(); }
From source file:edu.umd.cloud9.collection.wikipedia.WikipediaPageOld.java
License:Apache License
/** * Serializes this object.//from w w w .j a v a 2 s. co m */ public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); WikipediaPageOld.readPage(this, new String(bytes, "UTF-8")); language = in.readUTF(); }
From source file:edu.umd.cloud9.collection.wt10g.Wt10GDocument.java
License:Apache License
/** * Serializes this object.//from w ww.j a v a2 s. c om */ @Override public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); byte[] bytes = new byte[length]; in.readFully(bytes, 0, length); Wt10GDocument.readDocument(this, new String(bytes)); }
From source file:edu.umd.JBizz.BooleanRetrievalCompressed.java
License:Apache License
private ArrayListWritable<PairOfInts> fetchPostings(String term) throws IOException { Text key = new Text(); //PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>> value = //new PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>>(); ArrayListWritable<PairOfInts> poi = new ArrayListWritable<PairOfInts>(); BytesWritable value = new BytesWritable(); PairOfInts pair = new PairOfInts(); key.set(term);/*from w w w . j a va 2 s. c o m*/ index.get(key, value); byte[] vals = value.getBytes(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(vals)); int j = 0; int i = 0; int sentinel = 0; while (sentinel == 0) { j = WritableUtils.readVInt(dis); i = WritableUtils.readVInt(dis); if (i == 0 || j == 0) { sentinel = 1; } else { pair.set(j, i); poi.add(new PairOfInts(j, i)); } } return poi; }
From source file:edu.umd.shrawanraina.BooleanRetrievalCompressed.java
License:Apache License
private PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>> readPost(BytesWritable value) throws IOException { byte[] val = value.getBytes(); ByteArrayInputStream postings = new ByteArrayInputStream(val); DataInputStream stream = new DataInputStream(postings); ArrayListWritable<PairOfInts> pInt = new ArrayListWritable<PairOfInts>(); int currentDocNo = 0; int dgap = 0; int tf = -1;// w w w . ja v a 2 s. c om int postingList = WritableUtils.readVInt(stream); for (int i = 0; i < postingList; i++) { dgap = WritableUtils.readVInt(stream); tf = WritableUtils.readVInt(stream); currentDocNo = currentDocNo + dgap; pInt.add(new PairOfInts(currentDocNo, tf)); } //System.out.println("posting: "+new IntWritable(postingList)); //System.out.println("pInt: "+pInt); return new PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>>(new IntWritable(postingList), pInt); }
From source file:fi.tkk.ics.hadoop.bam.ReferenceFragment.java
License:Open Source License
public void readFields(DataInput in) throws IOException { // serialization order: // 1) sequence // 2) indexSequence (chromosome/contig name) // 3) position of first base in this line of the fasta file this.clear(); sequence.readFields(in);//from ww w .ja v a 2 s .co m indexSequence = WritableUtils.readString(in); position = WritableUtils.readVInt(in); }