diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 54 | ||||
-rw-r--r-- | cpp/src/Freeze/DBI.h | 2 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 14 | ||||
-rw-r--r-- | cpp/src/slice2freeze/.depend | 4 |
4 files changed, 26 insertions, 48 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index b6359fed260..cc97d8a31fd 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -387,23 +387,13 @@ Freeze::DBI::put(const Key& key, const Value& value, bool txn) throw ex; } - if (!servant) - { - return; - } - - IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); - IceInternal::Stream stream(instance); - stream.write(servant); - DBT dbKey, dbData; - memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); - dbKey.data = const_cast<void*>(static_cast<const void*>(key.c_str())); + dbKey.data = const_cast<void*>(static_cast<const void*>(key.begin())); dbKey.size = key.size(); - dbData.data = stream.b.begin(); - dbData.size = stream.b.size(); + dbData.data = const_cast<void*>(static_cast<const void*>(value.begin())); + dbData.size = value.size(); while (true) { @@ -416,7 +406,7 @@ Freeze::DBI::put(const Key& key, const Value& value, bool txn) if (_trace >= 1) { ostringstream s; - s << "writing value for key \"" << key << "\" in database \"" << _name << "\""; + s << "writing value in database \"" << _name << "\""; _logger->trace("DB", s.str()); } @@ -494,13 +484,13 @@ Freeze::DBI::get(const Key& key) DBT dbKey, dbData; memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); - dbKey.data = const_cast<void*>(static_cast<const void*>(key.c_str())); + dbKey.data = const_cast<void*>(static_cast<const void*>(key.begin())); dbKey.size = key.size(); if (_trace >= 1) { ostringstream s; - s << "reading value for key \"" << key << "\" from database \"" << _name << "\""; + s << "reading value from database \"" << _name << "\""; _logger->trace("DB", s.str()); } @@ -513,21 +503,10 @@ Freeze::DBI::get(const Key& key) // // Everything ok // - IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); - IceInternal::Stream stream(instance); - stream.b.resize(dbData.size); - stream.i = stream.b.begin(); - memcpy(stream.b.begin(), dbData.data, dbData.size); - - ObjectPtr servant; - stream.read(servant, "::Ice::Object"); - - if (!servant) - { - throw NoServantFactoryException(__FILE__, __LINE__); - } - - return servant; + Value value; + value.resize(dbData.size); + memcpy(value.begin(), dbData.data, dbData.size); + return value; } case DB_NOTFOUND: @@ -535,7 +514,7 @@ Freeze::DBI::get(const Key& key) // // Key does not exist, return a null servant // - return 0; + return Value(); } default: @@ -565,13 +544,13 @@ Freeze::DBI::del(const Key& key) DBT dbKey; memset(&dbKey, 0, sizeof(dbKey)); - dbKey.data = const_cast<void*>(static_cast<const void*>(key.c_str())); + dbKey.data = const_cast<void*>(static_cast<const void*>(key.begin())); dbKey.size = key.size(); if (_trace >= 1) { ostringstream s; - s << "deleting value for key \"" << key << "\" from database \"" << _name << "\""; + s << "deleting value from database \"" << _name << "\""; _logger->trace("DB", s.str()); } @@ -599,7 +578,7 @@ Freeze::DBI::del(const Key& key) } void -Freeze::DBI::put(const string& identity, const ObjectPtr& servant, bool txn) +Freeze::DBI::putServant(const string& identity, const ObjectPtr& servant, bool txn) { JTCSyncT<JTCMutex> sync(*this); @@ -622,7 +601,6 @@ Freeze::DBI::put(const string& identity, const ObjectPtr& servant, bool txn) stream.write(servant); DBT dbKey, dbData; - memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); dbKey.data = const_cast<void*>(static_cast<const void*>(identity.c_str())); @@ -703,7 +681,7 @@ Freeze::DBI::put(const string& identity, const ObjectPtr& servant, bool txn) } ObjectPtr -Freeze::DBI::get(const string& identity) +Freeze::DBI::getServant(const string& identity) { JTCSyncT<JTCMutex> sync(*this); @@ -775,7 +753,7 @@ Freeze::DBI::get(const string& identity) } void -Freeze::DBI::del(const string& identity) +Freeze::DBI::delServant(const string& identity) { JTCSyncT<JTCMutex> sync(*this); diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h index bb440926798..fa25dda1113 100644 --- a/cpp/src/Freeze/DBI.h +++ b/cpp/src/Freeze/DBI.h @@ -31,7 +31,7 @@ public: virtual std::string getName(); virtual DBPtr openDB(const std::string&); - virtual DBTransactionPtr startDBTransaction(); + virtual DBTransactionPtr startTransaction(); virtual void close(); private: diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index a775ad6cae1..4be3641ce68 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -102,7 +102,7 @@ Freeze::EvictorI::setPersistenceMode(EvictorPersistenceMode persistenceMode) for (map<string, EvictorElement>::iterator p = _evictorMap.begin(); p != _evictorMap.end(); ++p) { - _db->put(*(p->second.position), p->second.servant, true); + _db->putServant(*(p->second.position), p->second.servant, true); } } } @@ -124,7 +124,7 @@ Freeze::EvictorI::createObject(const string& identity, const ObjectPtr& servant) // // Save the new Ice Object to the database. // - _db->put(identity, servant, true); + _db->putServant(identity, servant, true); add(identity, servant); if (_trace >= 1) @@ -143,7 +143,7 @@ Freeze::EvictorI::destroyObject(const string& identity) // // Delete the Ice Object from the database. // - _db->del(identity); + _db->delServant(identity); remove(identity); if (_trace >= 1) @@ -204,7 +204,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity // Load the Ice Object from database and create and add a // Servant for it. // - ObjectPtr servant = _db->get(identity); + ObjectPtr servant = _db->getServant(identity); if (!servant) { // @@ -246,7 +246,7 @@ Freeze::EvictorI::finished(const ObjectAdapterPtr&, const string& identity, cons { if (servant->__isMutating(operation)) { - _db->put(identity, servant, true); + _db->putServant(identity, servant, true); } } } @@ -271,7 +271,7 @@ Freeze::EvictorI::deactivate() { for (map<string, EvictorElement>::iterator p = _evictorMap.begin(); p != _evictorMap.end(); ++p) { - _db->put(*(p->second.position), p->second.servant, true); + _db->putServant(*(p->second.position), p->second.servant, true); } } @@ -313,7 +313,7 @@ Freeze::EvictorI::evict() // if (_persistenceMode == SaveUponEviction) { - _db->put(identity, servant, true); + _db->putServant(identity, servant, true); } if (_trace >= 2) diff --git a/cpp/src/slice2freeze/.depend b/cpp/src/slice2freeze/.depend index 4c8defd2f1e..8bb92ea6ca9 100644 --- a/cpp/src/slice2freeze/.depend +++ b/cpp/src/slice2freeze/.depend @@ -1,2 +1,2 @@ -Main.o: Main.cpp ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h -GenUtil.o: ../slice2cpp/GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h +Main.o: Main.cpp ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h GenUtil.h +GenUtil.o: GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h |