1
0
Fork 0

result writer

This commit is contained in:
Simon Grätzer 2016-10-31 19:31:17 +01:00
parent 8463c41540
commit f57c76fda0
3 changed files with 66 additions and 52 deletions

View File

@ -23,5 +23,56 @@
#include "ResultWriter.h" #include "ResultWriter.h"
#include "GraphStore.h" #include "GraphStore.h"
#include "Utils/OperationCursor.h"
#include "Utils/SingleCollectionTransaction.h"
#include "Utils/StandaloneTransactionContext.h"
#include "Utils/Transaction.h"
#include "VocBase/ticks.h"
#include "VocBase/vocbase.h"
#include <velocypack/Iterator.h>
#include <velocypack/velocypack-aliases.h>
using namespace arangodb;
using namespace arangodb::pregel; using namespace arangodb::pregel;
using namespace arangodb::pregel::algos;
template <typename V, typename E>
void ResultWriter<V,E>::writeResults(TRI_vocbase_t *vocbase, GraphStore<V,E> *store) {
SingleCollectionTransaction
trx(StandaloneTransactionContext::Create(vocbase),
_vertexCollection, TRI_TRANSACTION_WRITE);
int res = trx.begin();
if (res != TRI_ERROR_NO_ERROR) {
LOG(ERR) << "cannot start transaction to load authentication";
return;
}*/
/*
OperationResult result;
OperationOptions options;
options.waitForSync = false;
options.mergeObjects = true;
for (auto const &pair : _vertices) {
//TransactionBuilderLeaser b(&trx);
VPackBuilder b;
b.openObject();
b.add(StaticStrings::KeyString,
pair.second->_data.get(StaticStrings::KeyString));
b.add("value", VPackValue(pair.second->_vertexState));
b.close();
LOG(INFO) << b.toJson();
result = trx.update(_vertexCollection, b->slice(), options);
if (!result.successful()) {
THROW_ARANGO_EXCEPTION_FORMAT(result.code, "while looking up graph
'%s'",
_vertexCollection.c_str());
}
}*/
// Commit or abort.
/*res = trx.finish(result.code);
if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION_FORMAT(res, "while looking up graph '%s'",
_vertexCollection.c_str());
}
}

View File

@ -24,25 +24,24 @@
#define ARANGODB_PREGEL_ALGO_SSSP_H 1 #define ARANGODB_PREGEL_ALGO_SSSP_H 1
#include "Algorithm.h" #include "Algorithm.h"
struct TRI_vocbase_t;
namespace arangodb { namespace arangodb {
namespace pregel { namespace pregel {
namespace algos {
/// Single Source Shortest Path. Uses integer attribute 'value', the source template<typename V, typename E> class GraphStore;
/// should have
/// the value == 0, all others -1 or an undefined value template<typename V, typename E>
struct SSSPAlgorithm : public Algorithm<int64_t, int64_t, int64_t> { class ResultWriter {
std::string _resultVertexCollection;
std::string _resultEdgeCollection;
bool _writeInSameCollections = true;
bool resultField;
public: public:
SSSPAlgorithm() : Algorithm("SSSP") {} ResultWriter(VPackSlice params) {}
void writeResults(TRI_vocbase_t *vocbase, GraphStore<V,E> *store);
size_t estimatedVertexSize() const override;
std::shared_ptr<GraphFormat<int64_t, int64_t>> inputFormat() const override;
std::shared_ptr<MessageFormat<int64_t>> messageFormat() const override;
std::shared_ptr<MessageCombiner<int64_t>> messageCombiner() const override;
std::shared_ptr<VertexComputation<int64_t, int64_t, int64_t>>
createComputation() const override;
}; };
} }
} }
}
#endif #endif

View File

@ -182,43 +182,7 @@ void Worker<V, E, M>::workerJobIsDone(bool allDone) {
template <typename V, typename E, typename M> template <typename V, typename E, typename M>
void Worker<V, E, M>::writeResults() { void Worker<V, E, M>::writeResults() {
/*SingleCollectionTransaction /**/
trx(StandaloneTransactionContext::Create(_vocbaseGuard.vocbase()),
_vertexCollection, TRI_TRANSACTION_WRITE);
int res = trx.begin();
if (res != TRI_ERROR_NO_ERROR) {
LOG(ERR) << "cannot start transaction to load authentication";
return;
}*/
/*
OperationResult result;
OperationOptions options;
options.waitForSync = false;
options.mergeObjects = true;
for (auto const &pair : _vertices) {
//TransactionBuilderLeaser b(&trx);
VPackBuilder b;
b.openObject();
b.add(StaticStrings::KeyString,
pair.second->_data.get(StaticStrings::KeyString));
b.add("value", VPackValue(pair.second->_vertexState));
b.close();
LOG(INFO) << b.toJson();
result = trx.update(_vertexCollection, b->slice(), options);
if (!result.successful()) {
THROW_ARANGO_EXCEPTION_FORMAT(result.code, "while looking up graph
'%s'",
_vertexCollection.c_str());
}
}*/
// Commit or abort.
/*res = trx.finish(result.code);
if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION_FORMAT(res, "while looking up graph '%s'",
_vertexCollection.c_str());
}*/
VPackBuilder b; VPackBuilder b;
b.openArray(); b.openArray();
auto it = _graphStore->vertexIterator(); auto it = _graphStore->vertexIterator();