vvysotskyi commented on a change in pull request #2016: DRILL-7631: Updates to
the Json Structure Parser
URL: https://github.com/apache/drill/pull/2016#discussion_r390423322
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/parser/ObjectListener.java
##########
@@ -52,80 +52,64 @@
*/
public interface ObjectListener {
+ public enum FieldType {
+
+ /**
+ * The field is unprojected, ignore its content. No value listener
+ * is created.
+ */
+ IGNORE,
+
+ /**
+ * Parse the JSON object according to its type.
+ */
+ TYPED,
+
+ /**
+ * The field is to be treated as "all-text". Used when the parser-level
+ * setting for {@code allTextMode} is {@code false}; allows per-field
+ * overrides to, perhaps, ride over inconsistent scalar types for a
+ * single field. The listener will receive only strings.
+ */
+ TEXT,
+
+ /**
+ * Parse the value, and all its children, as JSON.
+ * That is, converts the parsed JSON back into a
+ * JSON string. The listener will receive only strings.
+ */
+ JSON
+ }
+
/**
* Called at the start of a set of values for an object. That is, called
* when the structure parser accepts the <code>{</code> token.
*/
void onStart();
- /**
- * Called at the end of a set of values for an object. That is, called
- * when the structure parser accepts the <code>}</code> token.
- */
- void onEnd();
-
/**
* Called by the structure parser when it first sees a new field for
- * and object to determine if that field is to be projected (is needed
- * by the listener.) If not projected, the structure parser will not
+ * and object to determine how to parse the field.
+ * If not projected, the structure parser will not
* ask for a value listener and will insert a "dummy" parser that will
* free-wheel over any value of that field. As a result, unprojected
* fields can not cause type errors: they are invisible as long as
* they are syntactically valid.
+ * <p>
+ * The {@link FieldType#JSON} type says to parse the entire field, and
+ * its children, as a JSON string. The parser will ask for a value
+ * listener to accept the JSON text.
*
* @param key the object field name
- * @return {@code true} if this listener wants to provide a listener
- * for the field, {@code false} if the field should be ignored
- */
- boolean isProjected(String key);
-
- /**
- * A new field has appeared with a scalar (or {@code null}) value.
- * That is: {@code key: <scalar>}.
- *
- * @param key the field name
- * @param type the type as given by the JSON token for the value
- * @return a value listener for the scalar value
+ * @return how the field should be parsed
*/
- ValueListener addScalar(String key, JsonType type);
+ FieldType fieldType(String key);
- /**
- * A new field has appeared with a scalar, {@code null} or empty array
- * value. That is, one of:
- * <ul>
- * <li><code>key: [+ <scalar></code></li>
- * <li><code>key: [+ null</code></li>
- * <li><code>key: [+ ]</code></li>
- * </ul>
- * Where "[+" means one or more opening array elements.
- *
- * @param key the field name
- * @param arrayDims number of dimensions observed in the first appearance
- * of the array (more may appear later)
- * @param type the observed type of the first element of the array, or
- * {@link JsonType.NULL} if {@code null} was see, or
- * {@link JsonType.EMPTY} if an empty array was seen
- * @return a listener for the field itself which is prepared to
- * return an array listener
- */
- ValueListener addArray(String key, int arrayDims, JsonType type);
+ ValueListener addField(String key, ValueDef valueDef);
Review comment:
Please add JavaDoc.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services