&& (isEqualityFn || encodingType.startsWith("U"))) { bb = newByteBuf(8, encodingType.endsWith("_BE")); bb.writeLong(((LongExpression) valueArg).getLong()); if (encodingType.endsWith("_OBD")) { org.apache.hadoop.hbase.util.OrderedBytes.encodeInt64(br, ((LongExpression) valueArg).getLong(), Order.DESCENDING); this.sortOrderAscending = false; } else { org.apache.hadoop.hbase.util.OrderedBytes.encodeInt64(br, ((LongExpression) valueArg).getLong(), Order.ASCENDING);
public static LogicalExpression getNumericExpression(String sign, String s, ExpressionPosition ep) { String numStr = (sign == null) ? s : sign+s; try { int a = Integer.parseInt(numStr); return new IntExpression(a, ep); } catch (Exception e) { } try { long l = Long.parseLong(numStr); return new LongExpression(l, ep); } catch (Exception e) { } try { double d = Double.parseDouble(numStr); return new DoubleExpression(d, ep); } catch (Exception e) { } throw new IllegalArgumentException(String.format("Unable to parse string %s as integer or floating point number.", numStr)); }
&& (isEqualityFn || encodingType.startsWith("U"))) { bb = newByteBuf(8, encodingType.endsWith("_BE")); bb.writeLong(((LongExpression) valueArg).getLong()); if (encodingType.endsWith("_OBD")) { org.apache.hadoop.hbase.util.OrderedBytes.encodeInt64(br, ((LongExpression) valueArg).getLong(), Order.DESCENDING); this.sortOrderAscending = false; } else { org.apache.hadoop.hbase.util.OrderedBytes.encodeInt64(br, ((LongExpression) valueArg).getLong(), Order.ASCENDING);
val = ((LongExpression) valueArg).getLong(); } else if (encodingType.compareTo("TIMESTAMP_EPOCH_BE") == 0) { if (!(valueArg instanceof TimeStampExpression)) {
this.value = KeyValueBuilder.initFrom(((LongExpression)valueArg).getLong()); this.path = path; return true;
newArgs.add(new ValueExpressions.IntExpression(type.getScale(), null)); } else if (!Types.isFixedWidthType(type)) { //VarLen type newArgs.add(new ValueExpressions.LongExpression(type.getPrecision(), null));
castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null));
private List<NamedExpression> getExpressionList() { if (popConfig.getExprs() != null) { return popConfig.getExprs(); } final List<NamedExpression> exprs = Lists.newArrayList(); for (final MaterializedField field : incoming.getSchema()) { String fieldName = field.getName(); if (Types.isComplex(field.getType()) || Types.isRepeated(field.getType())) { final LogicalExpression convertToJson = FunctionCallFactory.createConvert(ConvertExpression.CONVERT_TO, "JSON", SchemaPath.getSimplePath(fieldName), ExpressionPosition.UNKNOWN); final String castFuncName = FunctionReplacementUtils.getCastFunc(MinorType.VARCHAR); final List<LogicalExpression> castArgs = Lists.newArrayList(); castArgs.add(convertToJson); //input_expr // implicitly casting to varchar, since we don't know actual source length, cast to undefined length, which will preserve source length castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null)); final FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN); exprs.add(new NamedExpression(castCall, new FieldReference(fieldName))); } else { exprs.add(new NamedExpression(SchemaPath.getSimplePath(fieldName), new FieldReference(fieldName))); } } return exprs; }
/** * Defines function return type and sets cast length as type precision * if cast length is simple long expression. * * @param logicalExpressions logical expressions * @param attributes function attributes * @return return type */ @Override public TypeProtos.MajorType getType(List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) { TypeProtos.MajorType.Builder builder = TypeProtos.MajorType.newBuilder() .setMinorType(attributes.getReturnValue().getType().getMinorType()) .setMode(FunctionUtils.getReturnTypeDataMode(logicalExpressions, attributes)); LogicalExpression logicalExpression = logicalExpressions.get(1); if (logicalExpressions.get(1) instanceof ValueExpressions.LongExpression) { long precision = ((ValueExpressions.LongExpression) logicalExpression).getLong(); builder.setPrecision(Ints.checkedCast(precision)); } return builder.build(); } }
public static LogicalExpression getNumericExpression(String sign, String s, ExpressionPosition ep) { String numStr = (sign == null) ? s : sign+s; try { int a = Integer.parseInt(numStr); return new IntExpression(a, ep); } catch (Exception e) { } try { long l = Long.parseLong(numStr); return new LongExpression(l, ep); } catch (Exception e) { } try { double d = Double.parseDouble(numStr); return new DoubleExpression(d, ep); } catch (Exception e) { } throw new IllegalArgumentException(String.format("Unable to parse string %s as integer or floating point number.", numStr)); }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { DrillParseContext context = new DrillParseContext(PrelUtil.getSettings(getCluster())); List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { final int indexInConstants = i - fn.size(); if (i < fn.size()) { args.add(new FieldReference(fn.get(i))); } else { final RexLiteral constant = constants.get(indexInConstants); LogicalExpression expr = DrillOptiq.toDrill(context, getInput(), constant); args.add(expr); } } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1l)); } return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(new FieldReference(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1l)); } LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); return expr; } }
public static LogicalExpression getBigInt(long l){ return new LongExpression(l); }
@Override public Statistics<T> visitLongConstant(ValueExpressions.LongExpression expr, Void value) throws RuntimeException { return getStatistics(expr.getLong()); }
@Override public ValueHolder visitLongConstant(ValueExpressions.LongExpression intExpr, Integer value) throws RuntimeException { return ValueHolderHelper.getBigIntHolder(intExpr.getLong()); }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(FieldReference.getWithQuotedRef(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1L)); } return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); }
@Override public HoldingContainer visitLongConstant(LongExpression e, ClassGenerator<?> generator) throws RuntimeException { return getHoldingContainer( generator, e.getMajorType(), buffer -> ValueHolderHelper.getBigIntHolder(e.getLong())); }
@Override public Void visitLongConstant(LongExpression e, Void v) { ref.value = e.getLong(); return null; } }, null);
@Override public Void visitLongConstant(LongExpression lExpr, StringBuilder sb) throws RuntimeException { sb.append(lExpr.getLong()); return null; }