Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -32,7 +32,79 @@ Click this link to learn how to load the dataset to [Chipmunk](https://github.co
|
|
32 |
|
33 |
### Use directly in PostgreSQL
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
## Dataset Structure
|
38 |
|
|
|
32 |
|
33 |
### Use directly in PostgreSQL
|
34 |
|
35 |
+
1. Create Table
|
36 |
+
|
37 |
+
```sql
|
38 |
+
CREATE TABLE IF NOT EXISTS is_pd12m (
|
39 |
+
id BIGSERIAL PRIMARY KEY,
|
40 |
+
url VARCHAR NOT NULL,
|
41 |
+
hash VARCHAR NOT NULL DEFAULT '',
|
42 |
+
caption VARCHAR NOT NULL DEFAULT '',
|
43 |
+
caption_long VARCHAR NOT NULL DEFAULT '',
|
44 |
+
origin_hash VARCHAR NOT NULL DEFAULT '',
|
45 |
+
origin_width BIGINT NOT NULL DEFAULT 0,
|
46 |
+
origin_height BIGINT NOT NULL DEFAULT 0,
|
47 |
+
origin_storage_id VARCHAR(1024) DEFAULT NULL,
|
48 |
+
processed_storage_id VARCHAR(1024) NOT NULL DEFAULT '',
|
49 |
+
processed_width BIGINT NOT NULL DEFAULT 0,
|
50 |
+
processed_height BIGINT NOT NULL DEFAULT 0,
|
51 |
+
aspect_ratio DOUBLE PRECISION NOT NULL DEFAULT 0,
|
52 |
+
exif JSONB NOT NULL DEFAULT '{EMPTY_OBJECT}',
|
53 |
+
meta JSONB NOT NULL DEFAULT '{EMPTY_OBJECT}',
|
54 |
+
source JSONB NOT NULL DEFAULT '[]',
|
55 |
+
vector halfvec(1152) DEFAULT NULL,
|
56 |
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
57 |
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
58 |
+
);
|
59 |
+
```
|
60 |
+
|
61 |
+
2. Load csv file to database
|
62 |
+
|
63 |
+
2.1. Load the dataset from local file system to a remote PostgreSQL server:
|
64 |
+
|
65 |
+
```sql
|
66 |
+
\copy is_pd12m FROM 'data/0000000.csv' CSV HEADER;
|
67 |
+
\copy is_pd12m FROM 'data/0000001.csv' CSV HEADER;
|
68 |
+
\copy is_pd12m FROM 'data/0000002.csv' CSV HEADER;
|
69 |
+
...
|
70 |
+
```
|
71 |
+
|
72 |
+
2.2. Load the dataset from the PostgreSQL server's file system:
|
73 |
+
|
74 |
+
```sql
|
75 |
+
copy is_pd12m FROM 'data/0000000.csv' CSV HEADER;
|
76 |
+
copy is_pd12m FROM 'data/0000001.csv' CSV HEADER;
|
77 |
+
copy is_pd12m FROM 'data/0000002.csv' CSV HEADER;
|
78 |
+
...
|
79 |
+
```
|
80 |
+
|
81 |
+
3. Create Indexes
|
82 |
+
|
83 |
+
```sql
|
84 |
+
CREATE UNIQUE INDEX IF NOT EXISTS is_pd12m_url_index ON is_pd12m (url);
|
85 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_origin_width_index ON is_pd12m (origin_width);
|
86 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_origin_height_index ON is_pd12m (origin_height);
|
87 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_origin_storage_id_index ON is_pd12m (origin_storage_id);
|
88 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_processed_storage_id_index ON is_pd12m (processed_storage_id);
|
89 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_processed_width_index ON is_pd12m (processed_width);
|
90 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_processed_height_index ON is_pd12m (processed_height);
|
91 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_aspect_ratio_index ON is_pd12m (aspect_ratio);
|
92 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_exif_index ON is_pd12m USING gin(exif);
|
93 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_meta_index ON is_pd12m USING gin(meta);
|
94 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_source_index ON is_pd12m USING gin(source);
|
95 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_created_at_index ON is_pd12m (created_at);
|
96 |
+
CREATE INDEX IF NOT EXISTS is_pd12m_updated_at_index ON is_pd12m (updated_at);
|
97 |
+
CREATE INDEX IF NOT EXISTS {table_name}_vector_index ON is_pd12m USING vchordrq (vector halfvec_l2_ops) WITH (options = $$
|
98 |
+
residual_quantization = true
|
99 |
+
[build.internal]
|
100 |
+
lists = [20000]
|
101 |
+
build_threads = 6
|
102 |
+
spherical_centroids = false
|
103 |
+
$$);
|
104 |
+
f"CREATE INDEX IF NOT EXISTS is_pd12m_caption_index ON is_pd12m (caption) WHERE caption = '';
|
105 |
+
f"CREATE INDEX IF NOT EXISTS is_pd12m_caption_long_index ON is_pd12m (caption_long) WHERE caption_long = '';
|
106 |
+
f'CREATE INDEX IF NOT EXISTS is_pd12m_vector_null_index ON is_pd12m (vector) WHERE vector IS NULL;
|
107 |
+
```
|
108 |
|
109 |
## Dataset Structure
|
110 |
|