Skip to content

Commit 5aec267

Browse files
committed
Remove JsonStream. Use parse_many() instead.
1 parent ab0e22a commit 5aec267

File tree

8 files changed

+3
-300
lines changed

8 files changed

+3
-300
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ SRCHEADERS_WESTMERE=src/westmere/bitmanipulation.h src/westmere/bitmask.h src/we
6161
SRCHEADERS_SRC=src/isadetection.h src/jsoncharutils.h src/simdprune_tables.h src/implementation.cpp src/stage1_find_marks.cpp src/stage2_build_tape.cpp src/document_parser_callbacks.h
6262
SRCHEADERS=$(SRCHEADERS_SRC) $(SRCHEADERS_GENERIC) $(SRCHEADERS_ARM64) $(SRCHEADERS_HASWELL) $(SRCHEADERS_WESTMERE) $(SRCHEADERS_FALLBACK)
6363

64-
INCLUDEHEADERS=include/simdjson.h include/simdjson/common_defs.h include/simdjson/internal/jsonformatutils.h include/simdjson/jsonioutil.h include/simdjson/jsonparser.h include/simdjson/padded_string.h include/simdjson/inline/padded_string.h include/simdjson/document.h include/simdjson/inline/document.h include/simdjson/parsedjson_iterator.h include/simdjson/inline/parsedjson_iterator.h include/simdjson/document_stream.h include/simdjson/inline/document_stream.h include/simdjson/implementation.h include/simdjson/parsedjson.h include/simdjson/jsonstream.h include/simdjson/inline/jsonstream.h include/simdjson/portability.h include/simdjson/error.h include/simdjson/inline/error.h include/simdjson/simdjson.h include/simdjson/simdjson_version.h
64+
INCLUDEHEADERS=include/simdjson.h include/simdjson/common_defs.h include/simdjson/internal/jsonformatutils.h include/simdjson/jsonioutil.h include/simdjson/jsonparser.h include/simdjson/padded_string.h include/simdjson/inline/padded_string.h include/simdjson/document.h include/simdjson/inline/document.h include/simdjson/parsedjson_iterator.h include/simdjson/inline/parsedjson_iterator.h include/simdjson/document_stream.h include/simdjson/inline/document_stream.h include/simdjson/implementation.h include/simdjson/parsedjson.h include/simdjson/portability.h include/simdjson/error.h include/simdjson/inline/error.h include/simdjson/simdjson.h include/simdjson/simdjson_version.h
6565

6666
ifeq ($(SIMDJSON_TEST_AMALGAMATED_HEADERS),1)
6767
HEADERS=singleheader/simdjson.h

include/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ set(SIMDJSON_INCLUDE
1010
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/document_stream.h
1111
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/document.h
1212
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/error.h
13-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/jsonstream.h
1413
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/padded_string.h
1514
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/parsedjson_iterator.h
1615
${SIMDJSON_INCLUDE_DIR}/simdjson/internal/jsonformatutils.h
1716
${SIMDJSON_INCLUDE_DIR}/simdjson/jsonioutil.h
1817
${SIMDJSON_INCLUDE_DIR}/simdjson/jsonparser.h
19-
${SIMDJSON_INCLUDE_DIR}/simdjson/jsonstream.h
2018
${SIMDJSON_INCLUDE_DIR}/simdjson/padded_string.h
2119
${SIMDJSON_INCLUDE_DIR}/simdjson/parsedjson.h
2220
${SIMDJSON_INCLUDE_DIR}/simdjson/parsedjson_iterator.h

include/simdjson.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
#include "simdjson/jsonparser.h"
1616
#include "simdjson/parsedjson.h"
1717
#include "simdjson/parsedjson_iterator.h"
18-
#include "simdjson/jsonstream.h"
1918

2019
// Inline functions
2120
#include "simdjson/inline/document.h"
2221
#include "simdjson/inline/document_stream.h"
2322
#include "simdjson/inline/error.h"
24-
#include "simdjson/inline/jsonstream.h"
2523
#include "simdjson/inline/padded_string.h"
2624
#include "simdjson/inline/parsedjson_iterator.h"
2725

include/simdjson/document_stream.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
namespace simdjson {
88

9-
template <class string_container = padded_string> class JsonStream;
10-
119
/**
1210
* A forward-only stream of documents.
1311
*
@@ -137,7 +135,6 @@ class document::stream {
137135
std::thread stage_1_thread;
138136
document::parser parser_thread;
139137
#endif
140-
template <class string_container> friend class JsonStream;
141138
friend class document::parser;
142139
}; // class document::stream
143140

include/simdjson/inline/document_stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SIMDJSON_INLINE_DOCUMENT_STREAM_H
22
#define SIMDJSON_INLINE_DOCUMENT_STREAM_H
33

4-
#include "simdjson/jsonstream.h"
4+
#include "simdjson/document_stream.h"
55
#include <algorithm>
66
#include <limits>
77
#include <stdexcept>

include/simdjson/inline/jsonstream.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

include/simdjson/jsonstream.h

Lines changed: 0 additions & 125 deletions
This file was deleted.

tests/basictests.cpp

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -440,134 +440,6 @@ namespace document_stream_tests {
440440
return true;
441441
}
442442

443-
// returns true if successful
444-
bool JsonStream_utf8_test() {
445-
std::cout << "Running " << __func__ << std::endl;
446-
fflush(NULL);
447-
const size_t n_records = 10000;
448-
std::string data;
449-
char buf[1024];
450-
for (size_t i = 0; i < n_records; ++i) {
451-
auto n = sprintf(buf,
452-
"{\"id\": %zu, \"name\": \"name%zu\", \"gender\": \"%s\", "
453-
"\"été\": {\"id\": %zu, \"name\": \"éventail%zu\"}}",
454-
i, i, (i % 2) ? "" : "", i % 10, i % 10);
455-
data += std::string(buf, n);
456-
}
457-
const size_t batch_size = 1000;
458-
printf(".");
459-
fflush(NULL);
460-
simdjson::padded_string str(data);
461-
simdjson::JsonStream<simdjson::padded_string> js{str, batch_size};
462-
int parse_res = simdjson::SUCCESS_AND_HAS_MORE;
463-
size_t count = 0;
464-
simdjson::ParsedJson pj;
465-
while (parse_res == simdjson::SUCCESS_AND_HAS_MORE) {
466-
parse_res = js.json_parse(pj);
467-
if (parse_res != simdjson::SUCCESS && parse_res != simdjson::SUCCESS_AND_HAS_MORE) {
468-
break;
469-
}
470-
simdjson::ParsedJson::Iterator iter(pj);
471-
if(!iter.is_object()) {
472-
printf("Root should be object\n");
473-
return false;
474-
}
475-
if(!iter.down()) {
476-
printf("Root should not be emtpy\n");
477-
return false;
478-
}
479-
if(!iter.is_string()) {
480-
printf("Object should start with string key\n");
481-
return false;
482-
}
483-
if(strcmp(iter.get_string(),"id")!=0) {
484-
printf("There should a single key, id.\n");
485-
return false;
486-
}
487-
iter.move_to_value();
488-
if(!iter.is_integer()) {
489-
printf("Value of image should be integer\n");
490-
return false;
491-
}
492-
int64_t keyid = iter.get_integer();
493-
if(keyid != (int64_t)count) {
494-
printf("key does not match %d, expected %d\n",(int) keyid, (int) count);
495-
return false;
496-
}
497-
count++;
498-
}
499-
if(count != n_records) {
500-
printf("Something is wrong in JsonStream_utf8_test at window size = %zu.\n", batch_size);
501-
return false;
502-
}
503-
printf("ok\n");
504-
return true;
505-
}
506-
507-
// returns true if successful
508-
bool JsonStream_test() {
509-
std::cout << "Running " << __func__ << std::endl;
510-
fflush(NULL);
511-
const size_t n_records = 10000;
512-
std::string data;
513-
char buf[1024];
514-
for (size_t i = 0; i < n_records; ++i) {
515-
auto n = sprintf(buf,
516-
"{\"id\": %zu, \"name\": \"name%zu\", \"gender\": \"%s\", "
517-
"\"ete\": {\"id\": %zu, \"name\": \"eventail%zu\"}}",
518-
i, i, (i % 2) ? "homme" : "femme", i % 10, i % 10);
519-
data += std::string(buf, n);
520-
}
521-
const size_t batch_size = 1000;
522-
printf(".");
523-
fflush(NULL);
524-
simdjson::padded_string str(data);
525-
simdjson::JsonStream<simdjson::padded_string> js{str, batch_size};
526-
int parse_res = simdjson::SUCCESS_AND_HAS_MORE;
527-
size_t count = 0;
528-
simdjson::ParsedJson pj;
529-
while (parse_res == simdjson::SUCCESS_AND_HAS_MORE) {
530-
parse_res = js.json_parse(pj);
531-
if (parse_res != simdjson::SUCCESS && parse_res != simdjson::SUCCESS_AND_HAS_MORE) {
532-
break;
533-
}
534-
simdjson::ParsedJson::Iterator iter(pj);
535-
if(!iter.is_object()) {
536-
printf("Root should be object\n");
537-
return false;
538-
}
539-
if(!iter.down()) {
540-
printf("Root should not be emtpy\n");
541-
return false;
542-
}
543-
if(!iter.is_string()) {
544-
printf("Object should start with string key\n");
545-
return false;
546-
}
547-
if(strcmp(iter.get_string(),"id")!=0) {
548-
printf("There should a single key, id.\n");
549-
return false;
550-
}
551-
iter.move_to_value();
552-
if(!iter.is_integer()) {
553-
printf("Value of image should be integer\n");
554-
return false;
555-
}
556-
int64_t keyid = iter.get_integer();
557-
if(keyid != (int64_t)count) {
558-
printf("key does not match %d, expected %d\n",(int) keyid, (int) count);
559-
return false;
560-
}
561-
count++;
562-
}
563-
if(count != n_records) {
564-
printf("Something is wrong in JsonStream_test at window size = %zu.\n", batch_size);
565-
return false;
566-
}
567-
printf("ok\n");
568-
return true;
569-
}
570-
571443
// returns true if successful
572444
bool document_stream_test() {
573445
std::cout << "Running " << __func__ << std::endl;
@@ -666,9 +538,7 @@ namespace document_stream_tests {
666538

667539
bool run() {
668540
return document_stream_test() &&
669-
document_stream_utf8_test() &&
670-
JsonStream_test() &&
671-
JsonStream_utf8_test();
541+
document_stream_utf8_test();
672542
}
673543
}
674544

0 commit comments

Comments
 (0)