예제 #1
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;
  }
예제 #2
0
  @Override
  public void close() {
    commitLock.lock();
    try {

      if (closed) {
        return;
      }

      if (hasUncommitedData()) {
        LOG.warning("Closing storage with uncommited data, this data will be discarded.");
      }

      headVol.putData(0, headVolBackup, 0, headVolBackup.length);

      if (!readonly) {
        replaySoft();
        wal.destroyWalFiles();
      }
      wal.close();

      vol.close();
      vol = null;

      headVol.close();
      headVol = null;
      headVolBackup = null;

      uncommittedStackPages.clear();

      if (caches != null) {
        for (Cache c : caches) {
          c.close();
        }
        Arrays.fill(caches, null);
      }
      if (fileLockHeartbeat != null) {
        fileLockHeartbeat.unlock();
        fileLockHeartbeat = null;
      }
      closed = true;
    } finally {
      commitLock.unlock();
    }
  }
예제 #3
0
 @Override
 public void compact() {
   LOG.warning(
       "Compaction not yet implemented with StoreWAL, disable transactions to compact this store");
 }