@Override public Value copy(DataHandler database, int tableId) { if (small == null) { return handler.getLobStorage().copyLob(this, tableId, getPrecision()); } else if (small.length > database.getMaxLengthInplaceLob()) { LobStorageInterface s = database.getLobStorage(); Value v; if (type == Value.BLOB) { v = s.createBlob(getInputStream(), getPrecision()); } else { v = s.createClob(getReader(), getPrecision()); } Value v2 = v.copy(database, tableId); v.remove(); return v2; } return this; }
@Override public InputStream getInputStream() { if (small != null) { return new ByteArrayInputStream(small); } else if (fileName != null) { FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; return new BufferedInputStream(new FileStoreInputStream(store, handler, false, alwaysClose), Constants.IO_BUFFER_SIZE); } long byteCount = (type == Value.BLOB) ? precision : -1; try { return handler.getLobStorage().getInputStream(this, hmac, byteCount); } catch (IOException e) { throw DbException.convertIOException(e, toString()); } }
/** * Create an independent copy of this value, * that will be bound to a result. * * @return the value (this for small objects) */ @Override public ValueLobDb copyToResult() { if (handler == null) { return this; } LobStorageInterface s = handler.getLobStorage(); if (s.isReadOnly()) { return this; } return s.copyLob(this, LobStorageFrontend.TABLE_RESULT, getPrecision()); }
if (handler != null) { return handler.getLobStorage(). createClob(getReader(), -1); } else if (small != null) { return ValueLobDb.createSmallLob(t, small); if (handler != null) { return handler.getLobStorage(). createBlob(getInputStream(), -1); } else if (small != null) { return ValueLobDb.createSmallLob(t, small);
private void removeOrphanedLobs() { // remove all session variables and temporary lobs if (!persistent) { return; } boolean lobStorageIsUsed = infoSchema.findTableOrView( systemSession, LobStorageBackend.LOB_DATA_TABLE) != null; lobStorageIsUsed |= mvStore != null; if (!lobStorageIsUsed) { return; } try { getLobStorage(); lobStorage.removeAllForTable( LobStorageFrontend.TABLE_ID_SESSION_VARIABLE); } catch (DbException e) { trace.error(e, "close"); } }
/** * Create a Clob value from this reader. * * @param x the reader * @param length the length (if smaller or equal than 0, all data until the * end of file is read) * @return the value */ public Value createClob(Reader x, long length) { if (x == null) { return ValueNull.INSTANCE; } if (length <= 0) { length = -1; } Value v = session.getDataHandler().getLobStorage().createClob(x, length); session.addTemporaryLob(v); return v; }
/** * Create a Blob value from this input stream. * * @param x the input stream * @param length the length (if smaller or equal than 0, all data until the * end of file is read) * @return the value */ public Value createBlob(InputStream x, long length) { if (x == null) { return ValueNull.INSTANCE; } if (length <= 0) { length = -1; } Value v = session.getDataHandler().getLobStorage().createBlob(x, length); session.addTemporaryLob(v); return v; }
@Override public void remove() { if (fileName != null) { if (tempFile != null) { tempFile.stopAutoDelete(); } // synchronize on the database, to avoid concurrent temp file // creation / deletion / backup synchronized (handler.getLobSyncObject()) { FileUtils.delete(fileName); } } if (handler != null) { handler.getLobStorage().removeLob(this); } }
getLobStorage().init(); systemSession.commit(true);
} else { v = session.getDataHandler().getLobStorage(). createClob(new BufferedReader(in), -1); session.getDataHandler().getLobStorage().createBlob(in, -1); session.addTemporaryLob(v); break;
@Override public void truncate(Session session) { TransactionMap<Value, Value> map = getMap(session); if (mvTable.getContainsLargeObject()) { database.getLobStorage().removeAllForTable(table.getId()); } map.clear(); }
/** * Create a new empty Clob object. * * @return the object */ @Override public Clob createClob() throws SQLException { try { int id = getNextId(TraceObject.CLOB); debugCodeAssign("Clob", TraceObject.CLOB, id, "createClob()"); checkClosedForWrite(); try { Value v = session.getDataHandler().getLobStorage() .createClob(new InputStreamReader( new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0); session.addTemporaryLob(v); return new JdbcClob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
/** * Create a new empty Blob object. * * @return the object */ @Override public Blob createBlob() throws SQLException { try { int id = getNextId(TraceObject.BLOB); debugCodeAssign("Blob", TraceObject.BLOB, id, "createClob()"); checkClosedForWrite(); try { Value v = session.getDataHandler().getLobStorage().createBlob( new ByteArrayInputStream(Utils.EMPTY_BYTES), 0); synchronized (session) { session.addTemporaryLob(v); } return new JdbcBlob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
@Override public void remove() { if (fileName != null) { if (tempFile != null) { tempFile.stopAutoDelete(); } // synchronize on the database, to avoid concurrent temp file // creation / deletion / backup synchronized (handler.getLobSyncObject()) { FileUtils.delete(fileName); } } if (handler != null) { handler.getLobStorage().removeLob(this); } }
getLobStorage().init(); systemSession.commit(true);
Reader r = new BufferedReader((java.io.Reader) x); return session.getDataHandler().getLobStorage(). createClob(r, -1); } else if (x instanceof java.sql.Clob) { try { Reader r = new BufferedReader(clob.getCharacterStream()); return session.getDataHandler().getLobStorage(). createClob(r, clob.length()); } catch (SQLException e) { throw DbException.convert(e); createBlob((java.io.InputStream) x, -1); } else if (x instanceof java.sql.Blob) { try { java.sql.Blob blob = (java.sql.Blob) x; return session.getDataHandler().getLobStorage(). createBlob(blob.getBinaryStream(), blob.length()); } catch (SQLException e) { throw DbException.convert(e);
@Override public Value copy(DataHandler database, int tableId) { if (small == null) { Value v2 = handler.getLobStorage().copyLob(this, tableId, getPrecision()); return v2; } else if (small.length > database.getMaxLengthInplaceLob()) { LobStorageInterface s = database.getLobStorage(); Value v; if (type == Value.BLOB) { v = s.createBlob(getInputStream(), getPrecision()); } else { v = s.createClob(getReader(), getPrecision()); } Value v2 = v.copy(database, tableId); v.remove(); return v2; } return this; }
@Override public void truncate(Session session) { rows = New.arrayList(); firstFree = -1; if (tableData.getContainsLargeObject() && tableData.isPersistData()) { database.getLobStorage().removeAllForTable(table.getId()); } tableData.setRowCount(0); rowCount = 0; rowCountDiff = 0; if (database.isMultiVersion()) { sessionRowCount.clear(); } }
/** * Create an independent copy of this value, * that will be bound to a result. * * @return the value (this for small objects) */ @Override public ValueLobDb copyToResult() { if (handler == null) { return this; } LobStorageInterface s = handler.getLobStorage(); if (s.isReadOnly()) { return this; } return s.copyLob(this, LobStorageFrontend.TABLE_RESULT, getPrecision()); }
/** * Create a new empty NClob object. * * @return the object */ @Override public NClob createNClob() throws SQLException { try { int id = getNextId(TraceObject.CLOB); debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()"); checkClosedForWrite(); try { Value v = session.getDataHandler().getLobStorage() .createClob(new InputStreamReader( new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0); session.addTemporaryLob(v); return new JdbcClob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }