[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/lava gzz/storm/BlockId.java gzz/storm/Index...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/lava gzz/storm/BlockId.java gzz/storm/Index... |
Date: |
Tue, 14 Jan 2003 10:43:09 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 03/01/14 10:43:08
Modified files:
lava/gzz/storm : BlockId.java IndexedPool.java
PointerIndexType.java
lava/gzz/storm/impl: AbstractPool.java DirDB.java DirPool.java
TransientPool.java ZipPool.java
lava/test/gzz/impl: storm_saving.test
lava/test/gzz/storm: BlockId.test ContentTypeIndexType.java
Added files:
lava/gzz/storm/util: DiffIndexType.java DiffingStormFiler.java
SimpleStormFiler.java
lava/test/gzz/impl: storm_diff_saving.test storm_saving.meta
Removed files:
lava/gzz/storm/util: StormFiler.java
Log message:
Refactor, work towards saving
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/BlockId.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/IndexedPool.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/PointerIndexType.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/AbstractPool.java.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirDB.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/TransientPool.java.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/ZipPool.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/util/DiffIndexType.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/util/DiffingStormFiler.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/util/SimpleStormFiler.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/impl/storm_diff_saving.test?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/impl/storm_saving.meta?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/impl/storm_saving.test.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/BlockId.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/ContentTypeIndexType.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: gzz/lava/gzz/storm/BlockId.java
diff -u gzz/lava/gzz/storm/BlockId.java:1.5 gzz/lava/gzz/storm/BlockId.java:1.6
--- gzz/lava/gzz/storm/BlockId.java:1.5 Sat Nov 16 00:59:46 2002
+++ gzz/lava/gzz/storm/BlockId.java Tue Jan 14 10:43:05 2003
@@ -54,6 +54,7 @@
public byte[] getBytes() { return bytes; }
public String getURI() { return uri; }
+ public String getHex() { return uri.substring(PREFIX_LEN); }
public String toString() { return uri; }
/** Check that the given data bytes match this id.
Index: gzz/lava/gzz/storm/IndexedPool.java
diff -u gzz/lava/gzz/storm/IndexedPool.java:1.14
gzz/lava/gzz/storm/IndexedPool.java:1.15
--- gzz/lava/gzz/storm/IndexedPool.java:1.14 Mon Jan 13 20:04:45 2003
+++ gzz/lava/gzz/storm/IndexedPool.java Tue Jan 14 10:43:05 2003
@@ -131,7 +131,13 @@
*/
Object createIndex(IndexedPool pool, DB db);
+ /** Return a unique URI identifying this index type.
+ */
String getIndexTypeURI();
+
+ /** Return a human-readable name for this kind of index.
+ */
+ String getHumanReadableName();
}
/** Get the Index object for a given IndexType.
Index: gzz/lava/gzz/storm/PointerIndexType.java
diff -u gzz/lava/gzz/storm/PointerIndexType.java:1.4
gzz/lava/gzz/storm/PointerIndexType.java:1.5
--- gzz/lava/gzz/storm/PointerIndexType.java:1.4 Mon Jan 13 23:24:32 2003
+++ gzz/lava/gzz/storm/PointerIndexType.java Tue Jan 14 10:43:05 2003
@@ -53,6 +53,10 @@
return indexTypeURI;
}
+ public String getHumanReadableName() {
+ return "The index of pointer blocks, by pointer.";
+ }
+
abstract public Set getMappings(Block b) throws IOException;
abstract public Object createIndex(IndexedPool pool, IndexedPool.DB db);
Index: gzz/lava/gzz/storm/impl/AbstractPool.java
diff -u gzz/lava/gzz/storm/impl/AbstractPool.java:1.13
gzz/lava/gzz/storm/impl/AbstractPool.java:1.14
--- gzz/lava/gzz/storm/impl/AbstractPool.java:1.13 Mon Jan 13 20:04:45 2003
+++ gzz/lava/gzz/storm/impl/AbstractPool.java Tue Jan 14 10:43:05 2003
@@ -42,7 +42,7 @@
* or removed (given that there's a corresponding
* index type in <code>indexTypes</code>).
*/
- protected abstract DB getDB(String typeURI) throws IOException;
+ protected abstract DB getDB(IndexType indexType) throws IOException;
public AbstractPool(Set indexTypes) throws IOException {
this.indexTypes = indexTypes;
@@ -68,9 +68,8 @@
for(Iterator i=indexTypes.iterator(); i.hasNext();) {
IndexType type = (IndexType)i.next();
-
- String uri = type.getIndexTypeURI();
- indices.put(uri, type.createIndex(this, getDB(uri)));
+ String uri = type.getIndexTypeURI();
+ indices.put(uri, type.createIndex(this, getDB(type)));
}
this.indices = Collections.unmodifiableMap(indices);
Index: gzz/lava/gzz/storm/impl/DirDB.java
diff -u gzz/lava/gzz/storm/impl/DirDB.java:1.2
gzz/lava/gzz/storm/impl/DirDB.java:1.3
--- gzz/lava/gzz/storm/impl/DirDB.java:1.2 Mon Jan 13 21:30:43 2003
+++ gzz/lava/gzz/storm/impl/DirDB.java Tue Jan 14 10:43:06 2003
@@ -17,10 +17,10 @@
* is to be stored in:
* <inDir>/idx_<hex-of-indexTypeURI>
*/
- public DirDB(File inDir, String indexTypeURI) throws IOException {
+ public DirDB(File inDir, IndexedPool.IndexType indexType) throws
IOException {
if(inDir == null) throw new NullPointerException("null directory");
- byte[] ascii = indexTypeURI.getBytes("US-ASCII");
+ byte[] ascii = indexType.getIndexTypeURI().getBytes("US-ASCII");
String hex = HexUtil.byteArrToHex(ascii);
dbDir = new File(inDir, "idx_"+hex);
@@ -29,6 +29,8 @@
OutputStream os = new FileOutputStream(new File(dbDir,
"index_type"));
os.write(ascii); os.write((byte)'\n');
+ os.write(indexType.getHumanReadableName().getBytes());
+ os.write((byte)'\n');
os.close();
os = new FileOutputStream(new File(dbDir, "indexed_blocks"));
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.21
gzz/lava/gzz/storm/impl/DirPool.java:1.22
--- gzz/lava/gzz/storm/impl/DirPool.java:1.21 Mon Jan 13 21:30:43 2003
+++ gzz/lava/gzz/storm/impl/DirPool.java Tue Jan 14 10:43:06 2003
@@ -162,14 +162,14 @@
return new FileBlockOutputStream(new VerbatimHeader822(hdr), tempFile);
}
- protected DB getDB(String typeURI) throws IOException {
+ protected DB getDB(IndexType indexType) throws IOException {
if(dir == null || dbs == null)
throw new IllegalStateException("Not initialized yet");
- DirDB db = (DirDB)dbs.get(typeURI);
+ DirDB db = (DirDB)dbs.get(indexType.getIndexTypeURI());
if(db == null) {
- db = new DirDB(dir, typeURI);
- dbs.put(typeURI, db);
+ db = new DirDB(dir, indexType);
+ dbs.put(indexType.getIndexTypeURI(), db);
Set indexed = db.getIndexed();
Set missing = new HashSet(getIds());
@@ -192,7 +192,7 @@
if(!m.block.equals(block.getId()))
throw new Error("Wrong block in mapping: "+m);
- ((DirDB)getDB(it.getIndexTypeURI())).add(m);
+ ((DirDB)getDB(it)).add(m);
}
}
}
Index: gzz/lava/gzz/storm/impl/TransientPool.java
diff -u gzz/lava/gzz/storm/impl/TransientPool.java:1.23
gzz/lava/gzz/storm/impl/TransientPool.java:1.24
--- gzz/lava/gzz/storm/impl/TransientPool.java:1.23 Mon Jan 13 18:21:44 2003
+++ gzz/lava/gzz/storm/impl/TransientPool.java Tue Jan 14 10:43:06 2003
@@ -140,8 +140,9 @@
return new TransientBlockOutputStream(new VerbatimHeader822(hdr));
}
- protected DB getDB(String typeURI) {
+ protected DB getDB(IndexType indexType) {
if(dbs == null) dbs = new HashMap();
+ String typeURI = indexType.getIndexTypeURI();
DB db = (DB)dbs.get(typeURI);
if(db == null) {
db = new TransientDB();
@@ -159,7 +160,7 @@
if(!m.block.equals(block.getId()))
throw new Error("Wrong block in mapping: "+m);
- ((TransientDB)getDB(it.getIndexTypeURI())).add(m);
+ ((TransientDB)getDB(it)).add(m);
}
}
}
Index: gzz/lava/gzz/storm/impl/ZipPool.java
diff -u gzz/lava/gzz/storm/impl/ZipPool.java:1.12
gzz/lava/gzz/storm/impl/ZipPool.java:1.13
--- gzz/lava/gzz/storm/impl/ZipPool.java:1.12 Mon Jan 13 20:04:45 2003
+++ gzz/lava/gzz/storm/impl/ZipPool.java Tue Jan 14 10:43:06 2003
@@ -167,7 +167,7 @@
}
// XXX temporary, until we have an implementation
- protected DB getDB(String typeURI) {
+ protected DB getDB(IndexType indexType) {
throw new UnsupportedOperationException("Not implemented");
}
}
Index: gzz/lava/test/gzz/impl/storm_saving.test
diff -u gzz/lava/test/gzz/impl/storm_saving.test:1.1
gzz/lava/test/gzz/impl/storm_saving.test:1.2
--- gzz/lava/test/gzz/impl/storm_saving.test:1.1 Mon Jan 13 23:24:33 2003
+++ gzz/lava/test/gzz/impl/storm_saving.test Tue Jan 14 10:43:08 2003
@@ -15,148 +15,8 @@
# file for more details.
#
-"""
-A variant of saving.test, for saving with gzz.storm code
-instead of saving with gzz.mediaserver code.
-
-XXX Stores the spans in a Mediaserver and
-the versions in a StormPool currently...
-because gzz.media doesn't work with Storm yet
-"""
-
import gzz, java
-from gzz import *
-from gzz.impl import *
-from gzz.media import *
-from gzz.media.impl import Enfilade1DImpl, PageImageScroll
-from gzz.slices import SliceVersion
-from gzz.slices.YAMLVersionFormatter import *
-from gzz.storm.impl import *
-from gzz.storm.util import StormFiler
-from gzz.util import *
-
-from java.io import *
-from java.util import *
-
-from test.tools import tools
-
-serv =
gzz.mediaserver.SimpleMediaserver(gzz.mediaserver.storage.TransientStorer())
-pool =
TransientPool(java.util.Collections.singleton(DefaultPointerIndexType.type))
-enfMaker = Enfilade1DImpl.Enfilade1DImplMaker()
-filers = StormFiler.Group(SliceVersion.EMPTY_VERSION, pool,
- YAMLVersionFormat(serv, enfMaker))
-filer = filers.getFiler("FOO")
-space = ModularSpace(*tools.spaceArgList())
-
-def load():
- ver = filer.load()
- print ver
- return ModularSpace(ver, *tools.spaceArgList())
-
-def save(space):
- filers.saveAll(space.getSlicer().exportAll())
-
-
-def testSaveLoad():
- """Test space saving and re-loading"""
- a,b,c = space.N(), space.N(), space.N()
- a.connect(space.getDim(b), c)
- a.setText("foo")
-
- ids = pool.getIds()
- save(space)
- print ids, pool.getIds()
- assert ids != pool.getIds()
-
- ids = pool.getIds()
- save(space)
- print ids, pool.getIds()
- assert ids == pool.getIds()
-
- s2 = load()
-
- ids = pool.getIds()
- save(s2)
- print ids, pool.getIds()
- assert ids == pool.getIds()
-
- a2, b2, c2 = [s2.getCell(cell.getId()) for cell in (a,b,c)]
- assert a2.s(s2.getDim(b2)) == c2
- assert a2.t() == "foo"
-
- a2.insertText(2, "bing")
- c2.setText("bar")
- a2.insert(s2.getDim(b2), 1, b2)
-
- ids = pool.getIds()
- save(s2)
- print ids, pool.getIds()
- assert ids != pool.getIds()
- s3 = load()
-
- a3, b3, c3 = [s3.getCell(cell.getId()) for cell in (a,b,c)]
- assert a3.s(s3.getDim(b3)) == b3
- assert b3.s(s3.getDim(b3)) == c3
- assert a3.t() == "fobingo"
- assert c3.t() == "bar"
-
- ids = pool.getIds()
- save(s3)
- print ids, pool.getIds()
- assert ids == pool.getIds()
-
-
-def testJoinSpans():
- """Test that adjacent spans are joined when saving"""
-
- c = space.N()
-
- c.insertText(0, "f")
- c.insertText(1, "oo")
- c.insertText(3, "bar")
- c.insertText(3, ""); # empty spans must be removed, too
-
- assert c.t() == "foobar"
- assert space.getCellTexter().getEnfilade(c, None).getList().size() == 4
-
- v = space.getSlicer().export(space.getSlicer().getSlice0())
- enf = v.contents.get(c.getId())
- assert enf.makeString() == "foobar"
- assert enf.getList().size() == 1
+FilerGroup = gzz.storm.util.SimpleStormFiler.Group
-
-def testSavePageSpans():
- """
- Test saving and re-loading page spans.
-
- Exploits an implementation detail of PageImageScroll: it doesn't look
- at the actual block, just at the mstmpimg version of it. So we can
- create an empty block with content type application/pdf and expect the
- test to work.
- """
-
- # Create dummy pageimage scroll
- id = serv.addDatum("", "application/pdf")
-
- c = space.N()
- empty = space.getCellTexter().getEnfilade(c, None)
- scr = ScrollBlockManager.getScrollBlock(serv, id)
- scr.forcelengthKLUDGE(17);
-
- space.getCellTexter().setEnfilade(c, empty.plus(scr.getCurrent()).plus(
- scr.getCurrent().subArea(5,9,7,7,23,23)))
-
- save(space)
- s2 = load()
-
- c2 = s2.getCell(c.getId())
-
- print s2.getCellTexter().getEnfilade(c2, None)
- print space.getCellTexter().getEnfilade(c, None)
-
- assert s2.getCellTexter().getEnfilade(c2, None) == \
- space.getCellTexter().getEnfilade(c, None)
-
- save(s2)
- s3 = load()
+execfile('lava/test/gzz/impl/storm_saving.meta')
Index: gzz/lava/test/gzz/storm/BlockId.test
diff -u gzz/lava/test/gzz/storm/BlockId.test:1.2
gzz/lava/test/gzz/storm/BlockId.test:1.3
--- gzz/lava/test/gzz/storm/BlockId.test:1.2 Thu Nov 7 16:42:50 2002
+++ gzz/lava/test/gzz/storm/BlockId.test Tue Jan 14 10:43:08 2003
@@ -33,6 +33,7 @@
assert a.getBytes() == b.getBytes() == c.getBytes() == asByteArray
assert a.getURI() == b.getURI() == c.getURI() == asUri
assert str(a) == str(b) == str(c) == asUri
+ assert a.getHex() == b.getHex() == c.getHex() == asHexString
assert a == b == c
assert a.hashCode() == b.hashCode() == c.hashCode()
Index: gzz/lava/test/gzz/storm/ContentTypeIndexType.java
diff -u gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.4
gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.5
--- gzz/lava/test/gzz/storm/ContentTypeIndexType.java:1.4 Mon Jan 13
19:02:26 2003
+++ gzz/lava/test/gzz/storm/ContentTypeIndexType.java Tue Jan 14 10:43:08 2003
@@ -82,4 +82,9 @@
public String getIndexTypeURI() {
return contentTypeIndexTypeURI;
}
+
+ public String getHumanReadableName() {
+ return ("An index of blocks by their content type. " +
+ "For testing purposes.");
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/lava gzz/storm/BlockId.java gzz/storm/Index...,
Benja Fallenstein <=