nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi] tpalfy commented on a change in pull request #3611: NIFI-6009 ScanKudu Processor
Date Tue, 01 Oct 2019 16:52:23 GMT
tpalfy commented on a change in pull request #3611: NIFI-6009 ScanKudu Processor
URL: https://github.com/apache/nifi/pull/3611#discussion_r330163407
 
 

 ##########
 File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/ScanKudu.java
 ##########
 @@ -0,0 +1,392 @@
+/*
+ * 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.processors.kudu;
+
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kudu.ColumnSchema;
+import org.apache.kudu.client.KuduPredicate;
+import org.apache.kudu.client.KuduScanner;
+import org.apache.kudu.client.KuduTable;
+import org.apache.kudu.client.RowResult;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processors.kudu.io.ResultHandler;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+import javax.security.auth.login.LoginException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"kudu", "scan", "fetch", "get"})
+@CapabilityDescription("Scans rows from a Kudu table with an optional list of predicates")
+@WritesAttributes({
+        @WritesAttribute(attribute = "kudu.table", description = "The name of the Kudu table
that the row was fetched from"),
+        @WritesAttribute(attribute = "mime.type", description = "Set to application/json
when using a Destination of flowfile-content, not set or modified otherwise"),
+        @WritesAttribute(attribute = "kudu.rows.count", description = "Number of rows in
the content of given flow file"),
+        @WritesAttribute(attribute = "scankudu.results.found", description = "Indicates whether
at least one row has been found in given Kudu table with provided predicates. "
+                + "Could be null (not present) if transfered to FAILURE")})
+public class ScanKudu extends AbstractKuduProcessor {
+
+    static final Pattern PREDICATES_PATTERN = Pattern.compile("\\w+((<=|>=|[=<>])(\\w|-)+)?(?:,\\w+((<=|>=|[=<>])(\\w|-)+)?)*");
+    static final Pattern COLUMNS_PATTERN = Pattern.compile("\\w+((\\w)+)?(?:,\\w+((\\w)+)?)*");
+
+    protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder()
+            .name("table-name")
+            .displayName("Table Name")
+            .description("The name of the Kudu Table to put data into")
+            .required(true)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+            .build();
+
+  static final PropertyDescriptor PREDICATES =
+      new PropertyDescriptor.Builder()
+          .name("Predicates")
+          .description("A comma-separated list of Predicates,"
+              + "EQUALS: \"(colName)=(value)\","
+              + "GREATER: \"(colName)<(value)\","
+              + "LESS: \"(colName)>(value)\","
+              + "GREATER_EQUAL: \"(colName)>=(value)\","
+              + "LESS_EQUAL: \"(colName)<=(value)\"")
+          .required(false)
+          .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+          .addValidator(StandardValidators.createRegexMatchingValidator(PREDICATES_PATTERN))
+          .build();
+
+    static final PropertyDescriptor PROJECTED_COLUMNS = new PropertyDescriptor.Builder()
+            .name("Projected Column Names")
+            .description("A comma-separated list of \"<column>\" names to return when
scanning, default all.")
+            .required(false)
+            .addValidator(StandardValidators.createRegexMatchingValidator(COLUMNS_PATTERN))
+            .build();
+
+    protected static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder()
+            .name("Batch Size")
+            .description("The maximum number of FlowFiles to generate in a single execution,
between 1 - 100000. " +
 
 Review comment:
   I think this description still doesn't capture properly the behaviour. I'd change this
something like this:
   `"The maximum number of rows to generate per output flowfiles, between 1 - 100000. "`

----------------------------------------------------------------
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

Mime
View raw message