gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/lava gzz/storm/IndexedPool.java gzz/storm/i...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava gzz/storm/IndexedPool.java gzz/storm/i...
Date: Mon, 13 Jan 2003 18:47:18 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/13 18:47:17

Modified files:
        lava/gzz/storm : IndexedPool.java 
        lava/gzz/storm/impl: AbstractPool.java DirPool.java 
        lava/test/gzz/storm: ContentTypeIndexType.java IndexedPool.meta 
        lava/test/gzz/storm/impl: DirPoolIndexing.test 

Log message:
        Hups, got that wrong on first try-- correct

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/IndexedPool.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/AbstractPool.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/ContentTypeIndexType.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/IndexedPool.meta.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/storm/IndexedPool.java
diff -u gzz/lava/gzz/storm/IndexedPool.java:1.11 
gzz/lava/gzz/storm/IndexedPool.java:1.12
--- gzz/lava/gzz/storm/IndexedPool.java:1.11    Mon Dec 30 11:02:02 2002
+++ gzz/lava/gzz/storm/IndexedPool.java Mon Jan 13 18:47:16 2003
@@ -137,13 +137,13 @@
     /** Get the Index object for a given IndexType.
      *  Equivalent to <code>getIndices().get(type)</code>.
      */
-    Object getIndex(String typeURI);
+    Object getIndex(String typeURI) throws IOException;
 
     /** Return a mapping from index type URIs
      *  to <code>Index</code> objects. This map
      *  cannot be modified.
      */
-    Map getIndices();
+    Map getIndices() throws IOException;
 
     /** A convenience method to get a <code>Pointer</code> instance
      *  for this pool. This is defined always to return this:
Index: gzz/lava/gzz/storm/impl/AbstractPool.java
diff -u gzz/lava/gzz/storm/impl/AbstractPool.java:1.10 
gzz/lava/gzz/storm/impl/AbstractPool.java:1.11
--- gzz/lava/gzz/storm/impl/AbstractPool.java:1.10      Mon Jan 13 18:21:44 2003
+++ gzz/lava/gzz/storm/impl/AbstractPool.java   Mon Jan 13 18:47:17 2003
@@ -32,7 +32,12 @@
     private static void pa(String s) { System.out.println(s); }
 
     protected Set indexTypes;
-    protected Map indices;
+
+    /**
+     *  <code>null</code> until initializeIndices() has been called
+     *  for the first time.
+     */
+    protected Map indices = null;
 
     /** Get a DB implementation associated with
      *  the given index type URI.
@@ -44,6 +49,12 @@
     protected abstract DB getDB(String typeURI) throws IOException;
 
     public AbstractPool(Set indexTypes) throws IOException {
+       this.indexTypes = indexTypes;
+    }
+
+    protected final void initializeIndices() throws IOException {
+       if(this.indices != null) return;
+
        Map indices = new HashMap();
 
        for(Iterator i=indexTypes.iterator(); i.hasNext();) {
@@ -53,17 +64,19 @@
            indices.put(uri, type.createIndex(this, getDB(uri)));
        }
 
-       this.indexTypes = indexTypes;
        this.indices = Collections.unmodifiableMap(indices);
     }
 
-    public Map getIndices() { return indices; }
+    public Map getIndices() throws IOException {
+       initializeIndices(); 
+       return indices; 
+    }
 
-    public Object getIndex(String indexTypeURI) {
+    public Object getIndex(String indexTypeURI) throws IOException {
        return getIndices().get(indexTypeURI);
     }
 
-    public Pointer getPointer(String uri) {
+    public Pointer getPointer(String uri) throws IOException {
        Object index = getIndex(PointerIndexType.indexTypeURI);
        return ((PointerIndexType.Index)index).getPointer(uri);
     }
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.17 
gzz/lava/gzz/storm/impl/DirPool.java:1.18
--- gzz/lava/gzz/storm/impl/DirPool.java:1.17   Mon Jan 13 18:21:44 2003
+++ gzz/lava/gzz/storm/impl/DirPool.java        Mon Jan 13 18:47:17 2003
@@ -108,6 +108,8 @@
        protected File dbDir;
 
        protected DirDB(String indexTypeURI) throws IOException {
+           if(dir == null) throw new Error("Directory not initialized");
+           
            byte[] ascii = indexTypeURI.getBytes("US-ASCII");
            String hex = HexUtil.byteArrToHex(ascii);
            dbDir = new File(dir, "idx_"+hex);
@@ -156,6 +158,10 @@
            os.write(HexUtil.byteArrToHex(m.value).getBytes("US-ASCII"));
            os.write((byte)'\n');
            os.close();
+       }
+
+       public String toString() {
+           return "<DirDB '"+dbDir+"'>";
        }
     }
 
Index: gzz/lava/test/gzz/storm/ContentTypeIndexType.java
diff -u gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.2 
gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.3
--- gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.2       Sat Jan 11 
13:10:08 2003
+++ gzz/lava/test/gzz/storm/ContentTypeIndexType.java   Mon Jan 13 18:47:17 2003
@@ -44,6 +44,7 @@
         *  XXX For real use, this should not block.
         */
        public Set getBlocks(String contentType) throws IOException {
+           System.out.println("Getblocks: "+db+" -- "+contentType);
            byte[] key = contentType.getBytes("US-ASCII");
            Collection mappings = db.get(key).block();
 
Index: gzz/lava/test/gzz/storm/IndexedPool.meta
diff -u gzz/lava/test/gzz/storm/IndexedPool.meta:1.2 
gzz/lava/test/gzz/storm/IndexedPool.meta:1.3
--- gzz/lava/test/gzz/storm/IndexedPool.meta:1.2        Sat Jan 11 13:10:08 2003
+++ gzz/lava/test/gzz/storm/IndexedPool.meta    Mon Jan 13 18:47:17 2003
@@ -34,6 +34,7 @@
     i = p.getIndex(gzz.storm.ContentTypeIndexType.contentTypeIndexTypeURI)
 
     assert i != None
+    print i.getBlocks("text/plain")
     assert i.getBlocks("text/plain") == set([])
 
     os = p.getBlockOutputStream("text/plain")
Index: gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test
diff -u gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test:1.1 
gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test:1.2
--- gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test:1.1       Mon Jan 13 
18:21:44 2003
+++ gzz/lava/test/gzz/storm/impl/DirPoolIndexing.test   Mon Jan 13 18:47:17 2003
@@ -18,12 +18,15 @@
 
 import gzz, java
 
-def pool(indexTypes):
-    directory = gzz.util.TempFileUtil.tmpFile(java.io.File("."));
-    directory.mkdir();
+directory = gzz.util.TempFileUtil.tmpFile(java.io.File("."));
+directory.mkdir();
 
+def pool(indexTypes):
     set = java.util.HashSet()
     for el in indexTypes: set.add(el)
     return gzz.storm.impl.DirPool(directory, set)
+
+def tearDown():
+    gzz.util.TempFileUtil.deltree(directory)
 
 execfile("lava/test/gzz/storm/IndexedPool.meta")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]