@Override public int getDisplaySize() { return MathUtils.convertLongToInt(value.length * 2L); }
int getPrecisionAsInt() { return MathUtils.convertLongToInt(precision); }
public void setLobBlockSize(long blockSize) { this.lobBlockSize = MathUtils.convertLongToInt(blockSize); }
@Override public int getDisplaySize() { long size = 0; for (Value v : values) { size += v.getDisplaySize(); } return MathUtils.convertLongToInt(size); }
public synchronized void setCacheSize(int kb) { if (starting) { int max = MathUtils.convertLongToInt(Utils.getMemoryMax()) / 2; kb = Math.min(kb, max); } cacheSize = kb; }
@Override public Value convertPrecision(long precision, boolean force) { if (value.length <= precision) { return this; } int len = MathUtils.convertLongToInt(precision); byte[] buff = new byte[len]; System.arraycopy(value, 0, buff, 0, len); return get(buff); }
@Override public int getDisplaySize() { // add 2 characters for '-' and '.' return MathUtils.convertLongToInt(getPrecision() + 2); }
@Override public Value convertPrecision(long precision, boolean force) { if (precision == 0 || value.length() <= precision) { return this; } int p = MathUtils.convertLongToInt(precision); return getNew(value.substring(0, p)); }
@Override public int getDisplaySize() { return MathUtils.convertLongToInt(getPrecision()); }
/** * Returns the value as a String. * * @param columnIndex (1,2,...) * @return the value */ @Override public String getString(int columnIndex) throws SQLException { Object o = get(columnIndex); if (o == null) { return null; } switch (columns.get(columnIndex - 1).sqlType) { case Types.CLOB: Clob c = (Clob) o; return c.getSubString(1, MathUtils.convertLongToInt(c.length())); } return o.toString(); }
private static int getBufferSize(DataHandler handler, boolean compress, long remaining) { if (remaining < 0 || remaining > Integer.MAX_VALUE) { remaining = Integer.MAX_VALUE; } int inplace = handler.getMaxLengthInplaceLob(); long m = compress ? Constants.IO_BUFFER_SIZE_COMPRESS : Constants.IO_BUFFER_SIZE; if (m < remaining && m <= inplace) { // using "1L" to force long arithmetic because // inplace could be Integer.MAX_VALUE m = Math.min(remaining, inplace + 1L); // the buffer size must be bigger than the inplace lob, otherwise we // can't know if it must be stored in-place or not m = MathUtils.roundUpLong(m, Constants.IO_BUFFER_SIZE); } m = Math.min(remaining, m); m = MathUtils.convertLongToInt(m); if (m < 0) { m = Integer.MAX_VALUE; } return (int) m; }
@Override public int getDisplaySize() { if (right != null) { switch (opType) { case CONCAT: return MathUtils.convertLongToInt((long) left.getDisplaySize() + (long) right.getDisplaySize()); default: return Math.max(left.getDisplaySize(), right.getDisplaySize()); } } return left.getDisplaySize(); }
/** * Returns the parameter precision. * The value 0 is returned if the precision is not known. * * @param param the column index (1,2,...) * @return the precision */ @Override public int getPrecision(int param) throws SQLException { try { debugCodeCall("getPrecision", param); CommandParameter p = getParameter(param); return MathUtils.convertLongToInt(p.getPrecision()); } catch (Exception e) { throw logAndConvert(e); } }
private void rebuildIndexBuffered(ServerSession session, Index index) { Index scan = getScanIndex(session); long remaining = scan.getRowCount(session); long total = remaining; Cursor cursor = scan.find(session, null, null); long i = 0; int bufferSize = (int) Math.min(total, database.getMaxMemoryRows()); ArrayList<Row> buffer = new ArrayList<>(bufferSize); String n = getName() + ":" + index.getName(); int t = MathUtils.convertLongToInt(total); while (cursor.next()) { Row row = cursor.get(); buffer.add(row); database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n, MathUtils.convertLongToInt(i++), t); if (buffer.size() >= bufferSize) { addRowsToIndex(session, buffer, index); } remaining--; } addRowsToIndex(session, buffer, index); if (SysProperties.CHECK && remaining != 0) { DbException.throwInternalError("rowcount remaining=" + remaining + " " + getName()); } }
/** * Gets the precision for this column. * This method always returns 0. * * @param column the column index (1,2,...) * @return the precision * @throws SQLException if the result set is closed or invalid */ @Override public int getPrecision(int column) throws SQLException { try { debugCodeCall("getPrecision", column); checkColumnIndex(column); long prec = result.getColumnPrecision(--column); return MathUtils.convertLongToInt(prec); } catch (Exception e) { throw logAndConvert(e); } }
if (handler == null) { try { int p = MathUtils.convertLongToInt(precision); String s = IOUtils.readStringAndClose(getReader(), p); byte[] data = s.getBytes(Constants.UTF8); if (handler == null) { try { int p = MathUtils.convertLongToInt(precision); byte[] data = IOUtils.readBytesAndClose(getInputStream(), p); lob = ValueLob.createSmallLob(type, data, data.length);
for (Expression e : args) { precision += e.getPrecision(); displaySize = MathUtils.convertLongToInt((long) displaySize + e.getDisplaySize()); if (precision < 0) { precision = Long.MAX_VALUE; case HEXTORAW: precision = (args[0].getPrecision() + 3) / 4; displaySize = MathUtils.convertLongToInt(precision); break; case LCASE: case RAWTOHEX: precision = args[0].getPrecision() * 4; displaySize = MathUtils.convertLongToInt(precision); break; case SOUNDEX:
ArrayList<Row> buffer = new ArrayList<>(bufferSize); String n = getName() + ":" + index.getName(); int t = MathUtils.convertLongToInt(total); ArrayList<String> bufferNames = Utils.newSmallArrayList(); while (cursor.next()) { Row row = cursor.get(); buffer.add(row); database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n, MathUtils.convertLongToInt(i++), t); if (buffer.size() >= bufferSize) { sortRows(buffer, index);
public ResultSet getResultSet() { SimpleResultSet rs = new SimpleResultSet(); rs.addColumn("X", DataType.convertTypeToSQLType(getType()), MathUtils.convertLongToInt(getPrecision()), getScale()); rs.addRow(getObject()); return rs; }
private static SimpleResultSet getSimpleResultSet(Result rs, int maxRows) { int columnCount = rs.getVisibleColumnCount(); SimpleResultSet simple = new SimpleResultSet(); for (int i = 0; i < columnCount; i++) { String name = rs.getColumnName(i); int sqlType = DataType.convertTypeToSQLType(rs.getColumnType(i)); int precision = MathUtils.convertLongToInt(rs.getColumnPrecision(i)); int scale = rs.getColumnScale(i); simple.addColumn(name, sqlType, precision, scale); } rs.reset(); for (int i = 0; i < maxRows && rs.next(); i++) { Object[] list = new Object[columnCount]; for (int j = 0; j < columnCount; j++) { list[j] = rs.currentRow()[j].getObject(); } simple.addRow(list); } return simple; }