[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/lava gzz/storm/impl/DirPool.java test/gzz/s...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/lava gzz/storm/impl/DirPool.java test/gzz/s... |
Date: |
Mon, 13 Jan 2003 19:02:27 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 03/01/13 19:02:26
Modified files:
lava/gzz/storm/impl: DirPool.java
lava/test/gzz/storm: ContentTypeIndexType.java IndexedPool.meta
Added files:
lava/gzz/storm/impl: DirDB.java
Log message:
Refactor
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirDB.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/ContentTypeIndexType.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/IndexedPool.meta.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.18
gzz/lava/gzz/storm/impl/DirPool.java:1.19
--- gzz/lava/gzz/storm/impl/DirPool.java:1.18 Mon Jan 13 18:47:17 2003
+++ gzz/lava/gzz/storm/impl/DirPool.java Mon Jan 13 19:02:26 2003
@@ -23,7 +23,6 @@
package gzz.storm.impl;
import gzz.storm.*;
import gzz.storm.headers.*;
-import gzz.util.*;
import java.io.*;
import java.util.*;
@@ -104,67 +103,6 @@
}
}
- protected class DirDB implements DB {
- 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);
-
- if(!dbDir.exists()) {
- dbDir.mkdir();
-
- OutputStream os = new FileOutputStream(new File(dbDir,
"index_type"));
- os.write(ascii); os.write((byte)'\n');
- os.close();
- }
- }
-
- protected File getKeyFile(byte[] key) throws IOException {
- return new File(dbDir, "key_"+HexUtil.byteArrToHex(key));
- }
-
- public Collector get(byte[] key) throws IOException {
- Set result = new HashSet();
- File f = getKeyFile(key);
-
- if(f.exists()) {
- InputStream in = new FileInputStream(getKeyFile(key));
- Reader ir = new InputStreamReader(in, "US-ASCII");
- BufferedReader r = new BufferedReader(ir);
-
- String line = r.readLine();
- while(line != null && !line.equals("")) {
- int i = line.indexOf(' ');
- BlockId block = new BlockId(line.substring(0, i));
- byte[] value = HexUtil.hexToByteArr(line.substring(i+1));
-
- result.add(new Mapping(block, key, value));
-
- line = r.readLine();
- }
- }
-
- return new SimpleSetCollector(result);
- }
-
- protected void add(Mapping m) throws IOException {
- 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();
- }
-
- public String toString() {
- return "<DirDB '"+dbDir+"'>";
- }
- }
-
/** Create a new DirPool.
* @param dir The directory blocks are stored in.
* Must already exist.
@@ -224,7 +162,7 @@
if(dbs == null) dbs = new HashMap();
DB db = (DB)dbs.get(typeURI);
if(db == null) {
- db = new DirDB(typeURI);
+ db = new DirDB(dir, typeURI);
dbs.put(typeURI, db);
}
return db;
Index: gzz/lava/test/gzz/storm/ContentTypeIndexType.java
diff -u gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.3
gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.4
--- gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.3 Mon Jan 13
18:47:17 2003
+++ gzz/lava/test/gzz/storm/ContentTypeIndexType.java Mon Jan 13 19:02:26 2003
@@ -44,7 +44,6 @@
* 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.3
gzz/lava/test/gzz/storm/IndexedPool.meta:1.4
--- gzz/lava/test/gzz/storm/IndexedPool.meta:1.3 Mon Jan 13 18:47:17 2003
+++ gzz/lava/test/gzz/storm/IndexedPool.meta Mon Jan 13 19:02:26 2003
@@ -34,7 +34,6 @@
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")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/lava gzz/storm/impl/DirPool.java test/gzz/s...,
Benja Fallenstein <=