Package it.unimi.dsi.law.webgraph
Class CompressedIntLabel
java.lang.Object
it.unimi.dsi.webgraph.labelling.AbstractLabel
it.unimi.dsi.webgraph.labelling.AbstractIntLabel
it.unimi.dsi.law.webgraph.CompressedIntLabel
- All Implemented Interfaces:
FlyweightPrototype<Label>
,Label
,Serializable
public class CompressedIntLabel extends AbstractIntLabel implements Serializable
An integer label that uses a coder/decoder pair depending on the source node.
This is a kind of int label whose serialization (fromBitStream(InputBitStream, int)
and toBitStream(OutputBitStream, int)
methods) rely on a coder/decoder pair that may depend on the source node of the arc.
Different constructors provide different ways to assign coders/decoders to source nodes: consult their documentation for more information.
More precisely, the public field nodeLabels
exposes a list of labels for nodes. Decoders are chosen depending on the label provided
by the list.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG
LongBigList
nodeLabels
The node labels stream containing the node labels.Fields inherited from class it.unimi.dsi.webgraph.labelling.AbstractIntLabel
key, value
Fields inherited from interface it.unimi.dsi.webgraph.labelling.Label
EMPTY_LABEL_ARRAY
-
Constructor Summary
Constructors Modifier Constructor Description CompressedIntLabel(Object directory, String key, String value, String labels, String nodeWidth, String decoders)
Creates a compressed integer label from a specification that includes just decoders.CompressedIntLabel(Object directory, String key, String value, String labels, String nodeWidth, String decoders, String coders)
Creates a compressed integer label from a specification that includes decoders and coders.CompressedIntLabel(String key, int value, LongBigList nodeLabels, Int2ObjectMap<Decoder> sourceLabel2Decoder, Int2ObjectMap<Coder> sourceLabel2Coder)
Creates a compressed integer label.protected
CompressedIntLabel(String key, int value, String labelSpec, LongBigList nodeLabels, Int2ObjectMap<Coder> source2Coder, Int2ObjectMap<Decoder> source2Decoder)
-
Method Summary
Modifier and Type Method Description CompressedIntLabel
copy()
int
fixedWidth()
int
fromBitStream(InputBitStream inputBitStream, int source)
int
toBitStream(OutputBitStream outputBitStream, int source)
String
toSpec()
Methods inherited from class it.unimi.dsi.webgraph.labelling.AbstractIntLabel
attributeKeys, attributeTypes, equals, get, get, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, hashCode, toString, wellKnownAttributeKey
Methods inherited from class it.unimi.dsi.webgraph.labelling.AbstractLabel
getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShort
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface it.unimi.dsi.webgraph.labelling.Label
getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShort
-
Field Details
-
DEBUG
public static final boolean DEBUG- See Also:
- Constant Field Values
-
nodeLabels
The node labels stream containing the node labels.
-
-
Constructor Details
-
CompressedIntLabel
protected CompressedIntLabel(String key, int value, String labelSpec, LongBigList nodeLabels, Int2ObjectMap<Coder> source2Coder, Int2ObjectMap<Decoder> source2Decoder) -
CompressedIntLabel
public CompressedIntLabel(String key, int value, LongBigList nodeLabels, Int2ObjectMap<Decoder> sourceLabel2Decoder, Int2ObjectMap<Coder> sourceLabel2Coder)Creates a compressed integer label.- Parameters:
key
- the key.value
- the value.nodeLabels
- the node labels.sourceLabel2Decoder
- a map assigning a decoder to every possible node label; note that the number of node labels is 2w, where w isnodeLabelPrototype.fixedWidth()
.sourceLabel2Coder
- an optional map assigning a coder to every possible node label, ornull
; note that the number of node labels is 2w, where w isnodeLabelPrototype.fixedWidth()
.
-
CompressedIntLabel
public CompressedIntLabel(Object directory, String key, String value, String labels, String nodeWidth, String decoders, String coders) throws NumberFormatException, FileNotFoundException, IOException, ClassNotFoundExceptionCreates a compressed integer label from a specification that includes decoders and coders.Warning: the entire node-label stream is loaded into memory by this method.
- Parameters:
key
- the key of this label.value
- the value of this label.labels
- the filename of the file of labels.nodeWidth
- the width in bits of a node label.decoders
- the filename of a serialisedInt2ObjectMap
mapping node labels to decoders.coders
- the filename of a serialisedInt2ObjectMap
mapping node labels to coders.- Throws:
NumberFormatException
FileNotFoundException
IOException
ClassNotFoundException
-
CompressedIntLabel
public CompressedIntLabel(Object directory, String key, String value, String labels, String nodeWidth, String decoders) throws NumberFormatException, FileNotFoundException, IOException, ClassNotFoundExceptionCreates a compressed integer label from a specification that includes just decoders.Warning: the entire node-label stream is loaded into memory by this method.
- Parameters:
key
- the key of this label.value
- the value of this label.labels
- the filename of the file of nodes labels.nodeWidth
- the width in bits of a node label.decoders
- the filename of a serialisedInt2ObjectMap
mapping node labels to decoders.- Throws:
NumberFormatException
FileNotFoundException
IOException
ClassNotFoundException
-
-
Method Details
-
copy
- Specified by:
copy
in interfaceFlyweightPrototype<Label>
- Specified by:
copy
in interfaceLabel
-
fromBitStream
- Specified by:
fromBitStream
in interfaceLabel
- Throws:
IOException
-
toBitStream
- Specified by:
toBitStream
in interfaceLabel
- Throws:
IOException
-
fixedWidth
public int fixedWidth()- Specified by:
fixedWidth
in interfaceLabel
-
toSpec
-