66import lombok .Data ;
77import lombok .RequiredArgsConstructor ;
88
9- public class SimdJsonParser2 {
9+ public class SimdJsonParserWithFixPath {
1010
1111 @ Data
1212 @ RequiredArgsConstructor
@@ -33,9 +33,8 @@ static class JsonNode {
3333 // every time json string is processed, currentVersion will be incremented by 1
3434 private long currentVersion = 0 ;
3535 // pruning, when alreadyProcessedCols == NUM
36- private long parseCols = 0 ;
3736
38- public SimdJsonParser2 (String ... args ) {
37+ public SimdJsonParserWithFixPath (String ... args ) {
3938 parser = new SimdJsonParser ();
4039 expectParseCols = args .length ;
4140 row = new JsonNode [expectParseCols ];
@@ -66,7 +65,6 @@ public String[] parse(byte[] buffer, int len) {
6665 if (buffer == null || buffer .length == 0 ) {
6766 return emptyResult ;
6867 }
69- this .parseCols = 0 ;
7068 this .currentVersion ++;
7169 this .ptr = root ;
7270 this .buffer = buffer ;
@@ -100,9 +98,6 @@ private String parseField() {
10098 }
10199
102100 private void parseElement (String expectFieldName ) {
103- if (parseCols >= expectParseCols ) {
104- return ;
105- }
106101 // if expectFieldName is null, parent is map, else is list
107102 if (expectFieldName == null ) {
108103 expectFieldName = parseField ();
@@ -123,7 +118,6 @@ private void parseElement(String expectFieldName) {
123118 default -> {
124119 ptr .setValue (skip (true ));
125120 ptr .setVersion (currentVersion );
126- ++parseCols ;
127121 }
128122 }
129123 ptr = ptr .getParent ();
@@ -133,12 +127,11 @@ private void parseMap() {
133127 if (ptr .getChildren () == null ) {
134128 ptr .setValue (skip (true ));
135129 ptr .setVersion (currentVersion );
136- ++parseCols ;
137130 return ;
138131 }
139132 ptr .setStart (bitIndexes .peek ());
140133 bitIndexes .advance ();
141- while (bitIndexes .hasNext () && buffer [bitIndexes .peek ()] != '}' && parseCols <= expectParseCols ) {
134+ while (bitIndexes .hasNext () && buffer [bitIndexes .peek ()] != '}' ) {
142135 parseElement (null );
143136 if (buffer [bitIndexes .peek ()] == ',' ) {
144137 bitIndexes .advance ();
@@ -148,7 +141,6 @@ private void parseMap() {
148141 if (ptr .isLeaf ()) {
149142 ptr .setValue (new String (buffer , ptr .getStart (), ptr .getEnd () - ptr .getStart () + 1 ));
150143 ptr .setVersion (currentVersion );
151- ++parseCols ;
152144 }
153145 bitIndexes .advance ();
154146 }
@@ -157,13 +149,12 @@ private void parseList() {
157149 if (ptr .getChildren () == null ) {
158150 ptr .setValue (skip (true ));
159151 ptr .setVersion (currentVersion );
160- ++parseCols ;
161152 return ;
162153 }
163154 ptr .setStart (bitIndexes .peek ());
164155 bitIndexes .advance ();
165156 int i = 0 ;
166- while (bitIndexes .hasNext () && buffer [bitIndexes .peek ()] != ']' && parseCols <= expectParseCols ) {
157+ while (bitIndexes .hasNext () && buffer [bitIndexes .peek ()] != ']' ) {
167158 parseElement ("" + i );
168159 if (buffer [bitIndexes .peek ()] == ',' ) {
169160 bitIndexes .advance ();
@@ -174,7 +165,6 @@ private void parseList() {
174165 if (ptr .isLeaf ()) {
175166 ptr .setValue (new String (buffer , ptr .getStart (), ptr .getEnd () - ptr .getStart () + 1 ));
176167 ptr .setVersion (currentVersion );
177- ++parseCols ;
178168 }
179169 bitIndexes .advance ();
180170 }
0 commit comments