Java Code Examples for org.apache.flink.table.client.gateway.TypedResult#empty()

The following examples show how to use org.apache.flink.table.client.gateway.TypedResult#empty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterializedCollectBatchResult.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public TypedResult<Integer> snapshot(int pageSize) {
	synchronized (resultLock) {
		// wait for a result
		if (retrievalThread.isAlive() && null == resultTable) {
			return TypedResult.empty();
		}
		// the job finished with an exception
		else if (executionException != null) {
			throw executionException;
		}
		// we return a payload result the first time and EoS for the rest of times as if the results
		// are retrieved dynamically
		else if (!snapshotted) {
			snapshotted = true;
			this.pageSize = pageSize;
			pageCount = Math.max(1, (int) Math.ceil(((double) resultTable.size() / pageSize)));
			return TypedResult.payload(pageCount);
		} else {
			return TypedResult.endOfStream();
		}
	}
}
 
Example 2
Source File: MaterializedCollectBatchResult.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public TypedResult<Integer> snapshot(int pageSize) {
	synchronized (resultLock) {
		// wait for a result
		if (retrievalThread.isAlive() && null == resultTable) {
			return TypedResult.empty();
		}
		// the job finished with an exception
		else if (executionException != null) {
			throw executionException;
		}
		// we return a payload result the first time and EoS for the rest of times as if the results
		// are retrieved dynamically
		else if (!snapshotted) {
			snapshotted = true;
			this.pageSize = pageSize;
			pageCount = Math.max(1, (int) Math.ceil(((double) resultTable.size() / pageSize)));
			return TypedResult.payload(pageCount);
		} else {
			return TypedResult.endOfStream();
		}
	}
}
 
Example 3
Source File: MaterializedCollectBatchResult.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public TypedResult<Integer> snapshot(int pageSize) {
	synchronized (resultLock) {
		// the job finished with an exception
		SqlExecutionException e = executionException.get();
		if (e != null) {
			throw e;
		}

		// wait for a result
		if (null == resultTable) {
			return TypedResult.empty();
		}
		// we return a payload result the first time and EoS for the rest of times as if the results
		// are retrieved dynamically
		else if (!snapshotted) {
			snapshotted = true;
			this.pageSize = pageSize;
			pageCount = Math.max(1, (int) Math.ceil(((double) resultTable.size() / pageSize)));
			return TypedResult.payload(pageCount);
		} else {
			return TypedResult.endOfStream();
		}
	}
}
 
Example 4
Source File: CollectStreamResult.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected <T> TypedResult<T> handleMissingResult() {
	// check if the monitoring thread is still there
	// we need to wait until we know what is going on
	if (monitoringThread.isAlive()) {
		return TypedResult.empty();
	}
	// the job finished with an exception
	else if (executionException != null) {
		throw executionException;
	}
	// we assume that a bounded job finished
	else {
		return TypedResult.endOfStream();
	}
}
 
Example 5
Source File: CollectStreamResult.java    From flink with Apache License 2.0 5 votes vote down vote up
protected <T> TypedResult<T> handleMissingResult() {
	// check if the monitoring thread is still there
	// we need to wait until we know what is going on
	if (monitoringThread.isAlive()) {
		return TypedResult.empty();
	}
	// the job finished with an exception
	else if (executionException != null) {
		throw executionException;
	}
	// we assume that a bounded job finished
	else {
		return TypedResult.endOfStream();
	}
}
 
Example 6
Source File: CollectStreamResult.java    From flink with Apache License 2.0 5 votes vote down vote up
protected <T> TypedResult<T> handleMissingResult() {

		// check if the monitoring thread is still there
		// we need to wait until we know what is going on
		if (!jobExecutionResultFuture.isDone()) {
			return TypedResult.empty();
		}

		if (executionException.get() != null) {
			throw executionException.get();
		}

		// we assume that a bounded job finished
		return TypedResult.endOfStream();
	}