/** * Enable or disable a number of bits. * * @param fromIndex the index of the first bit to enable or disable * @param toIndex one plus the index of the last bit to enable or disable * @param value the new value */ public void set(int fromIndex, int toIndex, boolean value) { // go backwards so that OutOfMemory happens // before some bytes are modified for (int i = toIndex - 1; i >= fromIndex; i--) { set(i, value); } if (value) { if (toIndex > maxLength) { maxLength = toIndex; } } else { if (toIndex >= maxLength) { maxLength = fromIndex; } } }
private void increaseFileSize(int increment) { for (int i = pageCount; i < pageCount + increment; i++) { freed.set(i); } pageCount += increment; long newLength = (long) pageCount << pageSizeShift; file.setLength(newLength); writeCount++; fileLength = newLength; }
/** * Allocate a new object id. * * @return the id */ public synchronized int allocateObjectId() { int i = objectIds.nextClearBit(0); objectIds.set(i); return i; }
private void set(int i, boolean value) { if (value) { set(i); } else { clear(i); } }
private boolean shuffleTwo(TableFilter[] f) { int a = 0, b = 0, i = 0; for (; i < 20; i++) { a = random.nextInt(f.length); b = random.nextInt(f.length); if (a == b) { continue; } if (a < b) { int temp = a; a = b; b = temp; } int s = a * f.length + b; if (switched.get(s)) { continue; } switched.set(s); break; } if (i == 20) { return false; } TableFilter temp = f[a]; f[a] = f[b]; f[b] = temp; return true; }
private PageFreeList(PageStore store, int pageId) { // kept in cache, and array list in page store setPos(pageId); this.store = store; pageCount = (store.getPageSize() - DATA_START) * 8; used = new BitField(pageCount); used.set(0); }
for (int j = 0; j < 8; j++) { if ((x & (1 << j)) != 0) { used.set(i + j);
/** * Add a page to the free list. The page is not used, therefore doesn't need * to be overwritten. * * @param pageId the page id */ void freeUnused(int pageId) { if (trace.isDebugEnabled()) { trace.debug("freeUnused " + pageId); } cache.remove(pageId); freePage(pageId); freed.set(pageId); }
/** * Mark a page as used. * * @param pageId the page id */ void allocate(int pageId) { int idx = pageId - getPos(); if (idx >= 0 && !used.get(idx)) { // set the bit first, because logUndo can // allocate other pages, and we must not // return the same page twice used.set(idx); store.logUndo(this, data); store.update(this); } }
/** * Update an object in the system table. * * @param session the session * @param obj the database object */ public void updateMeta(Session session, DbObject obj) { lockMeta(session); synchronized (this) { int id = obj.getId(); removeMeta(session, id); addMeta(session, obj); // for temporary objects if (id > 0) { objectIds.set(id); } } }
private void openForWriting() { if (!readMode || database.isReadOnly()) { return; } readMode = false; recoveryRunning = true; log.free(); logFirstTrunkPage = allocatePage(); log.openForWriting(logFirstTrunkPage, false); recoveryRunning = false; freed.set(0, pageCount, true); checkpoint(); }
public BitField getObjectIds() { BitField f = new BitField(); Cursor cursor = metaIndex.find(pageStoreSession, null, null); while (cursor.next()) { Row row = cursor.get(); int id = row.getValue(0).getInt(); if (id > 0) { f.set(id); } } return f; }
private void registerOutParameter(int parameterIndex) throws SQLException { try { checkClosed(); if (outParameters == null) { maxOutParameters = Math.min( getParameterMetaData().getParameterCount(), getCheckedMetaData().getColumnCount()); outParameters = new BitField(); } checkIndexBounds(parameterIndex); ParameterInterface param = command.getParameters().get(--parameterIndex); if (!param.isValueSet()) { param.setValue(ValueNull.INSTANCE, false); } outParameters.set(parameterIndex); } catch (Exception e) { throw logAndConvert(e); } }
private synchronized void addMeta(Session session, DbObject obj) { int id = obj.getId(); if (id > 0 && !starting && !obj.isTemporary()) { Row r = meta.getTemplateRow(); MetaRecord rec = new MetaRecord(obj); rec.setRecord(r); objectIds.set(id); if (SysProperties.CHECK) { verifyMetaLocked(session); } meta.addRow(session, r); if (isMultiVersion()) { // TODO this should work without MVCC, but avoid risks at the // moment session.log(meta, UndoLogRecord.INSERT, r); } } }
used.set(free); store.logUndo(this, data); store.update(this);
freed.set(newPageCount, pageCount, false);
writeCount++; freed.set(i);