Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.connector.system;
 
 
 
 import static com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
 import static com.facebook.presto.spi.type.BigintType.BIGINT;
 import static com.facebook.presto.spi.type.TimestampType.TIMESTAMP;
 import static com.facebook.presto.spi.type.VarcharType.VARCHAR;
 
 public class QuerySystemTable
         implements SystemTable
 {
     public static final SchemaTableName QUERY_TABLE_NAME = new SchemaTableName("runtime""queries");
 
             .column("node_id")
             .column("query_id")
             .column("state")
             .column("user")
             .column("source")
             .column("query")
 
             .column("queued_time_ms")
             .column("analysis_time_ms")
             .column("distributed_planning_time_ms")
 
             .column("created")
             .column("started")
             .column("last_heartbeat")
             .column("end")
             .build();
 
     private final QueryManager queryManager;
     private final String nodeId;
 
     @Inject
     public QuerySystemTable(QueryManager queryManagerNodeInfo nodeInfo)
     {
         this. = queryManager;
         this. = nodeInfo.getNodeId();
     }
 
     @Override
     public boolean isDistributed()
     {
         return true;
     }
 
     @Override
     {
         return ;
     }
 
     @Override
     public RecordCursor cursor()
     {
         Builder table = InMemoryRecordSet.builder();
         for (QueryInfo queryInfo : .getAllQueryInfo()) {
             QueryStats queryStats = queryInfo.getQueryStats();
             table.addRow(
                     ,
                     queryInfo.getQueryId().toString(),
                     queryInfo.getState().toString(),
                     queryInfo.getSession().getUser(),
                     queryInfo.getSession().getSource(),
                     queryInfo.getQuery(),
 
                     toMillis(queryStats.getQueuedTime()),
                     toMillis(queryStats.getAnalysisTime()),
                     toMillis(queryStats.getDistributedPlanningTime()),
 
                     toTimeStamp(queryStats.getCreateTime()),
                    toTimeStamp(queryStats.getExecutionStartTime()),
                    toTimeStamp(queryStats.getLastHeartbeat()),
                    toTimeStamp(queryStats.getEndTime()));
        }
        return table.build().cursor();
    }
    private static Long toMillis(Duration duration)
    {
        if (duration == null) {
            return null;
        }
        return duration.toMillis();
    }
    private static Long toTimeStamp(DateTime dateTime)
    {
        if (dateTime == null) {
            return null;
        }
        return dateTime.getMillis();
    }
New to GrepCode? Check out our FAQ X