/[gzz]/gzz/lava/gzz/storm/impl/DirDB.java
ViewVC logotype

Diff of /gzz/lava/gzz/storm/impl/DirDB.java

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

revision 1.1 by benja, Tue Jan 14 00:02:26 2003 UTC revision 1.2 by benja, Tue Jan 14 02:30:43 2003 UTC
# Line 30  public class DirDB implements IndexedPoo Line 30  public class DirDB implements IndexedPoo
30              OutputStream os = new FileOutputStream(new File(dbDir, "index_type"));              OutputStream os = new FileOutputStream(new File(dbDir, "index_type"));
31              os.write(ascii); os.write((byte)'\n');              os.write(ascii); os.write((byte)'\n');
32              os.close();              os.close();
33    
34                os = new FileOutputStream(new File(dbDir, "indexed_blocks"));
35                os.close();
36          }          }
37      }      }
38            
# Line 61  public class DirDB implements IndexedPoo Line 64  public class DirDB implements IndexedPoo
64          return new SimpleSetCollector(result);          return new SimpleSetCollector(result);
65      }      }
66            
67        public Set getIndexed() throws IOException {
68            HashSet result = new HashSet();
69    
70            InputStream in = new FileInputStream(new File(dbDir, "indexed_blocks"));
71            Reader ir = new InputStreamReader(in, "US-ASCII");
72            BufferedReader r = new BufferedReader(ir);
73                
74            String line = r.readLine();
75            while(line != null && !line.equals("")) {
76                result.add(new BlockId(line));
77                line = r.readLine();
78            }
79    
80            return result;
81        }
82    
83      public void add(IndexedPool.Mapping m) throws IOException {      public void add(IndexedPool.Mapping m) throws IOException {
84            if(getIndexed().contains(m.block))
85                return;
86    
87          OutputStream os = new FileOutputStream(getKeyFile(m.key), true);          OutputStream os = new FileOutputStream(getKeyFile(m.key), true);
88          os.write(m.block.getURI().getBytes("US-ASCII"));          os.write(m.block.getURI().getBytes("US-ASCII"));
89          os.write((byte)' ');          os.write((byte)' ');
90          os.write(HexUtil.byteArrToHex(m.value).getBytes("US-ASCII"));          os.write(HexUtil.byteArrToHex(m.value).getBytes("US-ASCII"));
91          os.write((byte)'\n');          os.write((byte)'\n');
92          os.close();          os.close();
93    
94            os = new FileOutputStream(new File(dbDir, "indexed_blocks"), true);
95            os.write(m.block.getURI().getBytes("US-ASCII"));
96            os.write((byte)'\n');
97            os.close();
98      }      }
99    
100      public String toString() {      public String toString() {

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

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