it.unimi.di.mg4j.index.cluster
Class ContiguousDocumentalStrategy

java.lang.Object
  extended by it.unimi.di.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
ContiguousDocumentalStrategy(int... cutPoint)
          Creates a new contiguous strategy with the given cutpoints.
 
Method Summary
 int globalPointer(int localIndex, int localPointer)
          Returns the global document pointer given a local index and a local document pointer.
 int localIndex(int globalPointer)
          Returns the index to which a given global document pointer is be mapped by this strategy.
 int localPointer(int globalPointer)
          Returns the local document pointer corresponding to a global document pointer.
 int 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContiguousDocumentalStrategy

public ContiguousDocumentalStrategy(int... 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 interface ClusteringStrategy
Specified by:
numberOfLocalIndices in interface PartitioningStrategy
Returns:
the number of local indices created by this strategy.

localIndex

public int localIndex(int 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 interface DocumentalPartitioningStrategy
Parameters:
globalPointer - a global document pointer.
Returns:
the corresponding local index.

localPointer

public int localPointer(int globalPointer)
Description copied from interface: DocumentalPartitioningStrategy
Returns the local document pointer corresponding to a global document pointer.

Specified by:
localPointer in interface DocumentalClusteringStrategy
Specified by:
localPointer in interface DocumentalPartitioningStrategy
Parameters:
globalPointer - a global document pointer.
Returns:
the corresponding local document pointer.

globalPointer

public int globalPointer(int localIndex,
                         int localPointer)
Description copied from interface: DocumentalClusteringStrategy
Returns the global document pointer given a local index and a local document pointer.

Specified by:
globalPointer in interface DocumentalClusteringStrategy
Parameters:
localIndex - the local index.
localPointer - the local document pointer in localIndex.
Returns:
the global document pointer.

numberOfDocuments

public int 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 interface DocumentalClusteringStrategy
Specified by:
numberOfDocuments in interface DocumentalPartitioningStrategy
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 interface PartitioningStrategy
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).

toString

public String toString()
Overrides:
toString in class Object