@Override public void setValue(int i, Value v) { if (i == -1) { this.key = v.getLong(); } else { data[i] = v; } }
/** * Calculate and get the end value of this range. * * @param session the session * @return the end value */ public long getMax(Session 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(); }
private Long getLong(Expression expr) { if (expr == null) { return null; } return expr.optimize(session).getValue(session).getLong(); }
@Override public Row get() { if (row == null) { if (current != null) { ValueArray array = (ValueArray) current.getValue(); row = session.createRow(array.getList(), 0); row.setKey(current.getKey().getLong()); } } return row; }
/** * Calculate and get the start value of this range. * * @param session the session * @return the start value */ public long getMin(Session session) { optimize(session); return min.getValue(session).getLong(); }
/** * Get the increment. * * @param session the session * @return the increment (1 by default) */ public long getStep(Session session) { optimize(session); if (step == null) { return 1; } return step.getValue(session).getLong(); }
/** * @param val Value. */ public GridH2Long(Value val) { assert val.getType() == Value.LONG : val.getType(); x = val.getLong(); }
/** * Get the key from the row. * * @param row the row * @param ifEmpty the value to use if the row is empty * @param ifNull the value to use if the column is NULL * @return the key */ long getKey(SearchRow row, long ifEmpty, long ifNull) { if (row == null) { return ifEmpty; } Value v = row.getValue(mainIndexColumn); if (v == null) { throw DbException.throwInternalError(row.toString()); } else if (v == ValueNull.INSTANCE) { return ifNull; } return v.getLong(); }
@Override public Cursor find(Session session, SearchRow first, SearchRow last) { long min = rangeTable.getMin(session), start = min; long max = rangeTable.getMax(session), end = max; long step = rangeTable.getStep(session); 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(session, start, end, step); }
/** * 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); } }
/** * 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); } }
private SearchRow getSearchRow(SearchRow row, int columnId, Value v, boolean max) { if (row == null) { row = table.getTemplateRow(); } else { v = getMax(row.getValue(columnId), v, max); } if (columnId < 0) { row.setKey(v.getLong()); } else { row.setValue(columnId, v); } 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(Session 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); } } }
/** * Convert array of values to a SearchRow. * * @param key the index key * @return the row */ SearchRow convertToSearchRow(ValueArray key) { Value[] array = key.getList(); SearchRow searchRow = mvTable.getTemplateRow(); searchRow.setKey((array[array.length - 1]).getLong()); Column[] cols = getColumns(); for (int i = 0; i < array.length - 1; i++) { Column c = cols[i]; int idx = c.getColumnId(); Value v = array[i]; searchRow.setValue(idx, v); } return searchRow; }
private SearchRow getSpatialSearchRow(SearchRow row, int columnId, Value v) { if (row == null) { row = table.getTemplateRow(); } else if (row.getValue(columnId) != null) { // if an object needs to overlap with both a and b, // then it needs to overlap with the the union of a and b // (not the intersection) ValueGeometry vg = (ValueGeometry) row.getValue(columnId). convertTo(Value.GEOMETRY); v = ((ValueGeometry) v.convertTo(Value.GEOMETRY)). getEnvelopeUnion(vg); } if (columnId < 0) { row.setKey(v.getLong()); } else { row.setValue(columnId, v); } return row; }
public MVPrimaryIndex(Database db, MVTable table, int id, IndexColumn[] columns, IndexType indexType) { this.mvTable = table; initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType); int[] sortTypes = new int[columns.length]; for (int i = 0; i < columns.length; i++) { sortTypes[i] = SortOrder.ASCENDING; } ValueDataType keyType = new ValueDataType(null, null, null); ValueDataType valueType = new ValueDataType(db.getCompareMode(), db, sortTypes); mapName = "table." + getId(); Transaction t = mvTable.getTransactionBegin(); dataMap = t.openMap(mapName, keyType, valueType); t.commit(); if (!table.isPersistData()) { dataMap.map.setVolatile(true); } Value k = dataMap.map.lastKey(); // include uncommitted keys as well lastKey.set(k == null ? 0 : k.getLong()); }
long c = row.getValue(mainIndexColumn).getLong(); row.setKey(c);
long size = cacheSize.optimize(session).getValue(session).getLong(); sequence.setCacheSize(size);