@Override public void done() { file.seek(FileStorage.HEADER_LENGTH); file.autoDelete(); }
/** * Close the result list and delete the temporary file. */ public void close() { if (file != null) { file.autoDelete(); file.closeAndDeleteSilently(); file = null; rowBuff = null; } }
private void writeAllRows() { if (file == null) { Database db = session.getDatabase(); String fileName = db.createTempFile(); file = db.openFile(fileName, "rw", false); file.setCheckedWriting(false); file.seek(FileStorage.HEADER_LENGTH); rowBuff = DataBuffer.create(db, Constants.DEFAULT_PAGE_SIZE); file.seek(FileStorage.HEADER_LENGTH); } DataBuffer buff = rowBuff; initBuffer(buff); for (int i = 0, size = list.size(); i < size; i++) { if (i > 0 && buff.length() > Constants.IO_BUFFER_SIZE) { flushBuffer(buff); initBuffer(buff); } Row r = list.get(i); writeRow(buff, r); } flushBuffer(buff); file.autoDelete(); list.clear(); memory = 0; }
/** * Create a CLOB in a temporary file. */ private ValueLob(DataHandler handler, Reader in, long remaining) throws IOException { this.type = Value.CLOB; this.handler = handler; this.small = null; this.lobId = 0; this.hmac = null; this.fileName = createTempLobFileName(handler); this.tempFile = this.handler.openFile(fileName, "rw", false); this.tempFile.autoDelete(); FileStorageOutputStream out = new FileStorageOutputStream(tempFile, null, null); long tmpPrecision = 0; try { char[] buff = new char[Constants.IO_BUFFER_SIZE]; while (true) { int len = getBufferSize(this.handler, false, remaining); len = IOUtils.readFully(in, buff, len); if (len == 0) { break; } } } finally { out.close(); } this.precision = tmpPrecision; }
this.fileName = createTempLobFileName(handler); this.tempFile = this.handler.openFile(fileName, "rw", false); this.tempFile.autoDelete(); FileStorageOutputStream out = new FileStorageOutputStream(tempFile, null, null); long tmpPrecision = 0;