/[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.2 by benja, Thu May 22 21:32:45 2003 UTC revision 1.3 by benja, Thu May 22 22:03:52 2003 UTC
# Line 44  public class TitleIndex { Line 44  public class TitleIndex {
44    
45      protected IndexedPool pool;      protected IndexedPool pool;
46      protected IndexedPool.DB db;      protected IndexedPool.DB db;
47        protected PointerIndex pointerIndex;
48    
49        /** Returns a set of *current* pointer blocks.
50         */
51        public Set getPointers(String query) throws IOException {
52            Iterator i=splitWords(query).iterator();
53            if(!i.hasNext()) return new HashSet();
54            Set refs = new HashSet(db.get((String)i.next()).block());
55            while(i.hasNext())
56                refs.retainAll(db.get((String)i.next()).block());
57    
58            Set result = new HashSet();
59            for(i=refs.iterator(); i.hasNext();) {
60                IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();
61                try {
62                    PointerId id = new PointerId(m.value);
63                    PointerBlock cur = pointerIndex.getPointerBlock(id);
64                    if(cur.getBlockId().equals(m.block))
65                        result.add(cur);
66                } catch(Throwable _) {
67                    // bad data, ignore
68                    continue;
69                }
70            }
71    
72            return result;
73        }
74    
75      /** Return a set of words from a title.      /** Return a set of words from a title.
76       *  E.g. "Hifi sp82;kzz1 anT hifi anT"       *  E.g. "Hifi sp82;kzz1 anT hifi anT"
# Line 84  public class TitleIndex { Line 111  public class TitleIndex {
111              String name = p.getName();              String name = p.getName();
112              if(name == null) return mappings;              if(name == null) return mappings;
113    
114              // Mapping pointer id -> pointer blocks              Set words = splitWords(name);
115              // for resolving a pointer  
116              mappings.add(new IndexedPool.Mapping(block.getId(),              for(Iterator i=words.iterator(); i.hasNext();) {
117                                                   p.getPointer().toString(),                  // Mapping word in title -> pointer
118                                                   ""+p.getTimestamp()));                  mappings.add(new IndexedPool.Mapping(block.getId(),
119                                                         (String)i.next(),
120              // Mapping "" -> pointer id                                                       p.getPointer().getURI()));
121              // for finding all pointers              }
             mappings.add(new IndexedPool.Mapping(block.getId(), "",  
                                                  p.getPointer().toString()));  
122    
123              return mappings;              return mappings;
124          }          }
125    
126          public Object createIndex(IndexedPool pool,          public Object createIndex(IndexedPool pool,
127                                    IndexedPool.DB db) {                                    IndexedPool.DB db) {
128              return new PointerIndex(pool, db);              return new TitleIndex(pool, db);
129          }          }
130                    
131          public String getIndexTypeURI() {          public String getIndexTypeURI() {
# Line 108  public class TitleIndex { Line 133  public class TitleIndex {
133          }          }
134                    
135          public String getHumanReadableName() {          public String getHumanReadableName() {
136              return ("An index of 0.1 pointer blocks by pointer URN.");              return ("An index of 0.1 pointers by pointer title.");
137          }          }
138      }      }
139    
140      public TitleIndex(IndexedPool pool, IndexedPool.DB db) {      public TitleIndex(IndexedPool pool, IndexedPool.DB db) {
141          this.pool = pool;          this.pool = pool;
142          this.db = db;          this.db = db;
143            this.pointerIndex =
144                (PointerIndex)pool.getIndex(PointerIndex.uri);
145      }      }
146  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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