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 term number with a local index out of a given set and a local term number in the local index.
25: *
26: * <p>When partitioning lexically an index (i.e., termwise), we need a way to associate
27: * to each term {@linkplain #localIndex(int) a local index} (the index
28: * that will contain the postings of that term) and {@linkplain #localNumber(int) a local
29: * term number} (the number of the term in the local index).
30: *
31: * <p>Usually, a lexical partitioning strategy has a matching
32: * {@link it.unimi.dsi.mg4j.index.cluster.LexicalClusteringStrategy} whose methods
33: * satisfy the following equations:
34: * <pre style="margin: 1em 0; text-align:center">
35: * globalNumber(localIndex(t), localNumber(t)) = t
36: * <localIndex(globalNumber(i, l)), localNumber(globalNumber(i, l))> = <i, l>
37: * </pre>
38: *
39: * @author Alessandro Arrabito
40: * @author Sebastiano Vigna
41: */
42:
43: public interface LexicalPartitioningStrategy extends
44: PartitioningStrategy {
45: /** Returns the index to which a given term number is mapped by this strategy.
46: *
47: * @param globalNumber the term global number.
48: * @return the corresponding local index, or -1 if the term should be removed from the partitioned index.
49: */
50: int localIndex(int globalNumber);
51:
52: /** Returns the local term number given a global term number.
53: * @param globalNumber a global term number.
54: * @return the corresponding local term number, or -1 if the term should be removed from the partitioned index.
55: */
56: int localNumber(final int globalNumber);
57: }
|