1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.files
;
5 import java
.io
.IOException
;
6 import java
.nio
.ByteBuffer
;
9 * A channel for reading records from a {@link FileReadChannel}.
11 * The format of these records is defined by the leveldb log format:
12 * http://leveldb.googlecode.com/svn/trunk/doc/log_format.txt
15 * An instance of {@link RecordReadChannel} may be obtained from the method:
16 * {@link FileService#openRecordReadChannel(AppEngineFile, boolean)}.
20 public interface RecordReadChannel
{
23 * Reads a record from the file and returns it in a {@link ByteBuffer}. This ByteBuffer is
24 * reused, so if the user would like to save the result of {@link #readRecord()}, they need
25 * to copy the output of this method.
26 * @return a {@link ByteBuffer} containing the record.
29 ByteBuffer
readRecord() throws IOException
;
32 * Returns the position in the underlying {@link FileReadChannel}.
33 * @return the position.
36 long position() throws IOException
;
39 * Sets the read position of the underlying {@link FileReadChannel}. The position value should
40 * only be set using the value obtained from a previous {@link #position()} call.
41 * @param newPosition the position at which to set the reader.
44 void position(long newPosition
) throws IOException
;