Class ContiguousDocumentalStrategy
- java.lang.Object
-
- it.unimi.di.big.mg4j.index.cluster.ContiguousDocumentalStrategy
-
- All Implemented Interfaces:
ClusteringStrategy
,DocumentalClusteringStrategy
,DocumentalPartitioningStrategy
,PartitioningStrategy
,Serializable
public class ContiguousDocumentalStrategy extends Object implements DocumentalPartitioningStrategy, DocumentalClusteringStrategy, Serializable
A documental partitioning and clustering strategy that partitions an index into contiguous segments.To partition an index in contiguous parts, you must provide an array of cutpoints, which define each part. More precisely, given cutpoints c0,c2,…,ck, the global index will be partitioned into k local indices containing the documents from c0 (included) to c1 (excluded), from c1 (included) to c2 and so on. Note that necessarily c0=0 and ck=N, where N is the number of globally indexed documents.
The
properties()
method provides two properties, pointerfrom and pointerto, that contain the first (included) and last (excluded) pointer in the local index.- Author:
- Alessandro Arrabito, Sebastiano Vigna
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ContiguousDocumentalStrategy(long... cutPoint)
Creates a new contiguous strategy with the given cutpoints.
-
Method Summary
Modifier and Type Method Description long
globalPointer(int localIndex, long localPointer)
Returns the global document pointer given a local index and a local document pointer.int
localIndex(long globalPointer)
Returns the index to which a given global document pointer is be mapped by this strategy.long
localPointer(long globalPointer)
Returns the local document pointer corresponding to a global document pointer.long
numberOfDocuments(int localIndex)
Returns the number of documents that will be assigned to the given local index.int
numberOfLocalIndices()
Returns the number of local indices created by this strategy.Properties[]
properties()
Returns an array of properties, one for each local index, that specify additional information about local indices.String
toString()
-
-
-
Constructor Detail
-
ContiguousDocumentalStrategy
public ContiguousDocumentalStrategy(long... cutPoint)
Creates a new contiguous strategy with the given cutpoints.Note that
DocumentalStrategies
has ready-made factory methods for the common cases.- Parameters:
cutPoint
- an array of cutpoints (see the class description}.
-
-
Method Detail
-
numberOfLocalIndices
public int numberOfLocalIndices()
Description copied from interface:PartitioningStrategy
Returns the number of local indices created by this strategy.- Specified by:
numberOfLocalIndices
in interfaceClusteringStrategy
- Specified by:
numberOfLocalIndices
in interfacePartitioningStrategy
- Returns:
- the number of local indices created by this strategy.
-
localIndex
public int localIndex(long globalPointer)
Description copied from interface:DocumentalPartitioningStrategy
Returns the index to which a given global document pointer is be mapped by this strategy.- Specified by:
localIndex
in interfaceDocumentalPartitioningStrategy
- Parameters:
globalPointer
- a global document pointer.- Returns:
- the corresponding local index.
-
localPointer
public long localPointer(long globalPointer)
Description copied from interface:DocumentalPartitioningStrategy
Returns the local document pointer corresponding to a global document pointer.- Specified by:
localPointer
in interfaceDocumentalClusteringStrategy
- Specified by:
localPointer
in interfaceDocumentalPartitioningStrategy
- Parameters:
globalPointer
- a global document pointer.- Returns:
- the corresponding local document pointer.
-
globalPointer
public long globalPointer(int localIndex, long localPointer)
Description copied from interface:DocumentalClusteringStrategy
Returns the global document pointer given a local index and a local document pointer.- Specified by:
globalPointer
in interfaceDocumentalClusteringStrategy
- Parameters:
localIndex
- the local index.localPointer
- the local document pointer inlocalIndex
.- Returns:
- the global document pointer.
-
numberOfDocuments
public long numberOfDocuments(int localIndex)
Description copied from interface:DocumentalPartitioningStrategy
Returns the number of documents that will be assigned to the given local index.- Specified by:
numberOfDocuments
in interfaceDocumentalClusteringStrategy
- Specified by:
numberOfDocuments
in interfaceDocumentalPartitioningStrategy
- Parameters:
localIndex
- the local index.- Returns:
- the number of documents that will be assigned to
localIndex
.
-
properties
public Properties[] properties()
Description copied from interface:PartitioningStrategy
Returns an array of properties, one for each local index, that specify additional information about local indices.- Specified by:
properties
in interfacePartitioningStrategy
- Returns:
- an array of properties, one for each local index; any element
can be
null
(in that case, the set of properties is assumed to be empty).
-
-