public Value[] getValueListWithVersion() { int len = data.length; Value[] d2 = new Value[len + 1]; System.arraycopy(data, 0, d2, 0, len); d2[len] = ValueInt.get(version); return d2; }
/** * Get or create an int value for the given int. * * @param i the int * @return the value */ public static ValueInt get(int i) { if (i >= 0 && i < STATIC_SIZE) { return STATIC_CACHE[i]; } ValueInt v = DYNAMIC_CACHE[i & (DYNAMIC_SIZE - 1)]; if (v == null || v.value != i) { v = new ValueInt(i); DYNAMIC_CACHE[i & (DYNAMIC_SIZE - 1)] = v; } return v; }
@Override public Value multiply(Value v) { ValueInt other = (ValueInt) v; return checkRange((long) value * (long) other.value); }
public int getInt() { return ((ValueInt) convertTo(Value.INT)).getInt(); }
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case INT: return ValueInt.get(DataUtils.readVarInt(buff)); case TAG_INTEGER_NEGATIVE: return ValueInt.get(-DataUtils.readVarInt(buff)); case TAG_INTEGER_FIXED: return ValueInt.get(buff.getInt()); } return ValueInt.get(tag - TAG_INTEGER_0_15); }
@Override public Value add(Value v) { ValueInt other = (ValueInt) v; return checkRange((long) value + (long) other.value); }
private static ValueInt checkRange(long x) { if (x < Integer.MIN_VALUE || x > Integer.MAX_VALUE) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Long.toString(x)); } return ValueInt.get((int) x); }
@Override public Value subtract(Value v) { ValueInt other = (ValueInt) v; return checkRange((long) value - (long) other.value); }
@Override public Value getValue(ServerSession session) { return ValueInt.get(prepared.getCurrentRowNumber()); }
@Override public Value negate() { return checkRange(-(long) value); }
public void setInt(int value) { this.expression = ValueExpression.get(ValueInt.get(value)); }
@Override Value getValue(Database database, int dataType, boolean distinct) { if (distinct) { count = 0; } Value v = null; int s = 0; if (count == 0) { s = 0; } else { m2 += distinctHashes.size(); m2 = 100 * m2 / count; s = (int) m2; s = s <= 0 ? 1 : s > 100 ? 100 : s; } v = ValueInt.get(s); return v.convertTo(dataType); }
private Cursor getMetaCursor(ServerSession session, int id) { SearchRow r = meta.getTemplateSimpleRow(false); r.setValue(0, ValueInt.get(id)); return metaIdIndex.find(session, r, r); }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateInt(int columnIndex, int x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateInt(" + columnIndex + ", " + x + ");"); } update(columnIndex, ValueInt.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setInt(int parameterIndex, int x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setInt(" + parameterIndex + ", " + x + ");"); } setParameter(parameterIndex, ValueInt.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ public void setQueryTimeout(int seconds) throws SQLException { try { debugCodeCall("setQueryTimeout", seconds); checkClosed(); setQueryTimeout = prepareCommand("SET QUERY_TIMEOUT ?", setQueryTimeout); setQueryTimeout.getParameters().get(0).setValue(ValueInt.get(seconds * 1000), false); setQueryTimeout.executeUpdate(); queryTimeoutCache = seconds; } catch (Exception e) { throw logAndConvert(e); } }