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 |
|
|
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() { |