apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shubham-pathak22 <...@git.apache.org>
Subject [GitHub] incubator-apex-malhar pull request: Apexmalhar 2033 streaming pars...
Date Wed, 25 May 2016 10:45:54 GMT
Github user shubham-pathak22 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/288#discussion_r64551501
  
    --- Diff: contrib/src/main/java/com/datatorrent/contrib/parser/StreamingJsonParser.java
---
    @@ -0,0 +1,451 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package com.datatorrent.contrib.parser;
    +
    +import java.io.UnsupportedEncodingException;
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.ListIterator;
    +import java.util.StringTokenizer;
    +
    +import org.elasticsearch.common.primitives.Ints;
    +import org.json.simple.parser.JSONParser;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import org.apache.commons.lang3.ClassUtils;
    +import org.apache.hadoop.classification.InterfaceStability;
    +
    +import com.google.common.collect.Lists;
    +
    +import com.datatorrent.api.Context;
    +import com.datatorrent.api.Context.OperatorContext;
    +import com.datatorrent.api.Context.PortContext;
    +import com.datatorrent.api.DefaultOutputPort;
    +import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
    +import com.datatorrent.lib.parser.Parser;
    +import com.datatorrent.lib.util.FieldInfo;
    +import com.datatorrent.lib.util.FieldInfo.SupportType;
    +import com.datatorrent.lib.util.KeyValPair;
    +import com.datatorrent.lib.util.PojoUtils;
    +
    +/**
    + * Operator that parses a JSON string tuple and emits a POJO on the output port
    + * and tuples that could not be parsed on error port.Upstream operator needs to
    + * ensure that a full JSON record is emitted.<br>
    + * <b>Properties</b><br>
    + * <b>pojoClass</b>:POJO class <br>
    + * <b>(optional)fieldMappingString</b>String of format
    + * fieldNameInJson:fieldNameInPOJO:DataType<br>
    + * <b>Ports</b> <br>
    + * <b>in</b>:input tuple as a String. Each tuple represents a json string<br>
    + * <b>out</b>:tuples that are validated as per the user defined POJO are
emitted
    + * as POJO on this port<br>
    + * <b>err</b>:tuples that could not be parsed are emitted on this port as
    + * KeyValPair<String,String><br>
    + * Key being the tuple and Val being the reason
    + * 
    + * @displayName SimpleStreamingJsonParser
    + * @category Parsers
    + * @tags json pojo parser streaming
    + */
    +@InterfaceStability.Evolving
    +public class StreamingJsonParser extends Parser<byte[], KeyValPair<String, String>>
    +{
    +  private String jsonSchema;
    +  private transient JSONParser jsonParser;
    +  private String fieldMappingString;
    +  private List<FieldInfo> fieldInfos;
    --- End diff --
    
    fieldInfos can be transient


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message