List of usage examples for org.apache.hadoop.io VersionMismatchException VersionMismatchException
public VersionMismatchException(byte expectedVersionIn, byte foundVersionIn)
From source file:cn.edu.jnu.ie.backend.NutchDocument.java
License:Apache License
public void readFields(DataInput in) throws IOException { fields.clear();/*from w w w . ja va 2s. com*/ byte version = in.readByte(); if (version != VERSION) { throw new VersionMismatchException(VERSION, version); } int size = WritableUtils.readVInt(in); for (int i = 0; i < size; i++) { String name = Text.readString(in); NutchField field = new NutchField(); field.readFields(in); fields.put(name, field); } weight = in.readFloat(); }
From source file:com.digitalpebble.behemoth.BehemothDocument.java
License:Apache License
public final void readFields(DataInput in) throws IOException { byte version = in.readByte(); // read version if (version > CUR_VERSION) // check version throw new VersionMismatchException(CUR_VERSION, version); url = Text.readString(in);//from w w w . j a v a 2s .co m int contentLength = in.readInt(); content = new byte[contentLength]; if (contentLength > 0) in.readFully(content); contentType = Text.readString(in); boolean hasText = in.readBoolean(); if (hasText) text = Text.readString(in); else text = null; boolean hasMD = in.readBoolean(); if (hasMD) { metadata = new MapWritable(); metadata.readFields(in); } else metadata = null; // read the number of annotation types int numTypes = in.readInt(); ArrayList<String> types = null; if (numTypes > 0) { types = new ArrayList<String>(numTypes); for (int i = 0; i < numTypes; i++) { types.add(Text.readString(in)); } } int numAnnots = in.readInt(); this.annotations = new ArrayList<Annotation>(numAnnots); for (int i = 0; i < numAnnots; i++) { Annotation annot = new Annotation(); readAnnotationFields(annot, in, types); this.annotations.add(annot); } }
From source file:com.iflytek.spider.parse.ParseText.java
License:Apache License
public void readFields(DataInput in) throws IOException { byte version = in.readByte(); switch (version) { case 1:/*from ww w . j a v a2 s .c o m*/ text = WritableUtils.readCompressedString(in); break; case VERSION: text = Text.readString(in); break; default: throw new VersionMismatchException(VERSION, version); } }
From source file:com.iflytek.spider.protocol.ProtocolStatus.java
License:Apache License
public void readFields(DataInput in) throws IOException { byte version = in.readByte(); switch (version) { case 1:/*from ww w. ja v a 2 s. c o m*/ code = in.readByte(); lastModified = in.readLong(); args = WritableUtils.readCompressedStringArray(in); break; case VERSION: code = in.readByte(); lastModified = in.readLong(); args = WritableUtils.readStringArray(in); break; default: throw new VersionMismatchException(VERSION, version); } }
From source file:org.apache.nutch.crawl.CrawlDatum.java
License:Apache License
public void readFields(DataInput in) throws IOException { byte version = in.readByte(); // read version if (version > CUR_VERSION) // check version throw new VersionMismatchException(CUR_VERSION, version); status = in.readByte();//from w ww . ja v a2 s .c om fetchTime = in.readLong(); retries = in.readByte(); if (version > 5) { fetchInterval = in.readInt(); } else fetchInterval = Math.round(in.readFloat()); score = in.readFloat(); if (version > 2) { modifiedTime = in.readLong(); int cnt = in.readByte(); if (cnt > 0) { signature = new byte[cnt]; in.readFully(signature); } else signature = null; } if (version > 3) { boolean hasMetadata = false; if (version < 7) { org.apache.hadoop.io.MapWritable oldMetaData = new org.apache.hadoop.io.MapWritable(); if (in.readBoolean()) { hasMetadata = true; metaData = new org.apache.hadoop.io.MapWritable(); oldMetaData.readFields(in); } for (Writable key : oldMetaData.keySet()) { metaData.put(key, oldMetaData.get(key)); } } else { if (in.readBoolean()) { hasMetadata = true; metaData = new org.apache.hadoop.io.MapWritable(); metaData.readFields(in); } } if (hasMetadata == false) metaData = null; } // translate status codes if (version < 5) { if (oldToNew.containsKey(status)) status = oldToNew.get(status); else status = STATUS_DB_UNFETCHED; } }
From source file:org.apache.nutch.indexer.IndexDocument.java
License:Apache License
public void readFields(DataInput in) throws IOException { fields.clear();//from ww w .j ava 2 s . c om byte version = in.readByte(); if (version != VERSION) { throw new VersionMismatchException(VERSION, version); } int size = WritableUtils.readVInt(in); for (int i = 0; i < size; i++) { String name = Text.readString(in); IndexField field = new IndexField(); field.readFields(in); fields.put(name, field); } weight = in.readFloat(); documentMeta.readFields(in); }
From source file:org.apache.nutch.indexer.NutchDocument.java
License:Apache License
public void readFields(DataInput in) throws IOException { byte version = in.readByte(); if (version != VERSION) { throw new VersionMismatchException(VERSION, version); }/*from w w w .j a v a 2s . c o m*/ int size = WritableUtils.readVInt(in); for (int i = 0; i < size; i++) { String name = Text.readString(in); int numValues = WritableUtils.readVInt(in); fields.put(name, new ArrayList<String>()); for (int j = 0; j < numValues; j++) { String value = Text.readString(in); addFieldUnprotected(name, value); } } score = in.readFloat(); documentMeta.readFields(in); }
From source file:org.apache.nutch.parse.ParseData.java
License:Apache License
public final void readFields(DataInput in) throws IOException { version = in.readByte();/*from w w w .j a v a 2 s .com*/ // incompatible change from UTF8 (version < 5) to Text if (version != VERSION) throw new VersionMismatchException(VERSION, version); status = ParseStatus.read(in); title = Text.readString(in); // read title int numOutlinks = in.readInt(); outlinks = new Outlink[numOutlinks]; for (int i = 0; i < numOutlinks; i++) { outlinks[i] = Outlink.read(in); } if (version < 3) { int propertyCount = in.readInt(); // read metadata contentMeta.clear(); for (int i = 0; i < propertyCount; i++) { contentMeta.add(Text.readString(in), Text.readString(in)); } } else { contentMeta.clear(); contentMeta.readFields(in); } if (version > 3) { parseMeta.clear(); parseMeta.readFields(in); } }
From source file:org.apache.nutch.parse.ParseStatus.java
License:Apache License
public void readFields(DataInput in) throws IOException { byte version = in.readByte(); switch (version) { case 1:/* w w w. ja v a 2s.c om*/ majorCode = in.readByte(); minorCode = in.readShort(); args = WritableUtils.readCompressedStringArray(in); break; case 2: majorCode = in.readByte(); minorCode = in.readShort(); args = WritableUtils.readStringArray(in); break; default: throw new VersionMismatchException(VERSION, version); } }
From source file:org.apache.nutch.protocol.Content.java
License:Apache License
private final void readFieldsCompressed(DataInput in) throws IOException { byte oldVersion = in.readByte(); switch (oldVersion) { case 0:/*from w w w . j a v a 2 s . c om*/ case 1: url = Text.readString(in); // read url base = Text.readString(in); // read base content = new byte[in.readInt()]; // read content in.readFully(content); contentType = Text.readString(in); // read contentType // reconstruct metadata int keySize = in.readInt(); String key; for (int i = 0; i < keySize; i++) { key = Text.readString(in); int valueSize = in.readInt(); for (int j = 0; j < valueSize; j++) { metadata.add(key, Text.readString(in)); } } break; case 2: url = Text.readString(in); // read url base = Text.readString(in); // read base content = new byte[in.readInt()]; // read content in.readFully(content); contentType = Text.readString(in); // read contentType metadata.readFields(in); // read meta data break; default: throw new VersionMismatchException((byte) 2, oldVersion); } }