public class SharedStringTable extends Object implements Closeable, Iterable<String>
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
defaultBufferSize
Buffer size(4K)
|
protected boolean |
shouldDelete
Delete the temp file if @author
SharedStringTable |
| 限定符 | 构造器和说明 |
|---|---|
protected |
SharedStringTable()
Create a temp file to storage shared strings
|
protected |
SharedStringTable(Path path)
Constructor a SharedStringTable with a exists file
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
checkCapacityAndGrow()
Check remaining data and grow if shortage
|
void |
close()
Close channel and delete temp files
|
protected void |
commit()
Commit current index file writer
|
int |
find(char c)
Find character value from begging
|
int |
find(char c,
long pos)
Find from the specified location
|
int |
find(String key)
Find value from begging
|
int |
find(String key,
long pos)
Find from the specified location
|
protected Path |
getTemp() |
static ByteBuffer |
grow(ByteBuffer buffer)
Grow a new Buffer
|
static int |
hasFullValue(ByteBuffer buffer)
Check the remaining data is complete
|
Iterator<String> |
iterator()
Returns an iterator over elements of type String
|
protected SharedStringTable |
mark()
Sets this buffer's mark at its position.
|
protected long |
position()
Returns this buffer's position.
|
int |
push(char c)
Write character value into table
|
int |
push(String key)
Write string value into table
|
protected int |
read(ByteBuffer buffer)
Returns a ByteBuffer data from channel position
|
protected SharedStringTable |
reset()
Resets this buffer's position to the previously-marked position.
|
int |
size()
Returns the cache size
|
protected SharedStringTable |
skip(long position)
Jump to the specified position, the actual moving position
will be increased by 4, the header contains an integer value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected boolean shouldDelete
SharedStringTableprotected int defaultBufferSize
protected SharedStringTable()
throws IOException
IOException - if I/O error occur.protected SharedStringTable(Path path) throws IOException
path - the file pathIOException - if file not exists or I/O error occur.protected Path getTemp()
public int push(char c)
throws IOException
c - the character valueIOException - if io error occurpublic int push(String key) throws IOException
key - the string valueIOException - if io error occurpublic int find(char c)
throws IOException
c - the character to findIOException - if io error occurpublic int find(char c,
long pos)
throws IOException
c - the character to findpos - the buffer's positionIOException - if io error occurpublic int find(String key) throws IOException
key - the key to findIOException - if io error occurpublic int find(String key, long pos) throws IOException
key - the key to findpos - the buffer's positionIOException - if io error occurpublic int size()
protected boolean checkCapacityAndGrow()
public static ByteBuffer grow(ByteBuffer buffer)
buffer - Old bufferWRITE STATUSpublic static int hasFullValue(ByteBuffer buffer)
buffer - the ByteBufferprotected void commit()
throws IOException
IOException - if I/O error occurpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOException - if I/O error occurprotected long position()
throws IOException
IOException - if I/O error occurprotected int read(ByteBuffer buffer) throws IOException
buffer - the byte bufferIOException - if I/O error occurprotected SharedStringTable mark() throws IOException
IOException - if I/O error occurprotected SharedStringTable reset() throws IOException
InvalidMarkException - If the mark has not been setIOException - if I/O error occurprotected SharedStringTable skip(long position) throws IOException
position - the position to jumpSharedStringTableIOException - if I/O error occurCopyright © 2022. All rights reserved.