Exemplo n.º 1
0
 /** Sets the current size */
 static void setCurrentSize(final PageIo page, final short pos, int value) {
   if (value == 0) {
     page.writeByte(pos + O_CURRENTSIZE, (byte) (MAX_SIZE_SPACE + 1));
     return;
   }
   int availSize = getAvailableSize(page, pos);
   if (value < (availSize - MAX_SIZE_SPACE) || value > availSize)
     throw new IllegalArgumentException(
         "currentSize out of bounds, need to realocate " + value + " - " + availSize);
   page.writeByte(pos + O_CURRENTSIZE, (byte) (availSize - value));
 }
Exemplo n.º 2
0
  /** Sets the available size */
  static void setAvailableSize(final PageIo page, final short pos, int value) {
    if (value != roundAvailableSize(value))
      throw new IllegalArgumentException("value is not rounded");
    int oldCurrSize = getCurrentSize(page, pos);

    page.writeShort(pos + O_AVAILABLESIZE, convertAvailSize(value));
    setCurrentSize(page, pos, oldCurrSize);
  }
Exemplo n.º 3
0
 /** Returns the available size */
 static int getAvailableSize(final PageIo page, final short pos) {
   return deconvertAvailSize(page.readShort(pos + O_AVAILABLESIZE));
 }
Exemplo n.º 4
0
 /** Returns the current size */
 static int getCurrentSize(final PageIo page, final short pos) {
   int s = page.readByte(pos + O_CURRENTSIZE) & 0xFF;
   if (s == MAX_SIZE_SPACE + 1) return 0;
   return getAvailableSize(page, pos) - s;
 }