MCPcopy Create free account
hub / github.com/apache/nutch / readFields

Method readFields

src/java/org/apache/nutch/protocol/Content.java:150–177  ·  view source on GitHub ↗
(DataInput in)

Source from the content-addressed store, hash-verified

148 }
149
150 public final void readFields(DataInput in) throws IOException {
151 metadata.clear();
152 int sizeOrVersion = in.readInt();
153 if (sizeOrVersion < 0) { // version
154 version = sizeOrVersion;
155 switch (version) {
156 case VERSION:
157 url = Text.readString(in);
158 base = Text.readString(in);
159
160 content = new byte[in.readInt()];
161 in.readFully(content);
162
163 contentType = Text.readString(in);
164 metadata.readFields(in);
165 break;
166 default:
167 throw new VersionMismatchException((byte) VERSION, (byte) version);
168 }
169 } else { // size
170 byte[] compressed = new byte[sizeOrVersion];
171 in.readFully(compressed, 0, compressed.length);
172 ByteArrayInputStream deflated = new ByteArrayInputStream(compressed);
173 DataInput inflater = new DataInputStream(
174 new InflaterInputStream(deflated));
175 readFieldsCompressed(inflater);
176 }
177 }
178
179 public final void write(DataOutput out) throws IOException {
180 out.writeInt(VERSION);

Callers 2

readMethod · 0.95
readFieldsCompressedMethod · 0.45

Calls 2

readFieldsCompressedMethod · 0.95
clearMethod · 0.80

Tested by

no test coverage detected