mirror of https://gitee.com/bigwinds/arangodb
result writer
This commit is contained in:
parent
8463c41540
commit
f57c76fda0
|
@ -23,5 +23,56 @@
|
|||
#include "ResultWriter.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::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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,25 +24,24 @@
|
|||
#define ARANGODB_PREGEL_ALGO_SSSP_H 1
|
||||
#include "Algorithm.h"
|
||||
|
||||
|
||||
struct TRI_vocbase_t;
|
||||
namespace arangodb {
|
||||
namespace pregel {
|
||||
namespace algos {
|
||||
|
||||
/// Single Source Shortest Path. Uses integer attribute 'value', the source
|
||||
/// should have
|
||||
/// the value == 0, all others -1 or an undefined value
|
||||
struct SSSPAlgorithm : public Algorithm<int64_t, int64_t, int64_t> {
|
||||
template<typename V, typename E> class GraphStore;
|
||||
|
||||
template<typename V, typename E>
|
||||
class ResultWriter {
|
||||
std::string _resultVertexCollection;
|
||||
std::string _resultEdgeCollection;
|
||||
bool _writeInSameCollections = true;
|
||||
bool resultField;
|
||||
|
||||
public:
|
||||
SSSPAlgorithm() : Algorithm("SSSP") {}
|
||||
|
||||
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;
|
||||
ResultWriter(VPackSlice params) {}
|
||||
void writeResults(TRI_vocbase_t *vocbase, GraphStore<V,E> *store);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -182,43 +182,7 @@ void Worker<V, E, M>::workerJobIsDone(bool allDone) {
|
|||
|
||||
template <typename V, typename E, typename M>
|
||||
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;
|
||||
b.openArray();
|
||||
auto it = _graphStore->vertexIterator();
|
||||
|
|
Loading…
Reference in New Issue