Package org.entityfs

Examples of org.entityfs.RandomAccess


  }

  @Override
  protected TransactionCollaborator<K, V, P> createReadWriteCollaborator(Lock writeLock)
  {
    RandomAccess ra = m_logFile.openForRandomAccess(RandomAccessMode.READ_WRITE);
    return new LoggingReadWriteTxnCollaborator<K, V, P>(this, m_backend, ra, writeLock, m_keySerializer, m_valueSerializer, getCloseObservable(), getLogAdapterHolder());
  }
View Full Code Here


{
  protected abstract TransactionalDatabase<Integer, Long> createNewDatabaseUsingSameFilesButTruncateRollbackLog(TransactionalDatabase<Integer, Long> otherDb, int howMuchToTruncate);

  protected EFile truncate(EFile f, int howMuchToTruncate)
  {
    RandomAccess ra = f.openForRandomAccess(RandomAccessMode.READ_WRITE);
    try
    {
      ra.setLength(ra.length() - howMuchToTruncate);
    }
    finally
    {
      ra.close();
    }
    return f;
  }
View Full Code Here

{
  protected abstract TransactionalDatabase<String, String> createNewDatabaseUsingSameFilesButTruncateRollbackLog(TransactionalDatabase<String, String> otherDb, int howMuchToTruncate);

  protected EFile truncate(EFile f, int howMuchToTruncate)
  {
    RandomAccess ra = f.openForRandomAccess(RandomAccessMode.READ_WRITE);
    try
    {
      ra.setLength(ra.length() - howMuchToTruncate);
    }
    finally
    {
      ra.close();
    }
    return f;
  }
View Full Code Here

        b2.insert("b2 key 2", "b2 value 2");

        File f = FileSupport.createTempFile();
        try
        {
          RandomAccess ra = new ReadWritableFileAdapter(f).openForRandomAccess(RandomAccessMode.READ_WRITE);
          try
          {
            long dataSize = b1.writeContentsTo(ra);
            ra.seek(0);
            int contentsVersion = b2.getContentsVersion();
            b2.replaceContentsWith(ra, dataSize);
            assertFalse(contentsVersion == b2.getContentsVersion());

            assertEquals(3, b2.getKeys().size());
            assertRecordEquals(new Record<String, String>("b1 key 1", "b1 value 1"), b2, b2.find("b1 key 1"));
            assertRecordEquals(new Record<String, String>("b1 key 2", "b1 value 2"), b2, b2.find("b1 key 2"));
            assertRecordEquals(new Record<String, String>("b1 åäö key 3", "b1 value 3 åäö"), b2, b2.find("b1 åäö key 3"));
          }
          finally
          {
            ra.close();
          }
        }
        finally
        {
          assertTrue(f.delete());
View Full Code Here

        b2.insert(34823, 348234823L);

        File f = FileSupport.createTempFile();
        try
        {
          RandomAccess ra = new ReadWritableFileAdapter(f).openForRandomAccess(RandomAccessMode.READ_WRITE);
          try
          {
            long dataSize = b1.writeContentsTo(ra);
            ra.seek(0);
            int contentsVersion = b2.getContentsVersion();
            b2.replaceContentsWith(ra, dataSize);
            assertFalse(contentsVersion == b2.getContentsVersion());

            assertEquals(3, b2.getKeys().size());
            assertRecordEquals(new Record<Integer, Long>(23, 234923L), b2, b2.find(23));
            assertRecordEquals(new Record<Integer, Long>(23823, 348723823L), b2, b2.find(23823));
            assertRecordEquals(new Record<Integer, Long>(-27237, -23823832L), b2, b2.find(-27237));

            // Try to feed it invalid data
            ra.seek(1);
            try
            {
              b2.replaceContentsWith(ra, dataSize - 1);
              fail();
            }
            catch (RuntimeException e)
            {
              // ok
            }
          }
          finally
          {
            ra.close();
          }
        }
        finally
        {
          assertTrue(f.delete());
View Full Code Here

TOP

Related Classes of org.entityfs.RandomAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.