private void writeHead() { data.writeByte((byte) type); data.writeShortInt(0); data.writeInt(parentPageId); }
private void writeStaticHeader() { Data page = Data.create(database, new byte[pageSize - FileStore.HEADER_LENGTH]); page.writeInt(pageSize); page.writeByte((byte) WRITE_VERSION); page.writeByte((byte) READ_VERSION); file.seek(FileStore.HEADER_LENGTH); file.write(page.getBytes(), 0, pageSize - FileStore.HEADER_LENGTH); writeCount++; }
/** * Write the header data. */ void initWrite() { data = store.createData(); data.writeByte((byte) Page.TYPE_STREAM_DATA); data.writeShortInt(0); data.writeInt(trunk); data.writeInt(logKey); remaining = store.getPageSize() - data.length(); }
private void writeHead() { data.reset(); data.writeByte((byte) (Page.TYPE_BTREE_LEAF | (onlyPosition ? 0 : Page.FLAG_LAST))); data.writeShortInt(0); data.writeInt(parentPageId); data.writeVarInt(index.getId()); data.writeShortInt(entryCount); }
private void writeHead() { data.reset(); data.writeByte((byte) (Page.TYPE_BTREE_NODE | (onlyPosition ? 0 : Page.FLAG_LAST))); data.writeShortInt(0); data.writeInt(parentPageId); data.writeVarInt(index.getId()); data.writeInt(rowCountStored); data.writeShortInt(entryCount); }
private void flushBuffer(Data buff) { buff.checkCapacity(1); buff.writeByte((byte) 0); buff.fillAligned(); buff.setInt(0, buff.length() / Constants.FILE_BLOCK_SIZE); file.write(buff.getBytes(), 0, buff.length()); }
/** * Switch to a new log section. */ void checkpoint() { Data buffer = getBuffer(); buffer.writeByte((byte) CHECKPOINT); write(buffer); undo = new BitField(); logSectionId++; logPos = 0; pageOut.flush(); pageOut.fillPage(); int currentDataPage = pageOut.getCurrentDataPageId(); logSectionPageMap.put(logSectionId, currentDataPage); }
@Override public void write() { data = store.createData(); data.writeByte((byte) Page.TYPE_STREAM_TRUNK); data.writeShortInt(0); data.writeInt(parent); data.writeInt(logKey); data.writeInt(nextTrunk); data.writeShortInt(pageCount); for (int i = 0; i < pageCount; i++) { data.writeInt(pageIds[i]); } store.writePage(getPos(), data); }
private void writeHead() { data.reset(); data.writeByte((byte) Page.TYPE_DATA_NODE); data.writeShortInt(0); if (SysProperties.CHECK2) { if (data.length() != START_PARENT) { DbException.throwInternalError(); } } data.writeInt(parentPageId); data.writeVarInt(index.getId()); data.writeInt(rowCountStored); data.writeShortInt(entryCount); }
/** * A table is truncated. * * @param session the session * @param tableId the table id */ void logTruncate(Session session, int tableId) { if (trace.isDebugEnabled()) { trace.debug("log truncate s: " + session.getId() + " table: " + tableId); } session.addLogPos(logSectionId, logPos); logPos++; Data buffer = getBuffer(); buffer.writeByte((byte) TRUNCATE); buffer.writeVarInt(session.getId()); buffer.writeVarInt(tableId); write(buffer); }
private void writeRow(Data buff, Row r) { buff.checkCapacity(1 + Data.LENGTH_INT * 8); buff.writeByte((byte) 1); buff.writeInt(r.getMemory()); int columnCount = r.getColumnCount(); buff.checkCapacity(1); if (v == null) { buff.writeByte((byte) 0); } else { buff.writeByte((byte) 1); if (v.getType() == Value.CLOB || v.getType() == Value.BLOB) {
/** * Set the state of an in-doubt transaction. * * @param sessionId the session * @param pageId the page where the commit was prepared * @param commit whether the transaction should be committed */ void setInDoubtTransactionState(int sessionId, int pageId, boolean commit) { PageStreamData d = (PageStreamData) store.getPage(pageId); d.initWrite(); Data buff = store.createData(); buff.writeByte((byte) (commit ? COMMIT : ROLLBACK)); buff.writeVarInt(sessionId); byte[] bytes = buff.getBytes(); d.write(bytes, 0, bytes.length); bytes = new byte[d.getRemaining()]; d.write(bytes, 0, bytes.length); d.write(); }
private void writeHead() { data.reset(); int type; if (firstOverflowPageId == 0) { type = Page.TYPE_DATA_LEAF | Page.FLAG_LAST; } else { type = Page.TYPE_DATA_LEAF; } data.writeByte((byte) type); data.writeShortInt(0); if (SysProperties.CHECK2) { if (data.length() != START_PARENT) { DbException.throwInternalError(); } } data.writeInt(parentPageId); data.writeVarInt(index.getId()); data.writeVarInt(columnCount); data.writeShortInt(entryCount); }
private void freeLogPages(IntArray pages) { if (trace.isDebugEnabled()) { trace.debug("log frees " + pages.get(0) + ".." + pages.get(pages.size() - 1)); } Data buffer = getBuffer(); buffer.writeByte((byte) FREE_LOG); int size = pages.size(); buffer.writeVarInt(size); for (int i = 0; i < size; i++) { buffer.writeVarInt(pages.get(i)); } write(buffer); }
/** * Mark a transaction as committed. * * @param sessionId the session */ void commit(int sessionId) { if (trace.isDebugEnabled()) { trace.debug("log commit s: " + sessionId); } if (store.getDatabase().getPageStore() == null) { // database already closed return; } Data buffer = getBuffer(); buffer.writeByte((byte) COMMIT); buffer.writeVarInt(sessionId); write(buffer); if (store.getDatabase().getFlushOnEachCommit()) { flush(); } }
PageDataOverflow p = new PageDataOverflow(store, page, data); store.logUndo(p, null); data.writeByte((byte) type); data.writeShortInt(0); data.writeInt(parentPageId);
/** * Append the row to the buffer. * * @param buff the buffer * @param log the undo log */ void append(Data buff, UndoLog log) { int p = buff.length(); buff.writeInt(0); buff.writeInt(operation); buff.writeByte(row.isDeleted() ? (byte) 1 : (byte) 0); buff.writeInt(log.getTableId(table)); buff.writeLong(row.getKey()); buff.writeInt(row.getSessionId()); int count = row.getColumnCount(); buff.writeInt(count); for (int i = 0; i < count; i++) { Value v = row.getValue(i); buff.checkCapacity(buff.getValueLen(v)); buff.writeValue(v); } buff.fillAligned(); buff.setInt(p, (buff.length() - p) / Constants.FILE_BLOCK_SIZE); }
pageOut.fillPage(); Data buffer = getBuffer(); buffer.writeByte((byte) PREPARE_COMMIT); buffer.writeVarInt(session.getId()); buffer.writeString(transaction);
buffer.writeByte((byte) (add ? ADD : REMOVE)); buffer.writeVarInt(session.getId()); buffer.writeVarInt(tableId);