gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/lava gzz/storm/impl/DirDB.java gzz/storm/im...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava gzz/storm/impl/DirDB.java gzz/storm/im...
Date: Mon, 13 Jan 2003 21:30:44 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/13 21:30:43

Modified files:
        lava/gzz/storm/impl: DirDB.java DirPool.java 
        lava/test/gzz/storm: IndexedPool.meta 

Log message:
        Make DirPool indexing reliable

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirDB.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/IndexedPool.meta.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/storm/impl/DirDB.java
diff -u gzz/lava/gzz/storm/impl/DirDB.java:1.1 
gzz/lava/gzz/storm/impl/DirDB.java:1.2
--- gzz/lava/gzz/storm/impl/DirDB.java:1.1      Mon Jan 13 19:02:26 2003
+++ gzz/lava/gzz/storm/impl/DirDB.java  Mon Jan 13 21:30:43 2003
@@ -30,6 +30,9 @@
            OutputStream os = new FileOutputStream(new File(dbDir, 
"index_type"));
            os.write(ascii); os.write((byte)'\n');
            os.close();
+
+           os = new FileOutputStream(new File(dbDir, "indexed_blocks"));
+           os.close();
        }
     }
     
@@ -61,11 +64,35 @@
        return new SimpleSetCollector(result);
     }
     
+    public Set getIndexed() throws IOException {
+       HashSet result = new HashSet();
+
+       InputStream in = new FileInputStream(new File(dbDir, "indexed_blocks"));
+       Reader ir = new InputStreamReader(in, "US-ASCII");
+       BufferedReader r = new BufferedReader(ir);
+           
+       String line = r.readLine();
+       while(line != null && !line.equals("")) {
+           result.add(new BlockId(line));
+           line = r.readLine();
+       }
+
+       return result;
+    }
+
     public void add(IndexedPool.Mapping m) throws IOException {
+       if(getIndexed().contains(m.block))
+           return;
+
        OutputStream os = new FileOutputStream(getKeyFile(m.key), true);
        os.write(m.block.getURI().getBytes("US-ASCII"));
        os.write((byte)' ');
        os.write(HexUtil.byteArrToHex(m.value).getBytes("US-ASCII"));
+       os.write((byte)'\n');
+       os.close();
+
+       os = new FileOutputStream(new File(dbDir, "indexed_blocks"), true);
+       os.write(m.block.getURI().getBytes("US-ASCII"));
        os.write((byte)'\n');
        os.close();
     }
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.20 
gzz/lava/gzz/storm/impl/DirPool.java:1.21
--- gzz/lava/gzz/storm/impl/DirPool.java:1.20   Mon Jan 13 19:14:51 2003
+++ gzz/lava/gzz/storm/impl/DirPool.java        Mon Jan 13 21:30:43 2003
@@ -166,10 +166,19 @@
        if(dir == null || dbs == null)
            throw new IllegalStateException("Not initialized yet");
 
-       DB db = (DB)dbs.get(typeURI);
+       DirDB db = (DirDB)dbs.get(typeURI);
        if(db == null) {
            db = new DirDB(dir, typeURI);
            dbs.put(typeURI, db);
+
+           Set indexed = db.getIndexed();
+           Set missing = new HashSet(getIds());
+           missing.removeAll(indexed);
+
+           for(Iterator i=missing.iterator(); i.hasNext();) {
+               BlockId id = (BlockId)i.next();
+               added(get(id));
+           }
        }
        return db;
     }
Index: gzz/lava/test/gzz/storm/IndexedPool.meta
diff -u gzz/lava/test/gzz/storm/IndexedPool.meta:1.5 
gzz/lava/test/gzz/storm/IndexedPool.meta:1.6
--- gzz/lava/test/gzz/storm/IndexedPool.meta:1.5        Mon Jan 13 20:04:46 2003
+++ gzz/lava/test/gzz/storm/IndexedPool.meta    Mon Jan 13 21:30:43 2003
@@ -62,6 +62,3 @@
     assert i.getBlocks("text/enriched") == set([])
 
     assert i == 
p.getIndex(gzz.storm.ContentTypeIndexType.contentTypeIndexTypeURI)
-       
-       
-




reply via email to

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