[ 
https://issues.apache.org/jira/browse/NIFI-3724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15991043#comment-15991043
 ] 

ASF GitHub Bot commented on NIFI-3724:
--------------------------------------

Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1712#discussion_r114150872
  
    --- Diff: 
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/avro/AvroTypeUtil.java
 ---
    @@ -0,0 +1,496 @@
    +/*
    + * 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 org.apache.nifi.avro;
    +
    +import org.apache.avro.LogicalType;
    +import org.apache.avro.LogicalTypes;
    +import org.apache.avro.Schema;
    +import org.apache.avro.Schema.Field;
    +import org.apache.avro.Schema.Type;
    +import org.apache.avro.generic.GenericData;
    +import org.apache.avro.generic.GenericFixed;
    +import org.apache.avro.generic.GenericRecord;
    +import org.apache.avro.util.Utf8;
    +import org.apache.nifi.schema.access.SchemaNotFoundException;
    +import org.apache.nifi.serialization.SimpleRecordSchema;
    +import org.apache.nifi.serialization.record.DataType;
    +import org.apache.nifi.serialization.record.MapRecord;
    +import org.apache.nifi.serialization.record.Record;
    +import org.apache.nifi.serialization.record.RecordField;
    +import org.apache.nifi.serialization.record.RecordFieldType;
    +import org.apache.nifi.serialization.record.RecordSchema;
    +import org.apache.nifi.serialization.record.SchemaIdentifier;
    +import org.apache.nifi.serialization.record.util.DataTypeUtils;
    +import 
org.apache.nifi.serialization.record.util.IllegalTypeConversionException;
    +
    +import java.io.IOException;
    +import java.nio.ByteBuffer;
    +import java.time.Duration;
    +import java.time.temporal.ChronoUnit;
    +import java.util.ArrayList;
    +import java.util.Date;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Optional;
    +import java.util.concurrent.TimeUnit;
    +import java.util.stream.Collectors;
    +
    +public class AvroTypeUtil {
    +    public static final String AVRO_SCHEMA_FORMAT = "avro";
    +
    +    public static Schema extractAvroSchema(final RecordSchema 
recordSchema) throws SchemaNotFoundException {
    +        final Optional<String> schemaFormatOption = 
recordSchema.getSchemaFormat();
    +        if (!schemaFormatOption.isPresent()) {
    +            throw new SchemaNotFoundException("No Schema Format was 
present in the RecordSchema");
    +        }
    +
    +        final String schemaFormat = schemaFormatOption.get();
    +        if (!schemaFormat.equals(AVRO_SCHEMA_FORMAT)) {
    +            throw new SchemaNotFoundException("Schema provided is not in 
Avro format");
    +        }
    +
    +        final Optional<String> textOption = recordSchema.getSchemaText();
    +        if (!textOption.isPresent()) {
    +            throw new SchemaNotFoundException("No Schema text was present 
in the RecordSchema");
    +        }
    +
    +        final String text = textOption.get();
    +        return new Schema.Parser().parse(text);
    +    }
    +
    +    public static DataType determineDataType(final Schema avroSchema) {
    +        final Type avroType = avroSchema.getType();
    --- End diff --
    
    Same comment for `null` check. 


> Add Put/Fetch Parquet Processors
> --------------------------------
>
>                 Key: NIFI-3724
>                 URL: https://issues.apache.org/jira/browse/NIFI-3724
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Bryan Bende
>            Assignee: Bryan Bende
>            Priority: Minor
>             Fix For: 1.2.0
>
>
> Now that we have the record reader/writer services currently in master, it 
> would be nice to have reader and writers for Parquet. Since Parquet's API is 
> based on the Hadoop Path object, and not InputStreams/OutputStreams, we can't 
> really implement direct conversions to and from Parquet in the middle of a 
> flow, but we can we can perform the conversion by taking any record format 
> and writing to a Path as Parquet, or reading Parquet from a Path and writing 
> it out as another record format.
> We should add a PutParquet that uses a record reader and writes records to a 
> Path as Parquet, and a FetchParquet that reads Parquet from a path and writes 
> out records to a flow file using a record writer.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to