The CommonCrawlDataDumper is a Nutch tool. It is an alias for
org.apache.nutch.tools.CommonCrawlDataDumper. By using this tool, we can dump out Nutch segments into Common Crawl data format, mapping each crawled-by-Nutch file on a JSON-based data structure. CommonCrawlDataDumper dumps out the files and serialize them with CBOR encoding, a data representation format used in many contexts. Optionally, the CommonCrawlDataDumper is able to create a compressed archive including all CBOR-encoded data using gzip.
In order to run the CommonCrawlDataDumper tool, we can use either the command line (
bin/nutch commoncrawldump) or the Java class (
Table of Contents
Common Crawl format
The Common Crawl corpus contains petabytes of data collected over the last 7 years. It contains raw web page data, extracted metadata and text extractions.
Common Crawl currently stores the crawl data using the Web ARChive (WARC) format. The WARC format allows for more efficient storage and processing of CommonCrawl's free multi-billion page web archives, which can be hundreds of terabytes in size. More in depth, the Common Crawl format includes three file formats:
- WARC files which store the raw crawl data
- WAT files which store computed metadata for the data stored in the WARC
- WET files which store extracted plaintext from the data stored in the WARC
Common Crawl provides a corpus for collaborative research, analysis and education, giving the great opportunity to easily access high quality crawl data that was previously only available to large search engine corporations. For this reason, dumping out Nutch segments into Common Crawl format may allow the Nutch community to contribute in realizing the Common Crawl's mission. Thus, the CommonCrawlDataDumper tool aims at providing an easy way to dump out Nutch segments into Common Crawl format.
Currently, the CommonCrawlDataDumper tool represents a preliminary solution that maps each crawled-by-Nutch file on a JSON-based data structure including data, metadata and crawling information:
As JSON format above, the tool does not provide yet data that perfectly adheres to Common Crawl format. This preliminary version of the tool has been released to allow the Nutch community to give important feedback and ideas in order to extend this solution. For more details, visit NUTCH-1949 JIRA issue.
The CommonCrawlDataDumper tool is able to perfom the following steps:
- deserialize the crawled data from Nutch 2. map serialized data on the proper JSON structure 3. serialize the data into CBOR format 4. optionally, compress the serialized data using gzip
In case of exporting to an actual WARC file the process is a little different:
- deserialize the crawled data from Nutch 2. map deserialized data into a WARC file that can be compressed or not.
The following diagram describes the workflow of CommonCrawlDataDumper tool. It includes also some annotations.
This tool is able to work with either single Nutch segments or directory including segments as input data.
As shown in following sections, we can use either the command line (
bin/nutch commoncrawldump) or the Java class (
Using the command line
We can run the CommonCrawlDataDumper tool using the command
bin/nutch commoncrawldump. Typing
bin/nutch commoncrawldump without any argument, we can show the following:
For example, we can run the tool against Nutch segments in
/path/to/input_dir by typing:
The command above dumps out the PDF files, excluding all other mimetypes in Nutch segments located on
/path/to/input_dir, creating a
.tar.gz archive in
/path/to/output_dir. The gzip archive contains all CBOR-encoded files extracted from input segments. Actually, only
-segment command-line options are mandatory.
Using the CommonCrawlDataDumper Java class
org.apache.nutch.tools.CommonCrawlDataDumper.java) is the file containing the Java implementation of the tool. In addition to the entry point (
main), this Java class provide only one public method called
This method implements the core task of CommonCrawlDataDumper. It accepts five arguments:
outputDir is the output directory to save CBOR-encoded data,
segmentRootDir is the input directory including Nutch segments,
gzip determines if compression is used,
mimeTypes contains a list of mimetypes, if provided, and
warc determines if the export must be donde into an actual WARC file instead of the CBOR based format. We can call the CommonCrawlDataDumper tool from a Java program using this method.
If Nutch has been installed correctly, we can start crawling by typing the following command:
The command above allows to create Nutch segments for crawled data in
testCrawl folder. We can use this folder as input for CommonCrawlDataDumper in order to dump out data crawled using Nutch. Obviously, the
crawl command is not necessary if we have already Nutch segments to dump out.
In order to dump out Nutch segments, we can use the command-line program:
If when you start running the script later you start getting an error called
OutOfMemoryError, try changing the JAVA_HEAP_MAX variable in line 128 of
bin/nutch to an appropriate value.
bin/nutch commoncrawldump program dumps out all Nutch segments included in
outCommonCrawl folder, making one CBOR-encoded file for each crawled file. The tool will show a short report as follows:
We can use also the
-mimetype options to enable compression and mimetype filtering respectively.
-warcSize paramter allow to specify a maximun file size in bytes for the WARC output file, if this parameter is not specified then a default of 1GB is used as suggested in the WARC specification. If the size of the export file exceeded the
-warcSize parameter (or the 1GB default size) then the output file will be splited in several files.
The output file is named using the following convention:
in this case the
WEB followed by the timestamp and
serialno will be incremented each time that the file needs to be splitted to keep the size of the file below the defined limit.
-gzip option is used along with the
-warc option the output WARC file will be compressed using the GZIP format.
CBOR (RFC 7049 Concise Binary Object Representation) provides an object encoding format for serialization purposes. CBOR encoding is really simple, because it stores the information itself also in the first byte when it’s small enough. So the encoding is really comprehensive in contrast to most other encodings.
CBOR data is more compact than JSON (or other formats) when (1) numbers are used as identifiers instead of strings as JSON format, (2) complex aggregated data are used, (3) heterogeneous dataypes are used because, for example,
false values may be represented using less bytes, and so on.
Actually, the CommonCrawlDataDumper tool wraps a single string value (corresponding to JSON-based representation of deserialized Nutch data) into CBOR.
File compression allows to save much space when facing several files. To assist with large crawling tasks, the CommonCrawlDataDumper tool is able to generate (if
-gzip option is provided) a
.tar.gz archive including all CBOR-encoded files. The archive is named using the current timestamp (yyyyMMddhhmm.tar.gz). The tool relies on Apache Commons Compress to create
Regarding the implemented format explained above you can also export the data into a WARC file, using the
-warc option and optionally indicate a file size using the
-warcSize parameter. The output of this tool will be a valid WARC file with resource, request or response records.
If you need to export response/request records then you'll need to enable the
store.http.request settings in your
nutch-site.xml file. This settings are DISABLED by default. If the raw request is not found in your segments then no request record will be generated, on the other hand if no header information is found in the segments then instead of a response record you'll get a basic resource record that will not contain any information about the response headers, but will contain the raw response from the server.
An alternative implementation of a WARC Exporter is provided in NUTCH-2102 that is shipped with Nutch (as of version 1.11). To use this tool you can use the following command to display the usage information
Essentially an output directory needs to be specified as a first parameter and a list of segments specified next, or instead use the
-dir parameter to indicate the segments parent directory.
The WARCExporter tool is built using the Hadoop Map/Reduce approach so it could be a more appealing alternative if you're dealing with a lot of data or running nutch in a Hadoop cluster.
CommonCrawlDataDumper is a Nutch tool under development. Currently, we provide a preliminary version to get feedback and ideas by Nutch community. Please contribute in CommonCrawlDataDumper by writing/commenting on NUTCH-1949 JIRA issue.