MCPcopy Create free account
hub / github.com/apache/impala / setKey

Method setKey

fe/src/main/java/org/apache/impala/util/KuduUtil.java:159–212  ·  view source on GitHub ↗

Sets the value 'boundaryVal' in 'key' at 'pos'. Checks if 'boundaryVal' has the expected data type.

(ColumnSchema col, TExpr boundaryVal, int pos, PartialRow key)

Source from the content-addressed store, hash-verified

157 * expected data type.
158 */
159 private static void setKey(ColumnSchema col, TExpr boundaryVal, int pos, PartialRow key)
160 throws ImpalaRuntimeException {
161 Preconditions.checkState(boundaryVal.getNodes().size() == 1);
162 TExprNode literal = boundaryVal.getNodes().get(0);
163 String colName = col.getName();
164 org.apache.kudu.Type type = col.getType();
165 String strLiteral;
166 switch (type) {
167 case INT8:
168 checkCorrectType(literal.isSetInt_literal(), type, colName, literal);
169 key.addByte(pos, (byte) literal.getInt_literal().getValue());
170 break;
171 case INT16:
172 checkCorrectType(literal.isSetInt_literal(), type, colName, literal);
173 key.addShort(pos, (short) literal.getInt_literal().getValue());
174 break;
175 case INT32:
176 checkCorrectType(literal.isSetInt_literal(), type, colName, literal);
177 key.addInt(pos, (int) literal.getInt_literal().getValue());
178 break;
179 case INT64:
180 checkCorrectType(literal.isSetInt_literal(), type, colName, literal);
181 key.addLong(pos, literal.getInt_literal().getValue());
182 break;
183 case VARCHAR:
184 checkCorrectType(literal.isSetString_literal(), type, colName, literal);
185 key.addVarchar(pos,
186 StringUtils.fromUtf8Buffer(literal.getString_literal().value, false));
187 break;
188 case STRING:
189 checkCorrectType(literal.isSetString_literal(), type, colName, literal);
190 key.addString(pos,
191 StringUtils.fromUtf8Buffer(literal.getString_literal().value, false));
192 break;
193 case UNIXTIME_MICROS:
194 checkCorrectType(literal.isSetInt_literal(), type, colName, literal);
195 key.addLong(pos, literal.getInt_literal().getValue());
196 break;
197 case DATE:
198 checkCorrectType(literal.isSetDate_literal(), type, colName, literal);
199 key.addDate(pos, Date.valueOf(LocalDate.ofEpochDay(
200 literal.getDate_literal().getDays_since_epoch())));
201 break;
202 case DECIMAL:
203 checkCorrectType(literal.isSetDecimal_literal(), type, colName, literal);
204 BigInteger unscaledVal = new BigInteger(literal.getDecimal_literal().getValue());
205 int scale = col.getTypeAttributes().getScale();
206 key.addDecimal(pos, new BigDecimal(unscaledVal, scale));
207 break;
208 default:
209 throw new ImpalaRuntimeException("Key columns not supported for type: "
210 + type.toString());
211 }
212 }
213
214 /**
215 * Returns the actual value of the specified defaultValue literal. The returned type is

Callers 2

toThriftMethod · 0.80

Calls 8

checkCorrectTypeMethod · 0.95
fromUtf8BufferMethod · 0.95
getMethod · 0.65
getNameMethod · 0.65
getTypeMethod · 0.65
sizeMethod · 0.45
getValueMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected