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);
  }
Esempio n. 3
0
  @Override
  public void clear() {
    if (_internalArray != null) {
      _internalArray.clear();
    }

    // Clear the entry manager
    _entryManager.clear();

    // Clear the underlying array file
    try {
      _arrayFile.reset(_internalArray, _entryManager.getLWMark());
    } catch (IOException e) {
      _log.error(e.getMessage(), e);
    }
  }
Esempio n. 4
0
 @Override
 public long[] getInternalArray() {
   return _internalArray.getInternalArray();
 }
Esempio n. 5
0
 @Override
 public void setCompactionAddress(int index, long address, long scn) throws Exception {
   _internalArray.set(index, address);
   _entryManager.addToPreFillEntryLongCompaction(index, address, scn);
 }
Esempio n. 6
0
 @Override
 public void set(int index, long value, long scn) throws Exception {
   _internalArray.set(index, value);
   _entryManager.addToPreFillEntryLong(index, value, scn);
 }
Esempio n. 7
0
 @Override
 public long get(int index) {
   return _internalArray.get(index);
 }