public FieldValue create() { return new LongFieldValue(); } }
private static FieldValue parseLong(String str) { if (str.endsWith("l") || str.endsWith("L")) { str = str.substring(0, str.length() - 1); } if (str.startsWith("0x")) { return new LongFieldValue(new BigInteger(str.substring(2), 16).longValue()); } else { return new LongFieldValue(new BigInteger(str).longValue()); } }
@Override public Serializer putLong(FieldBase field, long value) { singleValueTag(field, new LongFieldValue(value)); return this; }
public final FieldValue setFieldValue(Field field, Long value) { return setFieldValue(field, new LongFieldValue(value)); }
public final FieldValue setFieldValue(String field, Long value) { return setFieldValue(field, new LongFieldValue(value)); }
@Override protected void doExecute(ExecutionContext ctx) { ctx.setValue(new LongFieldValue(Long.valueOf(String.valueOf(ctx.getValue())))); }
@Override protected void doExecute(ExecutionContext ctx) { String input = String.valueOf(ctx.getValue()); if (input.isEmpty()) { ctx.setValue(new LongFieldValue(Long.MIN_VALUE)); return; } if (input.length() > 12) { throw new NumberFormatException("Base64 value '" + input + "' is out of range."); } byte[] decoded = Base64.decodeBase64(input); if (decoded == null || decoded.length == 0) { throw new NumberFormatException("Illegal base64 value '" + input + "'."); } long output = 0; for (int i = decoded.length; --i >= 0;) { output = (output << 8) + (((int)decoded[i]) & 0xff); } ctx.setValue(new LongFieldValue(output)); }
@Override protected void doExecute(ExecutionContext ctx) { String input = String.valueOf(ctx.getValue()); if (input.isEmpty()) { ctx.setValue(new LongFieldValue(Long.MIN_VALUE)); return; } BigInteger output; try { output = new BigInteger(input, 16); } catch (NumberFormatException e) { throw new NumberFormatException("Illegal hex value '" + input + "'."); } if (output.bitLength() > 64) { throw new NumberFormatException("Hex value '" + input + "' is out of range."); } if (output.compareTo(BigInteger.ZERO) == 1 && output.bitLength() == 64) { output = output.subtract(ULONG_MAX); // flip to negative } ctx.setValue(new LongFieldValue(output.longValue())); }
private FieldValue createFieldValue(FieldValue lhs, FieldValue rhs, BigDecimal val) { if (lhs instanceof FloatFieldValue || lhs instanceof DoubleFieldValue || rhs instanceof FloatFieldValue || rhs instanceof DoubleFieldValue) { if (lhs instanceof DoubleFieldValue || rhs instanceof DoubleFieldValue) { return new DoubleFieldValue(val.doubleValue()); } return new FloatFieldValue(val.floatValue()); } if (lhs instanceof LongFieldValue || rhs instanceof LongFieldValue) { return new LongFieldValue(val.longValue()); } return new IntegerFieldValue(val.intValue()); }
@Override protected void doExecute(ExecutionContext ctx) { ctx.setValue(new LongFieldValue(timer.currentTimeSeconds())); }
private Expression makeSetPredicateVariablesScript(BooleanIndexDefinition options) { List<Expression> expressions = new ArrayList<>(); expressions.add(new SetValueExpression(new IntegerFieldValue(options.getArity()))); expressions.add(new SetVarExpression("arity")); if (options.hasLowerBound()) { expressions.add(new SetValueExpression(new LongFieldValue(options.getLowerBound()))); expressions.add(new SetVarExpression("lower_bound")); } if (options.hasUpperBound()) { expressions.add(new SetValueExpression(new LongFieldValue(options.getUpperBound()))); expressions.add(new SetVarExpression("upper_bound")); } return new StatementExpression(expressions); }
@Override protected void doExecute(ExecutionContext ctx) { Struct input = ((Struct)ctx.getValue()); Integer x = getFieldValue(input, PositionDataType.FIELD_X); Integer y = getFieldValue(input, PositionDataType.FIELD_Y); if (x != null && y != null) { ctx.setValue(new LongFieldValue(ZCurve.encode(x, y))); } else { ctx.setValue(DataType.LONG.createFieldValue()); } }