mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add batch support to sophia backend
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<ClCompile Include="..\..\build\proto\ripple.pb.cc" />
|
||||
<ClCompile Include="..\..\src\ripple\beast\ripple_beast.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple\beast\ripple_beastc.c" />
|
||||
<ClCompile Include="..\..\src\ripple\sophia\ripple_sophia.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple\sophia\ripple_sophia.c" />
|
||||
<ClCompile Include="..\..\src\ripple\testoverlay\impl\TestOverlay.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -867,6 +867,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\node\SophiaBackendFactory.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\peerfinder\PeerFinder.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1603,6 +1609,7 @@
|
||||
<ClInclude Include="..\..\src\ripple_core\node\NodeObject.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\node\NodeStore.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\node\NullBackendFactory.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\node\SophiaBackendFactory.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\peerfinder\PeerFinder.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\ripple_core.h" />
|
||||
<ClInclude Include="..\..\src\ripple_data\crypto\Base58.h" />
|
||||
|
||||
@@ -921,7 +921,10 @@
|
||||
<ClCompile Include="..\..\src\ripple_net\basics\AsyncService.cpp">
|
||||
<Filter>[1] Ripple\ripple_net\basics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\sophia\ripple_sophia.cpp">
|
||||
<ClCompile Include="..\..\src\ripple_core\node\SophiaBackendFactory.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\sophia\ripple_sophia.c">
|
||||
<Filter>[2] Ripple %28New%29\sophia</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@@ -1830,6 +1833,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\sophia\ripple_sophia.h">
|
||||
<Filter>[2] Ripple %28New%29\sophia</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\node\SophiaBackendFactory.h">
|
||||
<Filter>[1] Ripple\ripple_core\node</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\src\ripple_data\protocol\ripple.proto">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#if RIPPLE_SOPHIA_AVAILABLE
|
||||
|
||||
class SophiaBackendFactory::Backend
|
||||
: public NodeStore::Backend
|
||||
, LeakChecked <SophiaBackendFactory::Backend>
|
||||
, public NodeStore::BatchWriter::Callback
|
||||
, public LeakChecked <SophiaBackendFactory::Backend>
|
||||
{
|
||||
public:
|
||||
typedef RecycledObjectPool <std::string> 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
|
||||
|
||||
Reference in New Issue
Block a user