#ifndef ENCODE_INDEX_H
|
|
#define ENCODE_INDEX_H
|
|
|
|
#include "leveldb/slice.h"
|
|
#include "util/coding.h"
|
|
namespace fielddb{
|
|
using namespace leveldb;
|
|
|
|
|
|
struct ParsedInternalIndexKey { //key : {name : val}
|
|
Slice user_key_;
|
|
Slice name_;
|
|
Slice val_;
|
|
|
|
ParsedInternalIndexKey() {} // Intentionally left uninitialized (for speed)
|
|
ParsedInternalIndexKey(const Slice& user_key, const Slice& name, const Slice& val)
|
|
: user_key_(user_key), name_(name), val_(val) {}
|
|
};
|
|
|
|
bool ParseInternalIndexKey(Slice input, ParsedInternalIndexKey* result);
|
|
void AppendIndexKey(std::string* result, const ParsedInternalIndexKey& key);
|
|
|
|
|
|
inline bool ParseInternalIndexKey(Slice input, ParsedInternalIndexKey* result){
|
|
return GetLengthPrefixedSlice(&input, &result->name_) &&
|
|
GetLengthPrefixedSlice(&input, &result->val_) &&
|
|
GetLengthPrefixedSlice(&input, &result->user_key_);
|
|
}
|
|
|
|
inline void AppendIndexKey(std::string* result, const ParsedInternalIndexKey& key){
|
|
PutLengthPrefixedSlice(result, key.name_);
|
|
PutLengthPrefixedSlice(result, key.val_);
|
|
PutLengthPrefixedSlice(result, key.user_key_);
|
|
}
|
|
|
|
}
|
|
#endif
|