asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AsterixDB Code Review <do-not-re...@asterix-gerrit.ics.uci.edu>
Subject Change in asterixdb[cheshire-cat]: [NO ISSUE] Misc utility / cleanup
Date Mon, 07 Jun 2021 00:06:38 GMT
>From Michael Blow <mblow@apache.org>:

Michael Blow has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11803
)


Change subject: [NO ISSUE] Misc utility / cleanup
......................................................................

[NO ISSUE] Misc utility / cleanup

Change-Id: Iae424fb99220630cb3a240cfef4cbba39b9da06b
---
M hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/HyracksThrowingConsumer.java
M hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
2 files changed, 28 insertions(+), 1 deletion(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/03/11803/1

diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/HyracksThrowingConsumer.java
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/HyracksThrowingConsumer.java
index b677132..765f9d7 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/HyracksThrowingConsumer.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/HyracksThrowingConsumer.java
@@ -18,9 +18,25 @@
  */
 package org.apache.hyracks.api.util;
 
+import java.util.function.Consumer;
+
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
+import com.google.common.util.concurrent.UncheckedExecutionException;
+
 @FunctionalInterface
 public interface HyracksThrowingConsumer<V> {
-    void process(V value) throws HyracksDataException;
+    void accept(V value) throws HyracksDataException;
+
+    @SuppressWarnings("Duplicates")
+    static <T> Consumer<T> asUnchecked(HyracksThrowingConsumer<T> consumer)
{
+        return input -> {
+            try {
+                consumer.accept(input);
+            } catch (HyracksDataException e) {
+                throw new UncheckedExecutionException(e);
+            }
+        };
+    }
+
 }
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
index dc8bc11..1a40360 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
@@ -18,6 +18,7 @@
  */
 package org.apache.hyracks.util;
 
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
@@ -70,6 +71,12 @@
         }
 
         @Override
+        public boolean await(CountDownLatch latch) throws InterruptedException {
+            latch.await();
+            return true;
+        }
+
+        @Override
         public String toString() {
             return "<INFINITE>";
         }
@@ -143,6 +150,10 @@
         TimeUnit.NANOSECONDS.timedWait(monitor, remaining(TimeUnit.NANOSECONDS));
     }
 
+    public boolean await(CountDownLatch latch) throws InterruptedException {
+        return latch.await(remaining(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
+    }
+
     public void loopUntilExhausted(ThrowingAction action) throws Exception {
         loopUntilExhausted(action, 0, TimeUnit.NANOSECONDS);
     }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11803
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: cheshire-cat
Gerrit-Change-Id: Iae424fb99220630cb3a240cfef4cbba39b9da06b
Gerrit-Change-Number: 11803
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Blow <mblow@apache.org>
Gerrit-MessageType: newchange

Mime
View raw message