diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index c53dcca6c..369993bac 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -22,7 +22,7 @@ - + true true @@ -867,6 +867,12 @@ true true + + true + true + true + true + true true @@ -1603,6 +1609,7 @@ + diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index 6216b95e4..d2c102c7a 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -921,7 +921,10 @@ [1] Ripple\ripple_net\basics - + + [1] Ripple\ripple_core\node + + [2] Ripple %28New%29\sophia @@ -1830,6 +1833,9 @@ [2] Ripple %28New%29\sophia + + [1] Ripple\ripple_core\node + diff --git a/src/ripple/sophia/ripple_sophia.c b/src/ripple/sophia/ripple_sophia.c index 3305dc3f0..0650deb45 100644 --- a/src/ripple/sophia/ripple_sophia.c +++ b/src/ripple/sophia/ripple_sophia.c @@ -8,7 +8,7 @@ #include "ripple_sophia.h" -//#if RIPPLE_SOPHIA_AVAILBLE +#if RIPPLE_SOPHIA_AVAILABLE #include "../sophia/db/cat.c" #include "../sophia/db/crc.c" @@ -23,4 +23,4 @@ #include "../sophia/db/sp.c" #include "../sophia/db/util.c" -//#endif +#endif diff --git a/src/ripple_core/node/SophiaBackendFactory.cpp b/src/ripple_core/node/SophiaBackendFactory.cpp index eb63c7dd5..f2056ac73 100644 --- a/src/ripple_core/node/SophiaBackendFactory.cpp +++ b/src/ripple_core/node/SophiaBackendFactory.cpp @@ -4,9 +4,12 @@ */ //============================================================================== +#if RIPPLE_SOPHIA_AVAILABLE + class SophiaBackendFactory::Backend : public NodeStore::Backend - , LeakChecked + , public NodeStore::BatchWriter::Callback + , public LeakChecked { public: typedef RecycledObjectPool StringPool; @@ -21,6 +24,7 @@ public: NodeStore::Scheduler& scheduler) : m_keyBytes (keyBytes) , m_scheduler (scheduler) + , m_batch (*this, scheduler) , m_name (keyValues ["path"].toStdString ()) , m_env (nullptr) , m_db (nullptr) @@ -97,28 +101,29 @@ public: void store (NodeObject::ref object) { - EncodedBlob::Pool::ScopedItem item (m_blobPool); - EncodedBlob& encoded (item.getObject ()); - encoded.prepare (object); - - int rv (sp_set (m_db, - encoded.getKey(), m_keyBytes, - encoded.getData(), encoded.getSize())); - - if (rv != 0) - { - String s; - s << "Sophia failed with error code " << rv; - Throw (std::runtime_error (s.toStdString()), __FILE__, __LINE__); - } + m_batch.store (object);; } void storeBatch (Batch const& batch) { + EncodedBlob::Pool::ScopedItem item (m_blobPool); + for (NodeStore::Batch::const_iterator iter (batch.begin()); iter != batch.end(); ++iter) { - store (*iter); + EncodedBlob& encoded (item.getObject ()); + encoded.prepare (*iter); + + int rv (sp_set (m_db, + encoded.getKey(), m_keyBytes, + encoded.getData(), encoded.getSize())); + + if (rv != 0) + { + String s; + s << "Sophia failed with error code " << rv; + Throw (std::runtime_error (s.toStdString()), __FILE__, __LINE__); + } } } @@ -128,10 +133,22 @@ public: int getWriteLoad () { - return 0; + return m_batch.getWriteLoad (); } void stopAsync () + { + m_batch.stopAsync (); + } + + //-------------------------------------------------------------------------- + + void writeBatch (NodeStore::Batch const& batch) + { + storeBatch (batch); + } + + void writeStopped () { m_scheduler.scheduledTasksStopped (); } @@ -139,6 +156,7 @@ public: private: size_t const m_keyBytes; NodeStore::Scheduler& m_scheduler; + NodeStore::BatchWriter m_batch; StringPool m_stringPool; NodeStore::EncodedBlob::Pool m_blobPool; std::string m_name; @@ -180,3 +198,4 @@ NodeStore::Backend* SophiaBackendFactory::createInstance ( //------------------------------------------------------------------------------ +#endif