Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TResultRowBuilder.java
Go to the documentation of this file.
1 // Copyright 2012 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 
18 import com.cloudera.impala.thrift.TColumnValue;
19 import com.cloudera.impala.thrift.TResultRow;
20 
24 public class TResultRowBuilder {
25  private final TResultRow row_ = new TResultRow();
26 
27  public TResultRowBuilder add(long val) {
28  TColumnValue colVal = new TColumnValue();
29  colVal.setLong_val(val);
30  row_.addToColVals(colVal);
31  return this;
32  }
33 
34  public TResultRowBuilder add(double val) {
35  TColumnValue colVal = new TColumnValue();
36  colVal.setDouble_val(val);
37  row_.addToColVals(colVal);
38  return this;
39  }
40 
41  public TResultRowBuilder add(String val) {
42  TColumnValue colVal = new TColumnValue();
43  colVal.setString_val(val);
44  row_.addToColVals(colVal);
45  return this;
46  }
47 
48  public TResultRowBuilder addBytes(long val) {
49  TColumnValue colVal = new TColumnValue();
50  colVal.setString_val(PrintUtils.printBytes(val));
51  row_.addToColVals(colVal);
52  return this;
53  }
54 
56  row_.clear();
57  return this;
58  }
59 
60  public TResultRow get() { return row_; }
61 }