Esempio n. 1
0
  @Override
  protected void loadArrayFileData() throws IOException {
    long maxScn = _arrayFile.getLwmScn();

    try {
      _internalArray = new MemoryLongArray(_subArrayBits);
      _arrayFile.load(_internalArray);

      expandCapacity(_internalArray.length() - 1);
      _internalArray.setArrayExpandListener(this);
    } catch (Exception e) {
      throw (e instanceof IOException)
          ? (IOException) e
          : new IOException("Failed to load array file", e);
    }

    _entryManager.setWaterMarks(maxScn, maxScn);
  }
Esempio n. 2
0
  @Override
  public void expandCapacity(int index) throws Exception {
    if (index < _length) return;

    long capacity = ((index >> _subArrayBits) + 1L) * _subArraySize;
    int newLength = (capacity < Integer.MAX_VALUE) ? (int) capacity : Integer.MAX_VALUE;

    // Reset _length
    _length = newLength;

    // Expand internal array in memory
    if (_internalArray.length() < newLength) {
      _internalArray.expandCapacity(index);
    }

    // Expand array file on disk
    _arrayFile.setArrayLength(newLength, null /* do not rename */);

    // Add to logging
    _log.info("Expanded: _length=" + _length);
  }