You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2019/04/08 23:23:27 UTC

[GitHub] [incubator-gobblin] ZihanLi58 commented on a change in pull request #2593: enable schema check for ticket ETL-8753

ZihanLi58 commented on a change in pull request #2593: enable schema check for ticket ETL-8753
URL: https://github.com/apache/incubator-gobblin/pull/2593#discussion_r273275278
 
 

 ##########
 File path: gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/extractor/FileAwareInputStreamExtractorWithCheckSchema.java
 ##########
 @@ -0,0 +1,79 @@
+/*
+ * 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.gobblin.data.management.copy.extractor;
+
+import java.io.IOException;
+
+import org.apache.avro.Schema;
+import org.apache.avro.file.DataFileReader;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.mapred.FsInput;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+
+import org.apache.gobblin.configuration.WorkUnitState;
+import org.apache.gobblin.data.management.copy.CopyableFile;
+import org.apache.gobblin.data.management.copy.FileAwareInputStream;
+import org.apache.gobblin.source.extractor.DataRecordException;
+import org.apache.gobblin.util.HadoopUtils;
+
+
+
+public class FileAwareInputStreamExtractorWithCheckSchema extends FileAwareInputStreamExtractor{
+  public final static String EXPECTED_SCHEMA = "expected.schema";
+
+  public FileAwareInputStreamExtractorWithCheckSchema(FileSystem fs, CopyableFile file, WorkUnitState state)
+  {
+    super(fs, file, state);
+  }
+  public FileAwareInputStreamExtractorWithCheckSchema(FileSystem fs, CopyableFile file)
+  {
+    this(fs, file, null);
+  }
+
+  @Override
+  public FileAwareInputStream readRecord(@Deprecated FileAwareInputStream reuse)
+      throws DataRecordException, IOException {
+    if (!this.recordRead) {
+      Configuration conf =
 
 Review comment:
   From my opinion, I think it's because the configuration only be used in this method. And temporary, this extractor will only handle one record so this readRecord method will be called only once. If we enable this extractor to handle multi records, then each time the state will change and the configuration need to be recomputed.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services