You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/03/15 09:21:31 UTC

[camel] branch main updated (8387682 -> 35b502e)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 8387682  Sync deps
     new ee53649  CAMEL-17762: avoid unnecessary array copies
     new 35b502e  CAMEL-17762: improved documentation for the resumable set

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/java/org/apache/camel/ResumableSet.java   | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

[camel] 01/02: CAMEL-17762: avoid unnecessary array copies

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ee53649a5d56e72d8766e7d7615e745300e68f9e
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Mar 14 18:32:15 2022 +0100

    CAMEL-17762: avoid unnecessary array copies
---
 core/camel-api/src/main/java/org/apache/camel/ResumableSet.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java b/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
index 4e4693d..4f82216 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
@@ -17,6 +17,7 @@
 
 package org.apache.camel;
 
+import java.lang.reflect.Array;
 import java.util.Arrays;
 import java.util.function.Predicate;
 
@@ -30,8 +31,8 @@ public interface ResumableSet<T> {
      * @return
      */
     default T[] resumeEach(T[] input, Predicate<T> resumableCheck) {
-
-        T[] tmp = Arrays.copyOf(input, input.length);
+        @SuppressWarnings("unchecked")
+        T[] tmp = (T[]) Array.newInstance(input.getClass().getComponentType(), input.length);
         int count = 0;
 
         for (T entry : input) {
@@ -41,7 +42,7 @@ public interface ResumableSet<T> {
             }
         }
 
-        if (count != input.length) {
+        if (count > 0 && count != input.length) {
             return Arrays.copyOf(tmp, count);
         }
 

[camel] 02/02: CAMEL-17762: improved documentation for the resumable set

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 35b502e7cd26a2afe220f5adc9b06743feaae712
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Mar 14 18:45:14 2022 +0100

    CAMEL-17762: improved documentation for the resumable set
---
 .../src/main/java/org/apache/camel/ResumableSet.java     | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java b/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
index 4f82216..898c997 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ResumableSet.java
@@ -21,14 +21,21 @@ import java.lang.reflect.Array;
 import java.util.Arrays;
 import java.util.function.Predicate;
 
+/**
+ * An interface that represents a set of resumables (i.e.: files in a directory, rows in a database, etc)
+ *
+ * @param <T> the indivudal type of each member of the set
+ */
 public interface ResumableSet<T> {
 
     /**
      * Iterates over the set of input checking if they should be resumed or not.
      *
-     * @param  input
-     * @param  resumableCheck
-     * @return
+     * @param  input          the input array to check for resumables
+     * @param  resumableCheck a checker method that returns true if a single entry of the input should be resumed or
+     *                        false otherwise. For instance: given a set A, B and C, where B has already been processed,
+     *                        then a test for A and C returns false, whereas a test for B returns true.
+     * @return                a new array containing the elements that still need to be processed
      */
     default T[] resumeEach(T[] input, Predicate<T> resumableCheck) {
         @SuppressWarnings("unchecked")
@@ -53,7 +60,8 @@ public interface ResumableSet<T> {
      * Iterates over the set of input checking if they should be resumed or not
      *
      * @param resumableCheck a checker method that returns true if a single entry of the input should be resumed or
-     *                       false otherwise
+     *                       false otherwise. For instance: given a set A, B and C, where B has already been processed,
+     *                       then a test for A and C returns false, whereas a test for B returns true.
      */
     void resumeEach(Predicate<T> resumableCheck);