public class FileWordList extends AbstractFileWordList
WordList
that is backed by a file. Each word is read from the file for every
get, though the implementation supports a simple memory cache to improve read performance. This implementation should
be avoided for files greater than 100MB in size.AbstractFileWordList.FileWord
DEFAULT_CACHE_PERCENT, file, size
comparator
Constructor and Description |
---|
FileWordList(RandomAccessFile raf)
Creates a new case-sensitive word list from the supplied file.
|
FileWordList(RandomAccessFile raf,
boolean caseSensitive)
Creates a new word list from the supplied file.
|
FileWordList(RandomAccessFile raf,
boolean caseSensitive,
int cachePercent)
Creates a new word list from the supplied file.
|
FileWordList(RandomAccessFile raf,
boolean caseSensitive,
int cachePercent,
CharsetDecoder decoder)
Creates a new word list from the supplied file.
|
FileWordList(RandomAccessFile raf,
boolean caseSensitive,
int cachePercent,
CharsetDecoder decoder,
boolean allocateDirect)
Creates a new word list from the supplied file.
|
Modifier and Type | Method and Description |
---|---|
protected ByteBuffer |
buffer()
Returns the buffer providing the backing file data.
|
protected void |
fill()
Fills the buffer from the backing file.
|
protected void |
seek(long offset)
Positions the read head of the backing file at the given byte offset.
|
close, get, getFile, initialize, readWord, size, toString
checkIsString, checkRange, getComparator, iterator, medianIterator
public FileWordList(RandomAccessFile raf) throws IOException
NOTE Attempts to close the source file will cause IOException
when AbstractFileWordList.get(int)
is
called subsequently.
raf
- File containing words, one per line.IOException
- if an error occurs reading the supplied filepublic FileWordList(RandomAccessFile raf, boolean caseSensitive) throws IOException
NOTE Attempts to close the source file will cause IOException
when AbstractFileWordList.get(int)
is
called subsequently.
raf
- File containing words, one per line.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.IOException
- if an error occurs reading the supplied filepublic FileWordList(RandomAccessFile raf, boolean caseSensitive, int cachePercent) throws IOException
NOTE Attempts to close the source file will cause IOException
when AbstractFileWordList.get(int)
is
called subsequently.
raf
- File containing words, one per line.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.cachePercent
- Percent (0-100) of file to cache in memory for improved read performance.IllegalArgumentException
- if cache percent is out of range.IOException
- if an error occurs reading the supplied filepublic FileWordList(RandomAccessFile raf, boolean caseSensitive, int cachePercent, CharsetDecoder decoder) throws IOException
NOTE Attempts to close the source file will cause IOException
when AbstractFileWordList.get(int)
is
called subsequently.
raf
- File containing words, one per line.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.cachePercent
- Percent (0-100) of file to cache in memory for improved read performance.decoder
- Charset decoder for converting file bytes to charactersIllegalArgumentException
- if cache percent is out of range.IOException
- if an error occurs reading the supplied filepublic FileWordList(RandomAccessFile raf, boolean caseSensitive, int cachePercent, CharsetDecoder decoder, boolean allocateDirect) throws IOException
NOTE Attempts to close the source file will cause IOException
when AbstractFileWordList.get(int)
is
called subsequently.
raf
- File containing words, one per line.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.cachePercent
- Percent (0-100) of file to cache in memory for improved read performance.decoder
- Charset decoder for converting file bytes to charactersallocateDirect
- whether buffers should be allocated with ByteBuffer.allocateDirect(int)
IllegalArgumentException
- if cache percent is out of range.IOException
- if an error occurs reading the supplied fileprotected void seek(long offset) throws IOException
AbstractFileWordList
seek
in class AbstractFileWordList
offset
- byte offset into file.IOException
- on I/O errors seeking.protected ByteBuffer buffer()
AbstractFileWordList
buffer
in class AbstractFileWordList
protected void fill() throws IOException
AbstractFileWordList
fill
in class AbstractFileWordList
IOException
- on I/O errors filling buffer.Copyright © 2003-2024 Virginia Tech. All Rights Reserved.