Class ResultFetcher


  • public class ResultFetcher
    extends Object
    A fetcher to fetch result from submitted statement.

    The fetcher uses the Iterator model. It means every time fetch the result with the current token, the fetcher will move forward and retire the old data.

    After closes, the fetcher will not fetch the results from the remote but is able to return all data in the local cache.

    • Method Detail

      • fromTableResult

        public static ResultFetcher fromTableResult​(org.apache.flink.table.gateway.api.operation.OperationHandle operationHandle,
                                                    org.apache.flink.table.api.internal.TableResultInternal tableResult,
                                                    boolean isQueryResult)
      • fromResults

        public static ResultFetcher fromResults​(org.apache.flink.table.gateway.api.operation.OperationHandle operationHandle,
                                                org.apache.flink.table.catalog.ResolvedSchema resultSchema,
                                                List<org.apache.flink.table.data.RowData> results)
      • fromResults

        public static ResultFetcher fromResults​(org.apache.flink.table.gateway.api.operation.OperationHandle operationHandle,
                                                org.apache.flink.table.catalog.ResolvedSchema resultSchema,
                                                List<org.apache.flink.table.data.RowData> results,
                                                @Nullable
                                                org.apache.flink.api.common.JobID jobID,
                                                org.apache.flink.table.api.ResultKind resultKind)
      • withResourceManager

        public ResultFetcher withResourceManager​(org.apache.flink.table.resource.ResourceManager resourceManager)
      • close

        public void close()
      • getResultSchema

        public org.apache.flink.table.catalog.ResolvedSchema getResultSchema()
      • isQueryResult

        public boolean isQueryResult()
      • getPrintStyle

        public org.apache.flink.table.utils.print.PrintStyle getPrintStyle()
      • getConverter

        @VisibleForTesting
        public org.apache.flink.table.utils.print.RowDataToStringConverter getConverter()
      • fetchResults

        public org.apache.flink.table.gateway.api.results.ResultSet fetchResults​(org.apache.flink.table.gateway.api.results.FetchOrientation orientation,
                                                                                 int maxFetchSize)
      • fetchResults

        public org.apache.flink.table.gateway.api.results.ResultSet fetchResults​(long token,
                                                                                 int maxFetchSize)
        Fetch results from the result store. It tries to return the data cached in the buffer first. If the buffer is empty, then fetch results from the ResultStore. It's possible multiple threads try to fetch results in parallel. To keep the data integration, use the synchronized to allow only one thread can fetch the result at any time.
      • getResultStore

        @VisibleForTesting
        public ResultStore getResultStore()