@Override
  public synchronized void transfer(Integer from, Integer to, int amount) {
    accounts.get(from).transfer(-amount);
    accounts.get(to).transfer(amount);

    excerpt.startExcerpt(12);
    excerpt.writeInt(from);
    excerpt.writeInt(to);
    excerpt.writeInt(amount);
    excerpt.finish();
  }
Example #2
0
  @Override
  public Page read(long key, @Nullable PageReadTrx pageReadTrx) throws SirixIOException {
    try {
      // Read page from excerpt.
      final boolean opened = mExcerpt.index(key);
      assert opened : "Index couldn't be opened!";
      final int dataLength = mExcerpt.readInt();
      final byte[] page = new byte[dataLength];
      mExcerpt.read(page);
      mExcerpt.finish();

      // Perform byte operations.
      final DataInputStream input =
          new DataInputStream(mByteHandler.deserialize(new ByteArrayInputStream(page)));

      // Return reader required to instantiate and deserialize page.
      return PagePersistenter.deserializePage(input, pageReadTrx);
    } catch (final IOException e) {
      throw new SirixIOException(e);
    }
  }