summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/IndexI.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
committerBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
commitabada90e3f84dc703b8ddc9efcbed8a946fadead (patch)
tree2c6f9dccd510ea97cb927a7bd635422efaae547a /cpp/src/Freeze/IndexI.cpp
parentremoving trace message (diff)
downloadice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip
Expanded tabs into spaces
Diffstat (limited to 'cpp/src/Freeze/IndexI.cpp')
-rw-r--r--cpp/src/Freeze/IndexI.cpp402
1 files changed, 201 insertions, 201 deletions
diff --git a/cpp/src/Freeze/IndexI.cpp b/cpp/src/Freeze/IndexI.cpp
index 5058fb23ece..ca9c21e095a 100644
--- a/cpp/src/Freeze/IndexI.cpp
+++ b/cpp/src/Freeze/IndexI.cpp
@@ -37,7 +37,7 @@ vector<Identity>
Freeze::IndexI::untypedFindFirst(const Key& bytes, Int firstN) const
{
DeactivateController::Guard
- deactivateGuard(_store->evictor()->deactivateController());
+ deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
@@ -63,111 +63,111 @@ Freeze::IndexI::untypedFindFirst(const Key& bytes, Int firstN) const
try
{
- for(;;)
- {
- Dbc* dbc = 0;
- identities.clear();
-
- try
- {
- //
- // Move to the first record
- //
- _db->cursor(0, &dbc, 0);
- u_int32_t flags = DB_SET;
-
- bool found;
-
- do
- {
- for(;;)
- {
- try
- {
- //
- // It is critical to set key size to key capacity before the
- // get, as a resize that increases the size inserts 0
- //
- pkey.resize(pkey.capacity());
-
- found = (dbc->pget(&dbKey, &pdbKey, &dbValue, flags) == 0);
- if(found)
- {
- pkey.resize(pdbKey.get_size());
-
- Ice::Identity ident;
- ObjectStore::unmarshal(ident, pkey, communicator);
- identities.push_back(ident);
- flags = DB_NEXT_DUP;
- }
- break; // for(;;)
- }
- catch(const DbDeadlockException&)
- {
- throw;
- }
- catch(const DbException& dx)
- {
- handleDbException(dx, pkey, pdbKey, __FILE__, __LINE__);
- }
- }
- }
- while((firstN <= 0 || identities.size() < static_cast<size_t>(firstN)) && found);
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
-
- if(_store->evictor()->deadlockWarning())
- {
- Warning out(_store->communicator()->getLogger());
- out << "Deadlock in Freeze::IndexI::untypedFindFirst while searching \""
- << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
- }
-
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ Dbc* dbc = 0;
+ identities.clear();
+
+ try
+ {
+ //
+ // Move to the first record
+ //
+ _db->cursor(0, &dbc, 0);
+ u_int32_t flags = DB_SET;
+
+ bool found;
+
+ do
+ {
+ for(;;)
+ {
+ try
+ {
+ //
+ // It is critical to set key size to key capacity before the
+ // get, as a resize that increases the size inserts 0
+ //
+ pkey.resize(pkey.capacity());
+
+ found = (dbc->pget(&dbKey, &pdbKey, &dbValue, flags) == 0);
+ if(found)
+ {
+ pkey.resize(pdbKey.get_size());
+
+ Ice::Identity ident;
+ ObjectStore::unmarshal(ident, pkey, communicator);
+ identities.push_back(ident);
+ flags = DB_NEXT_DUP;
+ }
+ break; // for(;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ throw;
+ }
+ catch(const DbException& dx)
+ {
+ handleDbException(dx, pkey, pdbKey, __FILE__, __LINE__);
+ }
+ }
+ }
+ while((firstN <= 0 || identities.size() < static_cast<size_t>(firstN)) && found);
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+
+ if(_store->evictor()->deadlockWarning())
+ {
+ Warning out(_store->communicator()->getLogger());
+ out << "Deadlock in Freeze::IndexI::untypedFindFirst while searching \""
+ << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- handleDbException(dx, __FILE__, __LINE__);
+ handleDbException(dx, __FILE__, __LINE__);
}
return identities;
@@ -183,7 +183,7 @@ Int
Freeze::IndexI::untypedCount(const Key& bytes) const
{
DeactivateController::Guard
- deactivateGuard(_store->evictor()->deactivateController());
+ deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
@@ -203,81 +203,81 @@ Freeze::IndexI::untypedCount(const Key& bytes) const
try
{
- for(;;)
- {
- Dbc* dbc = 0;
-
- try
- {
- //
- // Move to the first record
- //
- _db->cursor(0, &dbc, 0);
- bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
-
- if(found)
- {
- db_recno_t count = 0;
- dbc->count(&count, 0);
- result = static_cast<Int>(count);
- }
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
-
- if(_store->evictor()->deadlockWarning())
- {
- Warning out(_store->communicator()->getLogger());
- out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
- << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
- }
-
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ Dbc* dbc = 0;
+
+ try
+ {
+ //
+ // Move to the first record
+ //
+ _db->cursor(0, &dbc, 0);
+ bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
+
+ if(found)
+ {
+ db_recno_t count = 0;
+ dbc->count(&count, 0);
+ result = static_cast<Int>(count);
+ }
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+
+ if(_store->evictor()->deadlockWarning())
+ {
+ Warning out(_store->communicator()->getLogger());
+ out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
+ << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
return result;
@@ -285,7 +285,7 @@ Freeze::IndexI::untypedCount(const Key& bytes) const
void
Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
- bool createDb, bool populateIndex)
+ bool createDb, bool populateIndex)
{
assert(txn != 0);
_store = store;
@@ -298,7 +298,7 @@ Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
u_int32_t flags = 0;
if(createDb)
{
- flags = DB_CREATE;
+ flags = DB_CREATE;
}
_dbName = EvictorI::indexPrefix + store->dbName() + "." + _index.name();
@@ -308,14 +308,14 @@ Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
flags = 0;
if(populateIndex)
{
- flags = DB_CREATE;
+ flags = DB_CREATE;
}
store->db()->associate(txn, _db.get(), callback, flags);
}
int
Freeze::IndexI::secondaryKeyCreate(Db* secondary, const Dbt* dbKey,
- const Dbt* dbValue, Dbt* result)
+ const Dbt* dbValue, Dbt* result)
{
Ice::CommunicatorPtr communicator = _store->communicator();
@@ -327,19 +327,19 @@ Freeze::IndexI::secondaryKeyCreate(Db* secondary, const Dbt* dbKey,
Key bytes;
if(_index.marshalKey(rec.servant, bytes))
{
- result->set_flags(DB_DBT_APPMALLOC);
- void* data = malloc(bytes.size());
- memcpy(data, &bytes[0], bytes.size());
- result->set_data(data);
- result->set_size(static_cast<u_int32_t>(bytes.size()));
- return 0;
+ result->set_flags(DB_DBT_APPMALLOC);
+ void* data = malloc(bytes.size());
+ memcpy(data, &bytes[0], bytes.size());
+ result->set_data(data);
+ result->set_size(static_cast<u_int32_t>(bytes.size()));
+ return 0;
}
else
{
- //
- // Don't want to index this one
- //
- return DB_DONOTINDEX;
+ //
+ // Don't want to index this one
+ //
+ return DB_DONOTINDEX;
}
}
@@ -348,16 +348,16 @@ Freeze::IndexI::close()
{
if(_db.get() != 0)
{
- try
- {
- _db->close(0);
- }
- catch(const DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- _db.reset(0);
+ try
+ {
+ _db->close(0);
+ }
+ catch(const DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ _db.reset(0);
}
}