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: /** A way to associate a document with a local index out of a given set and a local document number in the local index.
25: *
26: * <p>When partitioning documentally an index, we need a way to associate
27: * to each global document pointer {@linkplain #localIndex(int) a local index} (the index
28: * that will contain the postings of that document) and {@linkplain #localPointer(int) a local
29: * document pointer} (the document pointer actually represented in the local index).
30: *
31: * <p>Usually, a documental partitioning strategy has a matching
32: * {@link it.unimi.dsi.mg4j.index.cluster.DocumentalClusteringStrategy}
33: * whose methods satisfy the following equations:
34: * <pre style="margin: 1em 0; text-align:center">
35: * globalPointer(localIndex(d), localPointer(d)) = d
36: * <localIndex(globalPointer(i, l)), localPointer(globalPointer(i, l))> = <i, l>
37: * </pre>
38: *
39: * @author Alessandro Arrabito
40: * @author Sebastiano Vigna
41: */
42:
43: public interface DocumentalPartitioningStrategy extends
44: PartitioningStrategy {
45:
46: /** Returns the index to which a given global document pointer is be mapped by this strategy.
47: *
48: * @param globalPointer a global document pointer.
49: * @return the corresponding local index.
50: */
51: int localIndex(final int globalPointer);
52:
53: /** Returns the local document pointer corresponding to a global document pointer.
54: *
55: * @param globalPointer a global document pointer.
56: * @return the corresponding local document pointer.
57: */
58: int localPointer(int globalPointer);
59:
60: /** Returns the number of documents that will be assigned to the given local index.
61: *
62: * @param localIndex the local index.
63: * @return the number of documents that will be assigned to <code>localIndex</code>.
64: */
65: int numberOfDocuments(int localIndex);
66: }
|