01: package it.unimi.dsi.mg4j.index.cluster;
02:
03: /*
04: * MG4J: Managing Gigabytes for Java
05: *
06: * Copyright (C) 2006-2007 Sebastiano Vigna
07: *
08: * This library is free software; you can redistribute it and/or modify it
09: * under the terms of the GNU Lesser General Public License as published by the Free
10: * Software Foundation; either version 2.1 of the License, or (at your option)
11: * any later version.
12: *
13: * This library is distributed in the hope that it will be useful, but
14: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16: * for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: *
22: */
23:
24: import java.io.Serializable;
25:
26: /** A documental strategy that maps identically local to global pointers and viceversa.
27: *
28: * <p>When clustering <i>a posteriory</i> a set of previously built renumbered indices
29: * using a {@link it.unimi.dsi.mg4j.index.cluster.DocumentalMergedCluster},
30: * local document pointers are actually global document pointers.
31: * In this case, an instance of this class should be used as a strategy
32: * for the cluster.
33: *
34: * @author Sebastiano Vigna
35: */
36:
37: public class IdentityDocumentalStrategy implements
38: DocumentalClusteringStrategy, Serializable {
39:
40: private static final long serialVersionUID = 0L;
41:
42: /** The number of local indices. */
43: private final int numberOfLocalIndices;
44: /** The number of documents. */
45: private final int numberOfDocuments;
46:
47: /** Creates a new identity documental clustering strategy.
48: *
49: * @param numberOfLocalIndices the number of local indices.
50: * @param numberOfDocuments the number of documents.
51: */
52:
53: public IdentityDocumentalStrategy(final int numberOfLocalIndices,
54: final int numberOfDocuments) {
55: this .numberOfLocalIndices = numberOfLocalIndices;
56: this .numberOfDocuments = numberOfDocuments;
57: }
58:
59: public int numberOfLocalIndices() {
60: return numberOfLocalIndices;
61: }
62:
63: public int localPointer(final int globalPointer) {
64: return globalPointer;
65: }
66:
67: public int globalPointer(final int localIndex,
68: final int localPointer) {
69: return localPointer;
70: }
71:
72: public int numberOfDocuments(final int localIndex) {
73: return numberOfDocuments;
74: }
75:
76: public String toString() {
77: return this .getClass().getName() + "[local indices: "
78: + numberOfLocalIndices + " documents: "
79: + numberOfDocuments + "]";
80: }
81: }
|