Datasets:
Update README.md
#1
by lfoppiano - opened
README.md
CHANGED
|
@@ -14,48 +14,136 @@ Each crawl, we generate a Host Index, which aggregates information about each we
|
|
| 14 |
information is aggregated from the Common Crawl [columnar index](https://commoncrawl.org/blog/index-to-warc-files-and-urls-in-columnar-format),
|
| 15 |
[web graph](https://commoncrawl.org/web-graphs), and [raw crawler logs](https://data.commoncrawl.org).
|
| 16 |
|
|
|
|
| 17 |
## Quickstart
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
DuckDB can [read directly from
|
|
|
|
| 22 |
|
| 23 |
```sql
|
| 24 |
$ duckdb
|
| 25 |
-
D
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
```python
|
| 52 |
>>> from datasets import load_dataset
|
| 53 |
-
>>> ds = load_dataset("commoncrawl/host-index-testing-v2",
|
| 54 |
-
|
| 55 |
>>> print(next(iter(ds)))
|
| 56 |
-
{'nutch_unfetched_pct': 0, 'fetch_other': 0,
|
| 57 |
```
|
| 58 |
|
|
|
|
|
|
|
| 59 |
## Use Cases
|
| 60 |
|
| 61 |
### Example questions this index can answer
|
|
|
|
| 14 |
information is aggregated from the Common Crawl [columnar index](https://commoncrawl.org/blog/index-to-warc-files-and-urls-in-columnar-format),
|
| 15 |
[web graph](https://commoncrawl.org/web-graphs), and [raw crawler logs](https://data.commoncrawl.org).
|
| 16 |
|
| 17 |
+
|
| 18 |
## Quickstart
|
| 19 |
|
| 20 |
+
The dataset is Hive-partitioned on `crawl` (`data/crawl=CC-MAIN-2025-18/*.parquet`). Open the whole
|
| 21 |
+
dataset once, then filter with `WHERE crawl = '...'`: because `crawl` is a partition key, the query
|
| 22 |
+
engine only reads the files for the crawls you ask for.
|
| 23 |
+
|
| 24 |
+
### Using DuckDB
|
| 25 |
|
| 26 |
+
DuckDB can [read directly from Hugging Face](https://huggingface.co/docs/hub/en/datasets-duckdb).
|
| 27 |
+
Create a view over every crawl once per session:
|
| 28 |
|
| 29 |
```sql
|
| 30 |
$ duckdb
|
| 31 |
+
D CREATE VIEW ccindex AS
|
| 32 |
+
SELECT * FROM read_parquet(
|
| 33 |
+
'hf://datasets/commoncrawl/host-index-testing-v2/data/**/*.parquet',
|
| 34 |
+
hive_partitioning = true, -- exposes the `crawl` directory as a column
|
| 35 |
+
union_by_name = true -- tolerates the schema differences between some crawls
|
| 36 |
+
);
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
This `CREATE VIEW` is slow (minutes, not seconds): DuckDB lists every file under `data/` through
|
| 40 |
+
the Hugging Face API and, because of `union_by_name`, reads the footer of each one to build the
|
| 41 |
+
merged schema. You pay this once per session. To make it faster, narrow the glob to the crawls you
|
| 42 |
+
need (e.g. `data/crawl=CC-MAIN-2025-*/*.parquet`), or drop `union_by_name` and stick to columns
|
| 43 |
+
that exist in every crawl.
|
| 44 |
+
|
| 45 |
+
Then run as many queries as you like against it. Always filter on `crawl`, and on
|
| 46 |
+
`url_host_tld` when you can — both prune the amount of data read.
|
| 47 |
+
|
| 48 |
+
Which crawls are available:
|
| 49 |
+
|
| 50 |
+
```sql
|
| 51 |
+
D SELECT DISTINCT crawl FROM ccindex ORDER BY crawl;
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
A single crawl:
|
| 55 |
+
|
| 56 |
+
```sql
|
| 57 |
+
D SELECT surt_host_name, fetch_200, hcrank10
|
| 58 |
+
FROM ccindex
|
| 59 |
+
WHERE crawl = 'CC-MAIN-2025-18'
|
| 60 |
+
LIMIT 3;
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Several crawls — crawl names sort chronologically, so range comparisons work too:
|
| 64 |
+
|
| 65 |
+
```sql
|
| 66 |
+
D SELECT crawl, count(*) AS hosts, sum(fetch_200) AS pages_200
|
| 67 |
+
FROM ccindex
|
| 68 |
+
WHERE crawl IN ('CC-MAIN-2025-13', 'CC-MAIN-2025-18')
|
| 69 |
+
GROUP BY crawl ORDER BY crawl;
|
| 70 |
+
|
| 71 |
+
D SELECT crawl, count(*) FROM ccindex
|
| 72 |
+
WHERE crawl >= 'CC-MAIN-2025-01'
|
| 73 |
+
GROUP BY crawl ORDER BY crawl;
|
| 74 |
```
|
| 75 |
|
| 76 |
+
The crawl history of one host, across every crawl:
|
| 77 |
|
| 78 |
+
```sql
|
| 79 |
+
D SELECT crawl, fetch_200, fetch_3xx, fetch_4xx, fetch_redirPerm, nutch_unfetched_pct, hcrank10
|
| 80 |
+
FROM ccindex
|
| 81 |
+
WHERE url_host_tld = 'org' AND surt_host_name = 'org,commoncrawl'
|
| 82 |
+
ORDER BY crawl;
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
Popular hosts in a crawl with mostly non-English content:
|
| 86 |
+
|
| 87 |
+
```sql
|
| 88 |
+
D SELECT surt_host_name, hcrank10, fetch_200, fetch_200_lote_pct
|
| 89 |
+
FROM ccindex
|
| 90 |
+
WHERE crawl = 'CC-MAIN-2025-18' AND fetch_200 >= 100 AND fetch_200_lote_pct > 50
|
| 91 |
+
ORDER BY hcrank10 DESC
|
| 92 |
+
LIMIT 20;
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
Notes:
|
| 96 |
+
- The view re-lists the files on every query. If you will hammer one crawl, materialize it
|
| 97 |
+
instead: `CREATE TABLE c2025_18 AS SELECT * FROM ccindex WHERE crawl = 'CC-MAIN-2025-18';`
|
| 98 |
+
- If your DuckDB does not auto-load `httpfs`, run `INSTALL httpfs; LOAD httpfs;` first.
|
| 99 |
+
|
| 100 |
+
### Using pyarrow
|
| 101 |
+
|
| 102 |
+
`pyarrow.dataset` understands the Hive partitioning natively and pushes the `crawl` filter down to
|
| 103 |
+
the file listing:
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
import pyarrow.dataset as ds
|
| 107 |
+
from huggingface_hub import HfFileSystem
|
| 108 |
+
|
| 109 |
+
fs = HfFileSystem()
|
| 110 |
+
ccindex = ds.dataset(
|
| 111 |
+
"datasets/commoncrawl/host-index-testing-v2/data",
|
| 112 |
+
filesystem=fs, format="parquet", partitioning="hive",
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
crawl = ds.field("crawl")
|
| 116 |
+
tld = ds.field("url_host_tld")
|
| 117 |
+
|
| 118 |
+
# one crawl, one TLD
|
| 119 |
+
gov = ccindex.to_table(filter=(crawl == "CC-MAIN-2025-18") & (tld == "gov"))
|
| 120 |
+
|
| 121 |
+
# one host across all crawls
|
| 122 |
+
history = ccindex.to_table(
|
| 123 |
+
filter=(tld == "org") & (ds.field("surt_host_name") == "org,commoncrawl"),
|
| 124 |
+
columns=["crawl", "fetch_200", "fetch_3xx", "fetch_redirPerm", "hcrank10"],
|
| 125 |
+
).sort_by("crawl")
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
Pass `columns=` whenever you can: Parquet is columnar, so unread columns cost nothing.
|
| 129 |
+
|
| 130 |
+
### Using the Hugging Face `datasets` library
|
| 131 |
+
|
| 132 |
+
"Streaming" mode (`streaming=True`) avoids downloading all of the parquet files up-front (see
|
| 133 |
+
[the `datasets` docs](https://huggingface.co/docs/datasets/v4.4.1/en/stream)). Point `data_dir`
|
| 134 |
+
at one crawl's partition; note that the `crawl` column comes from the directory name, so it does
|
| 135 |
+
not appear in rows loaded this way.
|
| 136 |
|
| 137 |
```python
|
| 138 |
>>> from datasets import load_dataset
|
| 139 |
+
>>> ds = load_dataset("commoncrawl/host-index-testing-v2",
|
| 140 |
+
... data_dir="data/crawl=CC-MAIN-2025-18", split="train", streaming=True)
|
| 141 |
>>> print(next(iter(ds)))
|
| 142 |
+
{'nutch_unfetched_pct': 0, 'fetch_other': 0, ...}
|
| 143 |
```
|
| 144 |
|
| 145 |
+
For multi-crawl work, prefer DuckDB or pyarrow above.
|
| 146 |
+
|
| 147 |
## Use Cases
|
| 148 |
|
| 149 |
### Example questions this index can answer
|