Пример #1
0
  protected DataInput walGetData(long offset, int segment) {
    if (CC.ASSERT && offset % 16 != 0) throw new DBException.DataCorruption();

    long longval = uncommittedDataLongs[segment].get(offset);
    if (longval == 0) {
      longval = committedDataLongs[segment].get(offset);
    }
    if (longval == 0) return null;

    return wal.walGetByteArray(longval);
  }
Пример #2
0
  /** return positions of (possibly) linked record */
  @Override
  protected long[] offsetsGet(int segment, long indexVal) {
    ;
    if (indexVal >>> 48 == 0) {
      return ((indexVal & MLINKED) != 0) ? null : StoreDirect.EMPTY_LONGS;
    }

    long[] ret = new long[] {indexVal};
    while ((ret[ret.length - 1] & MLINKED) != 0) {
      ret = Arrays.copyOf(ret, ret.length + 1);
      long oldLink = ret[ret.length - 2] & MOFFSET;

      // get WAL position from current transaction, or previous (not yet fully replayed)
      // transactions
      long val = uncommittedDataLongs[segment].get(oldLink);
      if (val == 0) val = committedDataLongs[segment].get(oldLink);
      if (val != 0) {
        //                //was found in previous position, read link from WAL
        //                int file = (int) ((val>>>32) & 0xFFFFL); // get WAL file number
        //                val = val & 0xFFFFFFFFL; // convert to WAL offset;
        //                val = volumes.get(file).getLong(val);
        try {
          val = wal.walGetByteArray(val).readLong();
        } catch (IOException e) {
          throw new DBException.VolumeIOError(e);
        }
      } else {
        // was not found in any transaction, read from main store
        val = vol.getLong(oldLink);
      }
      ret[ret.length - 1] = parity3Get(val);
    }

    if (CC.ASSERT) {
      offsetsVerify(ret);
    }

    if (CC.LOG_STORE && LOG.isLoggable(Level.FINEST)) {
      LOG.log(
          Level.FINEST,
          "indexVal={0}, ret={1}",
          new Object[] {Long.toHexString(indexVal), Arrays.toString(ret)});
    }

    return ret;
  }