Example usage for org.apache.cassandra.io.util RandomAccessReader bytesPastMark

List of usage examples for org.apache.cassandra.io.util RandomAccessReader bytesPastMark

Introduction

In this page you can find the example usage for org.apache.cassandra.io.util RandomAccessReader bytesPastMark.

Prototype

public long bytesPastMark() 

Source Link

Usage

From source file:com.fullcontact.cassandra.io.util.BufferedRandomAccessFileTest.java

License:Apache License

@Test
public void testMarkAndReset() throws IOException {
    SequentialWriter w = createTempFile("brafTestMark");
    w.write(new byte[30]);

    w.close();//from   w  w w . ja v  a  2 s.  c om

    RandomAccessReader file = RandomAccessReader.open(w, fs);

    file.seek(10);
    FileMark mark = file.mark();

    file.seek(file.length());
    assertTrue(file.isEOF());

    file.reset();
    assertEquals(file.bytesRemaining(), 20);

    file.seek(file.length());
    assertTrue(file.isEOF());

    file.reset(mark);
    assertEquals(file.bytesRemaining(), 20);

    file.seek(file.length());
    assertEquals(file.bytesPastMark(), 20);
    assertEquals(file.bytesPastMark(mark), 20);

    file.reset(mark);
    assertEquals(file.bytesPastMark(), 0);

    file.close();
}

From source file:com.fullcontact.cassandra.io.util.BufferedRandomAccessFileTest.java

License:Apache License

@Test(expected = AssertionError.class)
public void testAssertionErrorWhenBytesPastMarkIsNegative() throws IOException {
    SequentialWriter w = createTempFile("brafAssertionErrorWhenBytesPastMarkIsNegative");
    w.write(new byte[30]);
    w.close();//  w  w w .  ja v  a 2  s  .com

    RandomAccessReader r = RandomAccessReader.open(w, fs);
    r.seek(10);
    r.mark();

    r.seek(0);
    r.bytesPastMark();
}