From 4fe66b79ae14ba49ecb1aea58a15dca5fdf8b1f2 Mon Sep 17 00:00:00 2001 From: psainics Date: Mon, 9 Sep 2024 17:49:39 +0530 Subject: [PATCH] Add GCSEmptyInputFormat --- .../gcp/common/GCSEmptyInputFormat.java | 30 +++++++++++++++++++ .../cdap/plugin/gcp/gcs/source/GCSSource.java | 11 +++---- 2 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/main/java/io/cdap/plugin/gcp/common/GCSEmptyInputFormat.java diff --git a/src/main/java/io/cdap/plugin/gcp/common/GCSEmptyInputFormat.java b/src/main/java/io/cdap/plugin/gcp/common/GCSEmptyInputFormat.java new file mode 100644 index 0000000000..b6ee12e456 --- /dev/null +++ b/src/main/java/io/cdap/plugin/gcp/common/GCSEmptyInputFormat.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2024 Cask Data, Inc. + * + * Licensed 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 io.cdap.plugin.gcp.common; + +import io.cdap.plugin.format.input.AbstractEmptyInputFormat; + + +/** + * An InputFormat that returns no data. + * @param the type of key + * @param the type of value + */ +public class GCSEmptyInputFormat extends AbstractEmptyInputFormat { + // no-op +} diff --git a/src/main/java/io/cdap/plugin/gcp/gcs/source/GCSSource.java b/src/main/java/io/cdap/plugin/gcp/gcs/source/GCSSource.java index 1d52fc90fb..7bfec4dd81 100644 --- a/src/main/java/io/cdap/plugin/gcp/gcs/source/GCSSource.java +++ b/src/main/java/io/cdap/plugin/gcp/gcs/source/GCSSource.java @@ -43,6 +43,7 @@ import io.cdap.plugin.format.plugin.FileSourceProperties; import io.cdap.plugin.gcp.common.GCPConnectorConfig; import io.cdap.plugin.gcp.common.GCPUtils; +import io.cdap.plugin.gcp.common.GCSEmptyInputFormat; import io.cdap.plugin.gcp.crypto.EncryptedFileSystem; import io.cdap.plugin.gcp.gcs.GCSPath; import io.cdap.plugin.gcp.gcs.connector.GCSConnector; @@ -77,6 +78,11 @@ public void configurePipeline(PipelineConfigurer pipelineConfigurer) { super.configurePipeline(pipelineConfigurer); } + @Override + protected String getEmptyInputFormatClassName() { + return GCSEmptyInputFormat.class.getName(); + } + @Override public void prepareRun(BatchSourceContext context) throws Exception { // Get location of the source for lineage @@ -268,11 +274,6 @@ public Long getMinSplitSize() { return minSplitSize; } - @Override - public boolean shouldAllowEmptyInput() { - return false; - } - public boolean isCopyHeader() { return shouldCopyHeader(); }