Package uk.co.sculptor.kflibjava
Class FileIndex
java.lang.Object
uk.co.sculptor.kflibjava.FileIndex
- All Implemented Interfaces:
AutoCloseable
Represents one KeyedFile index (main or secondary). Can only be created from one of the KeyedFile
constructors and accessed via the KeyedFile.getIndex(java.lang.String)
AutoCloseable
interface, meaning that an object may hold resources
(such as file or socket handles) until it is closed. The close() method of an AutoCloseable object is called automatically
when exiting a try-with-resources
block for which the object has been declared in the resource specification header.
This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.- Author:
- Marcos Gutierrez Batz
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close All the objects hanging from the FileIndex.int
count()
Count the number of records/keys in a file/index.void
find()
Find first record with matching key, locking the record and not waiting when the record is in use.void
findu()
Find first record with matching key not locking the record.void
findw()
Find first record with matching key, locking the record and waiting when the record is in use.Returns current FileIndex nameint
Returns current FileIndex keylenint
Returns current FileIndex number of keysboolean
Returns whether the current FileIndex is the main KeyedFile indexboolean
Returns whether the current FileIndex permits nullsvoid
match()
Find next record with matching key, locking the record and not waiting when the record is in use.void
matchu()
Find next record with matching key not locking the record.void
matchw()
Find next record with matching key, locking the record and waiting when the record is in use.void
next()
Read next record, locking the record and not waiting when the record is in use.void
nextKey()
Read next key.void
nextu()
Read next record not locking the record.void
nextw()
Read next record, locking the record and waiting when the record is in use.void
prev()
Read previous record, locking the record and not waiting when the record is in use.void
prevKey()
Read previous key.void
prevu()
Read previous record not locking the record.void
prevw()
Read previous record, locking the record and waiting when the record is in use.void
read()
Read record for given key, locking the record and not waiting when the record is in use.void
readKey()
Read key.void
readu()
Read record for given key not locking the record.void
readw()
Read record for given key, locking the record and waiting when the record is in use.void
rewind()
Rewind (initialise the key contents)void
testKey()
Test key exists.void
wind()
Wind (initialise the key contents)
-
Method Details
-
close
public void close()Close All the objects hanging from the FileIndex.- Specified by:
close
in interfaceAutoCloseable
-
count
Count the number of records/keys in a file/index.- Returns:
- the number of records.
- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
find
Find first record with matching key, locking the record and not waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
findu
Find first record with matching key not locking the record.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
findw
Find first record with matching key, locking the record and waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
getIndexName
Returns current FileIndex name- Returns:
- The indexName
-
getKeyLength
public int getKeyLength()Returns current FileIndex keylen- Returns:
- The keylen
-
getNumberOfKeys
public int getNumberOfKeys()Returns current FileIndex number of keys- Returns:
- The number of keys
-
isMainIndex
public boolean isMainIndex()Returns whether the current FileIndex is the main KeyedFile index- Returns:
- true when that FileIndex is the main index of the KeyedFile
-
isNoNulls
public boolean isNoNulls()Returns whether the current FileIndex permits nulls- Returns:
- true if no nulls
-
match
Find next record with matching key, locking the record and not waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
matchu
Find next record with matching key not locking the record.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
matchw
Find next record with matching key, locking the record and waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
next
Read next record, locking the record and not waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
nextKey
Read next key.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
nextu
Read next record not locking the record.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
nextw
Read next record, locking the record and waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
prev
Read previous record, locking the record and not waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
prevKey
Read previous key.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
prevu
Read previous record not locking the record.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
prevw
Read previous record, locking the record and waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
read
Read record for given key, locking the record and not waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
readKey
Read key.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
readu
Read record for given key not locking the record.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
readw
Read record for given key, locking the record and waiting when the record is in use.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
rewind
Rewind (initialise the key contents)- Throws:
KfException
- Any error on the KfServer protocol or on the server process.
-
testKey
Test key exists.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- Any error on the KfServer protocol or on the server process.
-
wind
Wind (initialise the key contents)- Throws:
KfException
- Any error on the KfServer protocol or on the server process.
-