Class RandomAccessFilePaged
java.lang.Object
com.semedy.reasoner.edb.persistentstore.RandomAccessFilePaged
- All Implemented Interfaces:
RandomAccessToFile
A ramdom acess file paged. It provides a linear address room
- Author:
- juergen
-
Constructor Summary
ConstructorDescriptionRandomAccessFilePaged
(String filePath, String accessRights, int pagesize) creates a new file with given filepath and access rights "r" for read,
"rw" for read and write -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkFile
(long offset, int len) check file contentsvoid
close()
close filevoid
delete()
void
flush()
close filelong
get the current position of the filelong
length()
Get the file lengthvoid
read
(byte[] bytes) Reads a byte array from current position.void
read
(byte[] bytes, int offset, int len) Reads len bytes from current file position to array from offset position on.byte
readByte()
Reads a byte from current position.int
readInt()
Reads an int at current position.long
readLong()
Reads a long at current position.void
seek
(long position) Positions to an addressstatic void
unmap
(MappedByteBuffer buffer) void
write
(byte[] bytes) Writes a byte array to current position.void
write
(byte[] bytes, int offset, int len) Writes len bytes from byte array from offset position on to current file position.void
writeByte
(int b) Reads a byte current positionvoid
writeInt
(int value) Writes an int to current position.void
writeInternal
(byte[] bytes, int offset, int len) void
writeLong
(long value) Writes a long to current position.
-
Constructor Details
-
RandomAccessFilePaged
creates a new file with given filepath and access rights "r" for read,
"rw" for read and write- Parameters:
filePath
-accessRights
-- Throws:
IOException
-
-
Method Details
-
seek
Positions to an address- Specified by:
seek
in interfaceRandomAccessToFile
- Parameters:
position
-- Throws:
IOException
-
read
Reads a byte array from current position.- Specified by:
read
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
read
Reads len bytes from current file position to array from offset position on.- Specified by:
read
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
write
Writes a byte array to current position.- Specified by:
write
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
writeInternal
public void writeInternal(byte[] bytes, int offset, int len) -
write
Writes len bytes from byte array from offset position on to current file position.- Specified by:
write
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
readByte
Description copied from interface:RandomAccessToFile
Reads a byte from current position.- Specified by:
readByte
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeByte
Description copied from interface:RandomAccessToFile
Reads a byte current position- Specified by:
writeByte
in interfaceRandomAccessToFile
- Throws:
IOException
-
readInt
Reads an int at current position.- Specified by:
readInt
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeInt
Writes an int to current position.- Specified by:
writeInt
in interfaceRandomAccessToFile
- Parameters:
value
-- Throws:
IOException
-
close
close file- Specified by:
close
in interfaceRandomAccessToFile
- Throws:
IOException
-
flush
close file- Specified by:
flush
in interfaceRandomAccessToFile
- Throws:
IOException
-
readLong
Reads a long at current position. Creates an exception if byte array crosses a page border- Specified by:
readLong
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeLong
Writes a long to current position. Creates an exception if byte array crosses a page border- Specified by:
writeLong
in interfaceRandomAccessToFile
- Parameters:
value
-- Throws:
IOException
-
length
Get the file length- Specified by:
length
in interfaceRandomAccessToFile
- Throws:
IOException
-
delete
- Specified by:
delete
in interfaceRandomAccessToFile
- Throws:
IOException
-
unmap
-
getFilePointer
public long getFilePointer()Description copied from interface:RandomAccessToFile
get the current position of the file- Specified by:
getFilePointer
in interfaceRandomAccessToFile
- Returns:
-
checkFile
Description copied from interface:RandomAccessToFile
check file contents- Specified by:
checkFile
in interfaceRandomAccessToFile
- Returns:
- Throws:
IOException
-