/** * 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 set(int i, boolean value) { if (value) { set(i); } else { clear(i); } }
/** * Allocate a new object id. * * @return the id */ public int allocateObjectId() { synchronized (objectIds) { int i = objectIds.nextClearBit(0); objectIds.set(i); return 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; }
public synchronized void rollbackMetaTable(ServerSession session) { ArrayList<MetaRecord> records = new ArrayList<>(); Cursor cursor = metaIdIndex.find(systemSession, null, null); while (cursor.next()) { MetaRecord rec = new MetaRecord(cursor.get()); objectIds.set(rec.getId()); records.add(rec); } objectIds.set(0); starting = true; Collections.sort(records); for (MetaRecord rec : records) { rec.execute(this, systemSession, eventListener); } recompileInvalidViews(); starting = false; }
private void registerOutParameter(int parameterIndex) throws SQLException { try { checkClosed(); if (outParameters == null) { maxOutParameters = Math.min(getParameterMetaData().getParameterCount(), getCheckedMetaData().getColumnCount()); outParameters = new BitField(); } checkIndexBounds(parameterIndex); CommandParameter param = command.getParameters().get(--parameterIndex); if (param.getValue() == null) { param.setValue(ValueNull.INSTANCE, false); } outParameters.set(parameterIndex); } catch (Exception e) { throw logAndConvert(e); } }
private void addMeta(ServerSession 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); synchronized (objectIds) { objectIds.set(id); } // if (SysProperties.CHECK) { // verifyMetaLocked(session); // } meta.addRow(session, r); } }
else { for (int id : getAllChunkIds()) { chunkIds.set(id);
private TreeSet<Long> executeSave(boolean force) { DataBuffer buff = getDataBuffer(); int id = chunkIds.nextClearBit(1); chunkIds.set(id); BTreeChunk c = new BTreeChunk(id); chunks.put(c.id, c);