mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Segment the file into input chunks. Allow commas at the top level.
This commit is contained in:
@@ -903,10 +903,28 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (map != NULL && map != MAP_FAILED) {
|
if (map != NULL && map != MAP_FAILED) {
|
||||||
jp = json_begin_map(map, st.st_size - off);
|
#define THREADS 10
|
||||||
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, basezoom, source, droprate, file_bbox);
|
long long segs[THREADS + 1];
|
||||||
free(jp->source);
|
segs[0] = 0;
|
||||||
json_end(jp);
|
segs[THREADS] = st.st_size - off;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 1; i < THREADS; i++) {
|
||||||
|
segs[i] = off + (st.st_size - off) * i / THREADS;
|
||||||
|
|
||||||
|
while (segs[i] < st.st_size && map[segs[i]] != '\n') {
|
||||||
|
segs[i]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d %lld\n", i, segs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < THREADS; i++) {
|
||||||
|
jp = json_begin_map(map + segs[i], segs[i + 1] - segs[i]);
|
||||||
|
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, basezoom, source, droprate, file_bbox);
|
||||||
|
free(jp->source);
|
||||||
|
json_end(jp);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FILE *fp = fdopen(fd, "r");
|
FILE *fp = fdopen(fd, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
|
|||||||
+10
-13
@@ -332,20 +332,17 @@ again:
|
|||||||
/////////////////////////// Comma
|
/////////////////////////// Comma
|
||||||
|
|
||||||
if (c == ',') {
|
if (c == ',') {
|
||||||
if (j->container == NULL) {
|
if (j->container != NULL) {
|
||||||
j->error = "Found comma at top level";
|
if (j->container->expect != JSON_COMMA) {
|
||||||
return NULL;
|
j->error = "Found unexpected comma";
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (j->container->expect != JSON_COMMA) {
|
if (j->container->type == JSON_HASH) {
|
||||||
j->error = "Found unexpected comma";
|
j->container->expect = JSON_KEY;
|
||||||
return NULL;
|
} else {
|
||||||
}
|
j->container->expect = JSON_ITEM;
|
||||||
|
}
|
||||||
if (j->container->type == JSON_HASH) {
|
|
||||||
j->container->expect = JSON_KEY;
|
|
||||||
} else {
|
|
||||||
j->container->expect = JSON_ITEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user