-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
heng
committed
Aug 22, 2019
1 parent
e1f566e
commit 2f46e97
Showing
35 changed files
with
939 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
#include "kvstore/SnapshotManagerImpl.h" | ||
#include "base/NebulaKeyUtils.h" | ||
#include "kvstore/LogEncoder.h" | ||
|
||
DEFINE_int32(snapshot_batch_size, 1024 * 1024 * 10, "batch size for snapshot"); | ||
|
||
namespace nebula { | ||
namespace kvstore { | ||
|
||
void SnapshotManagerImpl::accessAllRowsInSnapshot(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
raftex::SnapshotCallback cb) { | ||
CHECK_NOTNULL(store_); | ||
std::unique_ptr<KVIterator> iter; | ||
auto prefix = NebulaKeyUtils::prefix(partId); | ||
store_->prefix(spaceId, partId, prefix, &iter); | ||
std::vector<std::string> data; | ||
data.reserve(1024); | ||
int32_t batchSize = 0; | ||
int64_t totalSize = 0; | ||
int64_t totalCount = 0; | ||
while (iter->valid()) { | ||
if (batchSize >= FLAGS_snapshot_batch_size) { | ||
cb(std::move(data), totalCount, totalSize, false); | ||
data.clear(); | ||
batchSize = 0; | ||
} | ||
auto key = iter->key(); | ||
auto val = iter->val(); | ||
data.emplace_back(encodeKV(key, val)); | ||
batchSize += data.back().size(); | ||
totalSize += data.back().size(); | ||
totalCount++; | ||
iter->next(); | ||
} | ||
if (data.size() > 0) { | ||
cb(std::move(data), totalCount, totalSize, true); | ||
} | ||
} | ||
} // namespace kvstore | ||
} // namespace nebula | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef KVSTORE_SNAPSHOTMANAGERIMPL_H_ | ||
#define KVSTORE_SNAPSHOTMANAGERIMPL_H_ | ||
|
||
#include "base/Base.h" | ||
#include "kvstore/raftex/SnapshotManager.h" | ||
#include "kvstore/KVStore.h" | ||
|
||
namespace nebula { | ||
namespace kvstore { | ||
|
||
class SnapshotManagerImpl : public raftex::SnapshotManager { | ||
public: | ||
explicit SnapshotManagerImpl(KVStore* kv) : store_(kv) {} | ||
|
||
void accessAllRowsInSnapshot(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
raftex::SnapshotCallback cb) override; | ||
|
||
private: | ||
KVStore* store_; | ||
}; | ||
|
||
} // namespace kvstore | ||
} // namespace nebula | ||
|
||
#endif // KVSTORE_SNAPSHOTMANAGERIMPL_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ nebula_add_library( | |
RaftPart.cpp | ||
RaftexService.cpp | ||
Host.cpp | ||
SnapshotManager.cpp | ||
) | ||
|
||
add_subdirectory(test) |
Oops, something went wrong.