/[storm]/storm/org/nongnu/storm/pointers/TitleIndex.java
ViewVC logotype

Diff of /storm/org/nongnu/storm/pointers/TitleIndex.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by benja, Thu May 22 22:41:05 2003 UTC revision 1.5 by benja, Thu May 22 22:54:42 2003 UTC
# Line 28  PointerBlock.java Line 28  PointerBlock.java
28  package org.nongnu.storm.pointers;  package org.nongnu.storm.pointers;
29  import org.nongnu.storm.*;  import org.nongnu.storm.*;
30  import org.nongnu.storm.impl.AsyncSetCollector;  import org.nongnu.storm.impl.AsyncSetCollector;
31    import org.nongnu.storm.util.Pair;
32  import java.util.*;  import java.util.*;
33  import com.bitzi.util.*;  import com.bitzi.util.*;
34  import java.io.*;  import java.io.*;
# Line 51  public class TitleIndex { Line 52  public class TitleIndex {
52      public Set getPointers(String query) throws IOException {      public Set getPointers(String query) throws IOException {
53          Iterator i=splitWords(query).iterator();          Iterator i=splitWords(query).iterator();
54          if(!i.hasNext()) return new HashSet();          if(!i.hasNext()) return new HashSet();
55          Set refs = new HashSet(db.get((String)i.next()).block());          Set refs = new HashSet(getWordRefs((String)i.next()));
56          while(i.hasNext())          while(i.hasNext())
57              refs.retainAll(db.get((String)i.next()).block());              refs.retainAll(getWordRefs((String)i.next()));
58    
59          Set result = new HashSet();          Set result = new HashSet();
60          for(i=refs.iterator(); i.hasNext();) {          for(i=refs.iterator(); i.hasNext();) {
61              IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();              Pair pair = (Pair)i.next();
62              try {              try {
63                  PointerId id = new PointerId(m.value);                  PointerId id = new PointerId((String)pair.second);
64                  PointerBlock cur = pointerIndex().getPointerBlock(id);                  PointerBlock cur = pointerIndex().getPointerBlock(id);
65                  if(cur.getBlockId().equals(m.block))                  if(cur.getBlockId().equals(pair.first))
66                      result.add(cur);                      result.add(cur);
67              } catch(Throwable _) {              } catch(Throwable _) {
68                  // bad data, ignore                  // bad data, ignore
# Line 96  public class TitleIndex { Line 97  public class TitleIndex {
97          return words;          return words;
98      }      }
99    
100        protected Set getWordRefs(String word) throws IOException {
101            Collection mappings = db.get(word).block();
102            Set result = new HashSet();
103            for(Iterator i=mappings.iterator(); i.hasNext();) {
104                IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();
105                result.add(new Pair(m.block, m.value));
106            }
107            return result;
108        }
109    
110      protected static class IndexType implements IndexedPool.IndexType {      protected static class IndexType implements IndexedPool.IndexType {
111          public Set getMappings(Block block) throws IOException {          public Set getMappings(Block block) throws IOException {
112              PointerBlock p;              PointerBlock p;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26