diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /java/src/Freeze/Index.java | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'java/src/Freeze/Index.java')
-rw-r--r-- | java/src/Freeze/Index.java | 456 |
1 files changed, 228 insertions, 228 deletions
diff --git a/java/src/Freeze/Index.java b/java/src/Freeze/Index.java index 8fa23f79e0c..026cc841742 100644 --- a/java/src/Freeze/Index.java +++ b/java/src/Freeze/Index.java @@ -22,41 +22,41 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator com.sleepycat.db.DatabaseEntry result) throws com.sleepycat.db.DatabaseException { - Ice.Communicator communicator = _store.communicator(); - ObjectRecord rec = ObjectStore.unmarshalValue(value.getData(), communicator); + Ice.Communicator communicator = _store.communicator(); + ObjectRecord rec = ObjectStore.unmarshalValue(value.getData(), communicator); - byte[] secondaryKey = marshalKey(rec.servant); - if(secondaryKey != null) - { - result.setData(secondaryKey); - result.setSize(secondaryKey.length); - return true; - } - else - { - // - // Don't want to index this one - // + byte[] secondaryKey = marshalKey(rec.servant); + if(secondaryKey != null) + { + result.setData(secondaryKey); + result.setSize(secondaryKey.length); + return true; + } + else + { + // + // Don't want to index this one + // return false; - } + } } public String name() { - return _name; + return _name; } public String facet() { - return _facet; + return _facet; } protected Index(String name, String facet) { - _name = name; - _facet = facet; + _name = name; + _facet = facet; } protected abstract byte[] @@ -65,50 +65,50 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator protected Ice.Identity[] untypedFindFirst(byte[] k, int firstN) { - EvictorI.DeactivateController deactivateController = _store.evictor().deactivateController(); - deactivateController.lock(); - - try - { - com.sleepycat.db.DatabaseEntry key = new com.sleepycat.db.DatabaseEntry(k); - - // When we have a custom-comparison function, Berkeley DB returns - // the key on-disk (when it finds one). We disable this behavior: - // (ref Oracle SR 5925672.992) - // - key.setPartial(true); + EvictorI.DeactivateController deactivateController = _store.evictor().deactivateController(); + deactivateController.lock(); + + try + { + com.sleepycat.db.DatabaseEntry key = new com.sleepycat.db.DatabaseEntry(k); + + // When we have a custom-comparison function, Berkeley DB returns + // the key on-disk (when it finds one). We disable this behavior: + // (ref Oracle SR 5925672.992) + // + key.setPartial(true); - com.sleepycat.db.DatabaseEntry pkey = new com.sleepycat.db.DatabaseEntry(); - com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); - // - // dlen is 0, so we should not retrieve any value - // - value.setPartial(true); - - Ice.Communicator communicator = _store.communicator(); - _store.evictor().saveNow(); - - java.util.List identities; - - try - { - for(;;) - { - com.sleepycat.db.SecondaryCursor dbc = null; - identities = new java.util.ArrayList(); - - try - { - // - // Move to the first record - // - dbc = _db.openSecondaryCursor(null, null); - boolean first = true; - - boolean found; - - do - { + com.sleepycat.db.DatabaseEntry pkey = new com.sleepycat.db.DatabaseEntry(); + com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); + // + // dlen is 0, so we should not retrieve any value + // + value.setPartial(true); + + Ice.Communicator communicator = _store.communicator(); + _store.evictor().saveNow(); + + java.util.List identities; + + try + { + for(;;) + { + com.sleepycat.db.SecondaryCursor dbc = null; + identities = new java.util.ArrayList(); + + try + { + // + // Move to the first record + // + dbc = _db.openSecondaryCursor(null, null); + boolean first = true; + + boolean found; + + do + { com.sleepycat.db.OperationStatus status; if(first) { @@ -119,210 +119,210 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator status = dbc.getNextDup(key, pkey, value, null); } - found = status == com.sleepycat.db.OperationStatus.SUCCESS; - - if(found) - { - Ice.Identity ident = ObjectStore.unmarshalKey(pkey.getData(), communicator); - identities.add(ident); - first = false; - } - } - while((firstN <= 0 || identities.size() < firstN) && found); - - break; // for(;;) - } - catch(com.sleepycat.db.DeadlockException dx) - { - if(_store.evictor().deadlockWarning()) - { - communicator.getLogger().warning("Deadlock in Freeze.Index.untypedFindFirst while " + + found = status == com.sleepycat.db.OperationStatus.SUCCESS; + + if(found) + { + Ice.Identity ident = ObjectStore.unmarshalKey(pkey.getData(), communicator); + identities.add(ident); + first = false; + } + } + while((firstN <= 0 || identities.size() < firstN) && found); + + break; // for(;;) + } + catch(com.sleepycat.db.DeadlockException dx) + { + if(_store.evictor().deadlockWarning()) + { + communicator.getLogger().warning("Deadlock in Freeze.Index.untypedFindFirst while " + "iterating over Db \"" + _store.evictor().filename() + "/" + _dbName + "\"; retrying..."); - } - - // - // Retry - // - } - finally - { - if(dbc != null) - { - try - { - dbc.close(); - } - catch(com.sleepycat.db.DeadlockException dx) - { - // - // Ignored - // - } - } - } - } - } - catch(com.sleepycat.db.DatabaseException dx) - { - DatabaseException ex = new DatabaseException(); - ex.initCause(dx); - ex.message = _store.evictor().errorPrefix() + "Db.cursor: " + dx.getMessage(); - throw ex; - } - - if(identities.size() != 0) - { - Ice.Identity[] result = new Ice.Identity[identities.size()]; - return (Ice.Identity[]) identities.toArray(result); - } - else - { - return new Ice.Identity[0]; - } - } - finally - { - deactivateController.unlock(); - } + } + + // + // Retry + // + } + finally + { + if(dbc != null) + { + try + { + dbc.close(); + } + catch(com.sleepycat.db.DeadlockException dx) + { + // + // Ignored + // + } + } + } + } + } + catch(com.sleepycat.db.DatabaseException dx) + { + DatabaseException ex = new DatabaseException(); + ex.initCause(dx); + ex.message = _store.evictor().errorPrefix() + "Db.cursor: " + dx.getMessage(); + throw ex; + } + + if(identities.size() != 0) + { + Ice.Identity[] result = new Ice.Identity[identities.size()]; + return (Ice.Identity[]) identities.toArray(result); + } + else + { + return new Ice.Identity[0]; + } + } + finally + { + deactivateController.unlock(); + } } - + protected Ice.Identity[] untypedFind(byte[] key) { - return untypedFindFirst(key, 0); + return untypedFindFirst(key, 0); } protected int untypedCount(byte[] k) { - EvictorI.DeactivateController deactivateController = _store.evictor().deactivateController(); - deactivateController.lock(); - - try - { - com.sleepycat.db.DatabaseEntry key = new com.sleepycat.db.DatabaseEntry(k); + EvictorI.DeactivateController deactivateController = _store.evictor().deactivateController(); + deactivateController.lock(); + + try + { + com.sleepycat.db.DatabaseEntry key = new com.sleepycat.db.DatabaseEntry(k); - // When we have a custom-comparison function, Berkeley DB returns - // the key on-disk (when it finds one). We disable this behavior: - // (ref Oracle SR 5925672.992) - // - key.setPartial(true); + // When we have a custom-comparison function, Berkeley DB returns + // the key on-disk (when it finds one). We disable this behavior: + // (ref Oracle SR 5925672.992) + // + key.setPartial(true); - com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); - // - // dlen is 0, so we should not retrieve any value - // - value.setPartial(true); - _store.evictor().saveNow(); - - try - { - for(;;) - { - com.sleepycat.db.Cursor dbc = null; - try - { - dbc = _db.openCursor(null, null); - if(dbc.getSearchKey(key, value, null) == com.sleepycat.db.OperationStatus.SUCCESS) - { - return dbc.count(); - } - else - { - return 0; - } - } - catch(com.sleepycat.db.DeadlockException dx) - { - if(_store.evictor().deadlockWarning()) - { - _store.communicator().getLogger().warning("Deadlock in Freeze.Index.untypedCount while " + + com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); + // + // dlen is 0, so we should not retrieve any value + // + value.setPartial(true); + _store.evictor().saveNow(); + + try + { + for(;;) + { + com.sleepycat.db.Cursor dbc = null; + try + { + dbc = _db.openCursor(null, null); + if(dbc.getSearchKey(key, value, null) == com.sleepycat.db.OperationStatus.SUCCESS) + { + return dbc.count(); + } + else + { + return 0; + } + } + catch(com.sleepycat.db.DeadlockException dx) + { + if(_store.evictor().deadlockWarning()) + { + _store.communicator().getLogger().warning("Deadlock in Freeze.Index.untypedCount while " + "iterating over Db \"" + _store.evictor().filename() + "/" + _dbName + "\"; retrying..."); - } - - // - // Retry - // - } - finally - { - if(dbc != null) - { - try - { - dbc.close(); - } - catch(com.sleepycat.db.DeadlockException dx) - { - // - // Ignored - // - } - } - } - } - } - catch(com.sleepycat.db.DatabaseException dx) - { - DatabaseException ex = new DatabaseException(); - ex.initCause(dx); - ex.message = _store.evictor().errorPrefix() + "Db.cursor: " + dx.getMessage(); - throw ex; - } - } - finally - { - deactivateController.unlock(); - } + } + + // + // Retry + // + } + finally + { + if(dbc != null) + { + try + { + dbc.close(); + } + catch(com.sleepycat.db.DeadlockException dx) + { + // + // Ignored + // + } + } + } + } + } + catch(com.sleepycat.db.DatabaseException dx) + { + DatabaseException ex = new DatabaseException(); + ex.initCause(dx); + ex.message = _store.evictor().errorPrefix() + "Db.cursor: " + dx.getMessage(); + throw ex; + } + } + finally + { + deactivateController.unlock(); + } } protected final Ice.Communicator communicator() { - return _store.communicator(); + return _store.communicator(); } void associate(ObjectStore store, com.sleepycat.db.Transaction txn, boolean createDb, boolean populateIndex) - throws com.sleepycat.db.DatabaseException, java.io.FileNotFoundException + throws com.sleepycat.db.DatabaseException, java.io.FileNotFoundException { - assert(txn != null); - _store = store; - - _dbName = EvictorI.indexPrefix + store.dbName() + "." + _name; + assert(txn != null); + _store = store; + + _dbName = EvictorI.indexPrefix + store.dbName() + "." + _name; com.sleepycat.db.SecondaryConfig config = new com.sleepycat.db.SecondaryConfig(); config.setAllowCreate(createDb); config.setAllowPopulate(populateIndex); config.setSortedDuplicates(true); config.setType(com.sleepycat.db.DatabaseType.BTREE); - config.setKeyCreator(this); + config.setKeyCreator(this); - _db = _store.evictor().dbEnv().getEnv().openSecondaryDatabase(txn, _store.evictor().filename(), _dbName, - _store.db(), config); + _db = _store.evictor().dbEnv().getEnv().openSecondaryDatabase(txn, _store.evictor().filename(), _dbName, + _store.db(), config); } void close() { - if(_db != null) - { - try - { - _db.close(); - } - catch(com.sleepycat.db.DatabaseException dx) - { - DatabaseException ex = new DatabaseException(); - ex.initCause(dx); - ex.message = _store.evictor().errorPrefix() + "Db.close: " + dx.getMessage(); - throw ex; - } - _db = null; - } + if(_db != null) + { + try + { + _db.close(); + } + catch(com.sleepycat.db.DatabaseException dx) + { + DatabaseException ex = new DatabaseException(); + ex.initCause(dx); + ex.message = _store.evictor().errorPrefix() + "Db.close: " + dx.getMessage(); + throw ex; + } + _db = null; + } } private final String _name; |