public class LongBigListSignedStringMap extends AbstractObject2LongFunction<CharSequence> implements StringMap<CharSequence>, Serializable
The purpose of this map is identical to that of a ShiftAddXorSignedStringMap
, but
Shift-Add-Xor signatures are 64-bit and stored in a LongBigList
. This approach makes it possible to
store the signatures in a file and read them by memory mapping using a ByteBufferLongBigList
.
If the map has a very large number of keys but the access pattern is strongly skewed towards a relatively
small number of entries, using memory mapping might be advantageous.
The intended usage pattern is as follows:
sign(Iterator, String)
for some elaboration);
ByteBufferLongBigList.map(java.nio.channels.FileChannel)
and create on the fly a signed map.
To simplify the process, there is a constructor that will do the mapping for you.
Modifier and Type | Field and Description |
---|---|
protected Object2LongFunction<? extends CharSequence> |
function
The underlying map.
|
protected LongBigList |
signatures
Signatures.
|
defRetValue
Constructor and Description |
---|
LongBigListSignedStringMap(Object2LongFunction<? extends CharSequence> function,
LongBigList signatures)
Creates a signed string map using a given hash map and a big list of 64-bit signatures.
|
LongBigListSignedStringMap(Object2LongFunction<? extends CharSequence> function,
String signatures)
Creates a signed string map using a given hash map and a big list of 64-bit signatures.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(Object o) |
Long |
get(Object o) |
long |
getLong(Object o) |
ObjectBigList<CharSequence> |
list()
Returns a list view of the domain of this string map (optional operation).
|
static void |
main(String[] arg) |
static void |
sign(Iterator<? extends CharSequence> iterator,
DataOutput signatures,
ProgressLogger pl)
Generates an on-disk list 64-bit signatures big array using a given string sequence.
|
static long[][] |
sign(Iterator<? extends CharSequence> iterator,
Object2LongFunction<? extends CharSequence> function)
Generates a 64-bit signatures big array using a given function and string sequence.
|
static long[][] |
sign(Iterator<? extends CharSequence> iterator,
Object2LongFunction<? extends CharSequence> function,
ProgressLogger pl)
Generates a 64-bit signatures big array using a given function and string sequence.
|
static void |
sign(Iterator<? extends CharSequence> iterator,
String signatureFile)
Generates an on-disk list 64-bit signatures big array using a given string sequence.
|
static void |
sign(Iterator<? extends CharSequence> iterator,
String signatureFile,
ProgressLogger pl)
Generates an on-disk list 64-bit signatures big array using a given string sequence.
|
int |
size()
Deprecated.
|
long |
size64() |
clear, defaultReturnValue, defaultReturnValue, put, put, remove, removeLong
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
defaultReturnValue, defaultReturnValue, put, removeLong
protected final Object2LongFunction<? extends CharSequence> function
protected final LongBigList signatures
public LongBigListSignedStringMap(Object2LongFunction<? extends CharSequence> function, LongBigList signatures)
function
- a minimal perfect hash for the strings enumerated by iterator
; it must support size()
.
and have default return value -1.signatures
- a big list of 64-bit signatures generated by sign(Iterator, Object2LongFunction, ProgressLogger)
.public LongBigListSignedStringMap(Object2LongFunction<? extends CharSequence> function, String signatures) throws FileNotFoundException, IOException
function
- a minimal perfect hash for the strings enumerated by iterator
; it must support size()
.
and have default return value -1.signatures
- a file containing a list of 64-bit signatures
generated by sign(Iterator, Object2LongFunction, ProgressLogger)
and stored in DataOutput
format.FileNotFoundException
IOException
public static long[][] sign(Iterator<? extends CharSequence> iterator, Object2LongFunction<? extends CharSequence> function)
The resulting big array can be saved using BinIO.storeLongs(long[][], CharSequence)
or similar BinIO
methods.
iterator
- an iterator over a list of strings.function
- the function to be signed.public static long[][] sign(Iterator<? extends CharSequence> iterator, Object2LongFunction<? extends CharSequence> function, ProgressLogger pl)
The resulting big array can be saved using BinIO.storeLongs(long[][], CharSequence)
or similar BinIO
methods.
iterator
- an iterator over a list of strings.function
- the function to be signed.pl
- a progress logger, or null
.public static void sign(Iterator<? extends CharSequence> iterator, String signatureFile) throws IOException
This methods generates on-disk signatures in the same order of the strings returned by the provided iterator. Thus, the signature file can be only used with a function that maps each string returned by the iterator in its ordinal position. This happens, for instance, if you have a sorted set of string and you use a monotone minimal perfect hash function.
iterator
- an iterator over a list of strings.signatureFile
- the file name of the resulting signature file.IOException
public static void sign(Iterator<? extends CharSequence> iterator, String signatureFile, ProgressLogger pl) throws IOException
iterator
- an iterator over a list of strings.signatureFile
- the file name of the resulting signature file.pl
- a progress logger, or null
.IOException
sign(Iterator, DataOutput, ProgressLogger)
public static void sign(Iterator<? extends CharSequence> iterator, DataOutput signatures, ProgressLogger pl) throws IOException
This methods generates on-disk signatures in the same order of the strings returned by the provided iterator. Thus, the generated signatures can be only used with a function that maps each string returned by the iterator in its ordinal position. This happens, for instance, if you have a sorted set of string and you use a monotone minimal perfect hash function.
iterator
- an iterator over a list of strings.signatures
- a DataOutput
where the signatures will be written.pl
- a progress logger, or null
.IOException
public long getLong(Object o)
getLong
in interface Object2LongFunction<CharSequence>
public Long get(Object o)
get
in interface Function<CharSequence,Long>
get
in class AbstractObject2LongFunction<CharSequence>
public boolean containsKey(Object o)
containsKey
in interface Function<CharSequence,Long>
@Deprecated public int size()
public ObjectBigList<CharSequence> list()
StringMap
Note that the list view acts as an inverse of the mapping implemented by this map.
list
in interface StringMap<CharSequence>
null
if this map does
not support this operation.public static void main(String[] arg) throws NoSuchMethodException, IOException, JSAPException, ClassNotFoundException