@Override public InputStream getInputStream(long oneBasedOffset, long length) { if (fileName == null) { return super.getInputStream(oneBasedOffset, length); } FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; InputStream inputStream = new BufferedInputStream( new FileStoreInputStream(store, handler, compressed, alwaysClose), Constants.IO_BUFFER_SIZE); return rangeInputStream(inputStream, oneBasedOffset, length, store.length()); }
int last = storedEntriesPos.size() - 1; long pos = storedEntriesPos.remove(last); long end = file.length(); int bufferLength = (int) (end - pos); Data buff = Data.create(database, bufferLength);
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } else { compress = null; } page = Data.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw DbException.convertIOException(e, store.name); } }
long remaining = in.length() - FileStore.HEADER_LENGTH; long total = remaining; in.seek(FileStore.HEADER_LENGTH);
@Override public InputStream getInputStream(long oneBasedOffset, long length) { long byteCount; InputStream inputStream; if (small != null) { return super.getInputStream(oneBasedOffset, length); } else if (fileName != null) { FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; byteCount = store.length(); inputStream = new BufferedInputStream(new FileStoreInputStream(store, handler, false, alwaysClose), Constants.IO_BUFFER_SIZE); } else { byteCount = (type == Value.BLOB) ? precision : -1; try { inputStream = handler.getLobStorage().getInputStream(this, hmac, byteCount); } catch (IOException e) { throw DbException.convertIOException(e, toString()); } } return ValueLob.rangeInputStream(inputStream, oneBasedOffset, length, byteCount); }
resetSchema(); store = FileStore.open(null, fileName, remove ? "rw" : "r"); long length = store.length(); try { store.init();
byte[] salt; byte[] magic = HEADER.getBytes(StandardCharsets.UTF_8); if (length() < HEADER_LENGTH) {
readStaticHeader(); freeListPagesPerList = PageFreeList.getPagesAddressed(pageSize); fileLength = file.length(); pageCount = (int) (fileLength / pageSize); if (pageCount < MIN_PAGE_COUNT) {
trace.debug("pageCount: " + pageCount); long newLength = (long) pageCount << pageSizeShift; if (file.length() != newLength) { file.setLength(newLength); writeCount++;
if (store.length() == store.getFilePointer()) { close(); return;
public synchronized void freeUpDiskSpace() throws SQLException { long sizeAvailable = 0; if (emergencyReserve != null) { sizeAvailable = emergencyReserve.length(); long newLength = sizeAvailable / 4; if (newLength < SysProperties.EMERGENCY_SPACE_MIN) { newLength = 0; noDiskSpace = true; } emergencyReserve.setLength(newLength); } if (eventListener != null) { eventListener.diskSpaceIsLow(sizeAvailable); } }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) throws SQLException { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } page = DataPage.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw Message.convertIOException(e, store.name); } }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } else { compress = null; } page = Data.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw DbException.convertIOException(e, store.name); } }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } else { compress = null; } page = Data.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw DbException.convertIOException(e, store.name); } }
long remaining = in.length() - FileStore.HEADER_LENGTH; long total = remaining; in.seek(FileStore.HEADER_LENGTH);
long remaining = in.length() - FileStore.HEADER_LENGTH; long total = remaining; in.seek(FileStore.HEADER_LENGTH);
private void readHeader() throws SQLException { DataPage buff = getHeader(); int len = buff.length(); buff.reset(); if (file.length() < FileStore.HEADER_LENGTH + len) { // this is an empty file return; } file.readFully(buff.getBytes(), 0, len); id = buff.readInt(); firstUncommittedPos = buff.readInt(); firstUnwrittenPos = buff.readInt(); }
void flush() throws SQLException { if (bufferPos > 0) { if (file == null) { throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF); } file.write(buffer, 0, bufferPos); pos = getBlock(); for (int i = 0; i < unwritten.size(); i++) { Record r = (Record) unwritten.get(i); r.setLogWritten(id, pos); } unwritten.clear(); bufferPos = 0; long min = (long) pos * BLOCK_SIZE; min = MathUtils.scaleUp50Percent(Constants.FILE_MIN_SIZE, min, Constants.FILE_PAGE_SIZE, Constants.FILE_MAX_INCREMENT); if (min > file.length()) { file.setLength(min); } } }
public void redoAllGoEnd() throws SQLException { boolean readOnly = logSystem.getDatabase().getReadOnly(); long length = file.length(); if (length <= FileStore.HEADER_LENGTH) { return;
public void init() throws SQLException { int len = Constants.FILE_BLOCK_SIZE; byte[] salt; if (length() < HEADER_LENGTH) {