Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MaxRowsProcessedVisitor.java
Go to the documentation of this file.
1 // Copyright 2014 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.util;
16 
21 
25 public class MaxRowsProcessedVisitor implements Visitor<PlanNode> {
26 
27  private boolean abort_ = false;
28  private long result_ = -1l;
29 
30  @Override
31  public void visit(PlanNode caller) {
32  if (abort_) return;
33 
34  if (caller instanceof ScanNode) {
35  long tmp = caller.getInputCardinality();
36  ScanNode scan = (ScanNode) caller;
37  if (scan.isTableMissingTableStats() && !scan.hasLimit()) {
38  abort_ = true;
39  return;
40  }
41  result_ = Math.max(result_, tmp);
42  } else if (caller instanceof HashJoinNode || caller instanceof CrossJoinNode) {
43  // Revisit when multiple scan nodes can be executed in a single fragment, IMPALA-561
44  abort_ = true;
45  return;
46  } else {
47  long in = caller.getInputCardinality();
48  long out = caller.getCardinality();
49  if ((in == -1) || (out == -1)) {
50  abort_ = true;
51  return;
52  }
53  result_ = Math.max(result_, Math.max(in, out));
54  }
55  }
56 
57  public long get() {
58  return abort_ ? -1 : result_;
59  }
60 }