forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#9176] Add executeAsync API to WrappedPinotConnection
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...dule/metric/src/main/java/com/navercorp/pinpoint/metric/common/pinot/ResultSetFuture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.navercorp.pinpoint.metric.common.pinot; | ||
|
||
import org.apache.pinot.client.PinotResultSet; | ||
import org.apache.pinot.client.ResultSetGroup; | ||
|
||
import java.sql.ResultSet; | ||
import java.util.Objects; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
public class ResultSetFuture implements Future<ResultSet> { | ||
private final Future<ResultSetGroup> resultSetGroupFuture; | ||
|
||
public ResultSetFuture(Future<ResultSetGroup> resultSetGroupFuture) { | ||
this.resultSetGroupFuture = Objects.requireNonNull(resultSetGroupFuture, "resultSetGroupFuture"); | ||
} | ||
|
||
@Override | ||
public boolean cancel(boolean mayInterruptIfRunning) { | ||
return this.resultSetGroupFuture.cancel(mayInterruptIfRunning); | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return this.resultSetGroupFuture.isCancelled(); | ||
} | ||
|
||
@Override | ||
public boolean isDone() { | ||
return this.resultSetGroupFuture.isDone(); | ||
} | ||
|
||
@Override | ||
public ResultSet get() throws InterruptedException, ExecutionException { | ||
ResultSetGroup resultSetGroup = this.resultSetGroupFuture.get(); | ||
return toResultSet(resultSetGroup); | ||
} | ||
|
||
@Override | ||
public ResultSet get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { | ||
ResultSetGroup resultSetGroup = this.resultSetGroupFuture.get(timeout, unit); | ||
return toResultSet(resultSetGroup); | ||
} | ||
|
||
private static PinotResultSet toResultSet(ResultSetGroup resultSetGroup) { | ||
if (resultSetGroup == null) { | ||
// return null or empty?? | ||
return PinotResultSet.empty(); | ||
} | ||
if (resultSetGroup.getResultSetCount() == 0) { | ||
return PinotResultSet.empty(); | ||
} | ||
return new PinotResultSet(resultSetGroup.getResultSet(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters