@Override public void setValue(int i, Value v, Column c) { if (i == -1) { this.key = v.getLong(); } else { data[i] = v; } }
@Override void merge(Database database, int dataType, boolean distinct, Value v) { count += v.getLong(); }
@Override void merge(Database database, int dataType, boolean distinct, Value v) { count += v.getLong(); }
@Override public boolean next() { current = it.hasNext() ? it.next() : null; if (current != null && current.getKey().getLong() > last.getLong()) { current = null; } row = null; return current != null; }
@Override public void writeValue(DataBuffer buff, Value v) { long x = v.getLong(); write0(buff, x); }
/** * Calculate and get the start value of this range. * * @param session the session * @return the start value */ public long getMin(ServerSession session) { optimize(session); return min.getValue(session).getLong(); }
/** * Calculate and get the end value of this range. * * @param session the session * @return the end value */ public long getMax(ServerSession session) { optimize(session); return max.getValue(session).getLong(); }
private Long getLong(Expression expr) { if (expr == null) { return null; } return expr.optimize(session).getValue(session).getLong(); }
/** * Get the increment. * * @param session the session * @return the increment (1 by default) */ public long getStep(ServerSession session) { optimize(session); if (step == null) { return 1; } return step.getValue(session).getLong(); }
private Long getLong(Expression expr) { if (expr == null) { return null; } return expr.optimize(session).getValue(session).getLong(); }
@Override public Cursor find(ServerSession session, SearchRow first, SearchRow last) { long min = rangeTable.getMin(session), start = min; long max = rangeTable.getMax(session), end = max; try { start = Math.max(min, first == null ? min : first.getValue(0).getLong()); } catch (Exception e) { // error when converting the value - ignore } try { end = Math.min(max, last == null ? max : last.getValue(0).getLong()); } catch (Exception e) { // error when converting the value - ignore } return new RangeCursor(start, end); }
/** * Returns the value of the specified column as a long. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public long getLong(int columnIndex) throws SQLException { try { debugCodeCall("getLong", columnIndex); return get(columnIndex).getLong(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a long. * * @param columnLabel the column label * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public long getLong(String columnLabel) throws SQLException { try { debugCodeCall("getLong", columnLabel); return get(columnLabel).getLong(); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Row get() { Row row = new Row(result.currentRow(), 0); row.setKey(row.getValue(0).getLong()); return row; }
private SearchRow getSearchRow(ServerSession session, Column column, SearchRow row, int id, Value v, boolean max) { if (row == null) { row = table.getTemplateRow(); } else { v = getMax(session, row.getValue(id), v, max); } if (id < 0) { row.setKey(v.getLong()); } else { row.setValue(id, v, column); } return row; }
private long readLong() { boolean minus = false; if (currentTokenType == MINUS) { minus = true; read(); } else if (currentTokenType == PLUS) { read(); } if (currentTokenType != VALUE) { throw DbException.getSyntaxError(sqlCommand, parseIndex, "long"); } if (minus) { // must do that now, otherwise Long.MIN_VALUE would not work currentValue = currentValue.negate(); } long i = currentValue.getLong(); read(); return i; }
private void updateSequenceIfRequired(ServerSession session, Value value) { if (sequence != null) { long current = sequence.getCurrentValue(); long inc = sequence.getIncrement(); long now = value.getLong(); boolean update = false; if (inc > 0 && now > current) { update = true; } else if (inc < 0 && now < current) { update = true; } if (update) { sequence.modify(now + inc, null, null, null); session.setLastIdentity(ValueLong.get(now)); sequence.flush(session, 0); } } }
@Override public Row get() { if (row == null) { if (current != null) { VersionedValue value = current.getValue(); Value[] data = value.value.getList(); int version = value.vertion; row = new Row(data, 0); row.setKey(current.getKey().getLong()); row.setVersion(version); if (table.getVersion() != version) { ArrayList<TableAlterHistoryRecord> records = table.getDatabase() .getTableAlterHistoryRecord(table.getId(), version, table.getVersion()); Value[] newValues = data; for (TableAlterHistoryRecord record : records) { newValues = record.redo(session, newValues); } if (newValues != data) { index.remove(session, row); row = new Row(newValues, 0); row.setKey(current.getKey().getLong()); row.setVersion(table.getVersion()); index.add(session, row); } } } } return row; }
/** * Convert array of values to a SearchRow. * * @param array the index key * @return the row */ SearchRow convertToSearchRow(ValueArray key) { Value[] array = key.getList(); int len = array.length - 1; SearchRow searchRow = table.getTemplateRow(); searchRow.setKey((array[len]).getLong()); Column[] cols = getColumns(); for (int i = 0; i < len; i++) { Column c = cols[i]; int idx = c.getColumnId(); Value v = array[i]; searchRow.setValue(idx, v); } return searchRow; }
long size = cacheSize.optimize(session).getValue(session).getLong(); sequence.setCacheSize(size);