mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
FeatureSet DebugString
Summary: This will help debugging Test Plan: ran, observed output Reviewers: yinwang Reviewed By: yinwang Differential Revision: https://reviews.facebook.net/D20937
This commit is contained in:
parent
e4c3673923
commit
9c5a3f4746
|
@ -120,11 +120,14 @@ class FeatureSet {
|
||||||
iterator end() const { return map_.end(); }
|
iterator end() const { return map_.end(); }
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
size_t Size() const { return map_.size(); }
|
||||||
|
|
||||||
void Serialize(std::string* output) const;
|
void Serialize(std::string* output) const;
|
||||||
// REQUIRED: empty FeatureSet
|
// REQUIRED: empty FeatureSet
|
||||||
bool Deserialize(const Slice& input);
|
bool Deserialize(const Slice& input);
|
||||||
|
|
||||||
|
std::string DebugString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
map map_;
|
map map_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
#ifndef ROCKSDB_LITE
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
#include "rocksdb/utilities/spatial_db.h"
|
||||||
|
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#include <inttypes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -13,7 +17,6 @@
|
||||||
#include "rocksdb/cache.h"
|
#include "rocksdb/cache.h"
|
||||||
#include "rocksdb/db.h"
|
#include "rocksdb/db.h"
|
||||||
#include "rocksdb/utilities/stackable_db.h"
|
#include "rocksdb/utilities/stackable_db.h"
|
||||||
#include "rocksdb/utilities/spatial_db.h"
|
|
||||||
#include "util/coding.h"
|
#include "util/coding.h"
|
||||||
#include "utilities/spatialdb/utils.h"
|
#include "utilities/spatialdb/utils.h"
|
||||||
|
|
||||||
|
@ -197,6 +200,48 @@ bool FeatureSet::Deserialize(const Slice& input) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string FeatureSet::DebugString() const {
|
||||||
|
std::string out = "{";
|
||||||
|
bool comma = false;
|
||||||
|
for (const auto& iter : map_) {
|
||||||
|
if (comma) {
|
||||||
|
out.append(", ");
|
||||||
|
} else {
|
||||||
|
comma = true;
|
||||||
|
}
|
||||||
|
out.append("\"" + iter.first + "\": ");
|
||||||
|
switch (iter.second.type()) {
|
||||||
|
case Variant::kNull:
|
||||||
|
out.append("null");
|
||||||
|
case Variant::kBool:
|
||||||
|
if (iter.second.get_bool()) {
|
||||||
|
out.append("true");
|
||||||
|
} else {
|
||||||
|
out.append("false");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Variant::kInt: {
|
||||||
|
char buf[32];
|
||||||
|
snprintf(buf, sizeof(buf), "%" PRIu64, iter.second.get_int());
|
||||||
|
out.append(buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Variant::kDouble: {
|
||||||
|
char buf[32];
|
||||||
|
snprintf(buf, sizeof(buf), "%lf", iter.second.get_double());
|
||||||
|
out.append(buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Variant::kString:
|
||||||
|
out.append("\"" + iter.second.get_string() + "\"");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out + "}";
|
||||||
|
}
|
||||||
|
|
||||||
class SpatialIndexCursor : public Cursor {
|
class SpatialIndexCursor : public Cursor {
|
||||||
public:
|
public:
|
||||||
SpatialIndexCursor(Iterator* spatial_iterator, Iterator* data_iterator,
|
SpatialIndexCursor(Iterator* spatial_iterator, Iterator* data_iterator,
|
||||||
|
|
Loading…
Reference in a new issue