-- LarsAronsson - 30 Jun 2004

These notes were written on 30 June 2004, and doesn't handle the config files or the web db.

Nutch file formats from the bottom up

Nutch version 0.5

-- Differences noted by MattKangas - 04 Jan 2005

A segment now consists of five subdirectories, each containing an ArrayFile:





FetcherOutput is changed:

New class: net.nutch.protocol.Content

New class: net.nutch.parse.ParseText

New class: net.nutch.parse.ParseData

Nutch version 0.4

Nutch 0.4 was released on May 25, 2004 (the previous version 0.3 was from June 17, 2003). The Java source code consists of 165 files comprising 37,178 lines of code.

Nutch implements its own serialization to store serialized Java data types and structures on file. The interface net.nutch.io.Writable must be implemented for all such data types. In some cases, long text strings are stored in GZIP (Gnu ZIP) compressed format.

The abstract class nutch.io.VersionedWritable prepends a byte indicating the version of the data structure, typically \001.

Nutch uses Java's native UTF-8 character set, and the class net.nutch.io.UTF8 for writing short strings to files. The UTF8 class limits the length of strings to 0xffff/3 or 21845 bytes. The function UTF8.write() uses java.io.DataOutput.writeShort() to prepend the length of the string. This is why the two bytes \000\003 is seen before a three letter word in a file. The zero byte is thus not a null termination of the previous string (strings are not null terminated), but the most significant byte of the 16 bit short integer indicating the length of the following string.

Nutch relies heavily on mappings (associative arrays) from keys to values. The class net.nutch.io.SequenceFile is a flat file of keys and values. The first four bytes of each such file are ASCII "SEQ" and \001 (C-a), followed by the Java class names of keys and values, written as UTF8 strings, e.g. "SEQ\001\000\004long\000\004long", for a mapping from long integers to long integers. After that follows the key-value pairs. Each pair is introduced by four bytes telling the length in bytes of the pair (excluding the eight length bytes) and four bytes telling the length of the key. The typical long (64 bit) integer is 8 bytes and a long-to-long mapping will have pairs of length 16 bytes, e.g.

To economize the handling of large data volumes, net.nutch.io.MapFile manages a mapping as two separate files in a subdirectory of its own. The large "data" file stores all keys and values, sorted by the key. The much smaller "index" file points to byte offsets in the data file for a small sample of keys. Only the index file is read into memory.

net.nutch.io.ArrayFile is a specialization of MapFile where the keys are long integers.

The Java files in net.nutch.io.* comprise 2556 lines of source code. The biggest one is Sequencefile.java, which contains a Writer (112 lines), a Reader (138 lines), a BufferedRandomAccessFile (140 lines) and a Sorter (389 lines).

When Nutch crawls the web, each resulting segment has four subdirectories, each containing an ArrayFile (a MapFile having keys that are long integers):





Crawling is performed by net.nutch.fetcher.Fetcher which starts a number of parallel FetcherThread?. Each thread gets an URL from the fetchList, checks robots.txt, retrieves the contents and appends the results to fetcherDb, rawDb, and strippedDb.

The FetchListEntry is represented thus:

The FetcherOutput is all of the fetcher's output except the raw and stripped versions of the contents:

The FetcherContent is the raw contents stored in GZIP:

The FetcherText is the text conversion of page's content, stored in GZIP: