string idx;
switch (op.type) {
- case PlainIdx:
+ case BIIndexType::Plain:
idx = op.key.name;
break;
- case InstanceIdx:
+ case BIIndexType::Instance:
encode_obj_index_key(op.key, &idx);
break;
- case OLHIdx:
+ case BIIndexType::OLH:
encode_olh_data_key(op.key, &idx);
break;
default:
}
rgw_cls_bi_entry entry;
- entry.type = PlainIdx;
+ entry.type = BIIndexType::Plain;
entry.idx = iter->first;
entry.data = iter->second;
map<string, bufferlist>::iterator iter;
for (iter = keys.begin(); iter != keys.end(); ++iter) {
rgw_cls_bi_entry entry;
- entry.type = InstanceIdx;
+ entry.type = BIIndexType::Instance;
entry.idx = iter->first;
entry.data = iter->second;
map<string, bufferlist>::iterator iter;
for (iter = keys.begin(); iter != keys.end(); ++iter) {
rgw_cls_bi_entry entry;
- entry.type = OLHIdx;
+ entry.type = BIIndexType::OLH;
entry.idx = iter->first;
entry.data = iter->second;
cls_rgw_obj_key key;
BIIndexType type; /* namespace: plain, instance, olh */
- rgw_cls_bi_get_op() : type(PlainIdx) {}
+ rgw_cls_bi_get_op() : type(BIIndexType::Plain) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
#include "cls/rgw/cls_rgw_types.h"
#include "common/ceph_json.h"
{
bufferlist::iterator iter = bl.begin();
switch (index_type) {
- case PlainIdx:
- case InstanceIdx:
+ case BIIndexType::Plain:
+ case BIIndexType::Instance:
{
rgw_bucket_dir_entry entry;
decode(entry, iter);
encode_json("entry", entry, formatter);
}
break;
- case OLHIdx:
+ case BIIndexType::OLH:
{
rgw_bucket_olh_entry entry;
decode(entry, iter);
string s;
JSONDecoder::decode_json("type", s, obj);
if (s == "plain") {
- type = PlainIdx;
+ type = BIIndexType::Plain;
} else if (s == "instance") {
- type = InstanceIdx;
+ type = BIIndexType::Instance;
} else if (s == "olh") {
- type = OLHIdx;
+ type = BIIndexType::OLH;
} else {
- type = InvalidIdx;
+ type = BIIndexType::Invalid;
}
using ceph::encode;
switch (type) {
- case PlainIdx:
- case InstanceIdx:
+ case BIIndexType::Plain:
+ case BIIndexType::Instance:
{
rgw_bucket_dir_entry entry;
JSONDecoder::decode_json("entry", entry, obj);
}
}
break;
- case OLHIdx:
+ case BIIndexType::OLH:
{
rgw_bucket_olh_entry entry;
JSONDecoder::decode_json("entry", entry, obj);
{
string type_str;
switch (type) {
- case PlainIdx:
- type_str = "plain";
- break;
- case InstanceIdx:
- type_str = "instance";
- break;
- case OLHIdx:
- type_str = "olh";
- break;
- default:
- type_str = "invalid";
+ case BIIndexType::Plain:
+ type_str = "plain";
+ break;
+ case BIIndexType::Instance:
+ type_str = "instance";
+ break;
+ case BIIndexType::OLH:
+ type_str = "olh";
+ break;
+ default:
+ type_str = "invalid";
}
encode_json("type", type_str, f);
encode_json("idx", idx, f);
bufferlist::iterator iter = data.begin();
using ceph::decode;
switch (type) {
- case PlainIdx:
+ case BIIndexType::Plain:
account = true;
// NO BREAK; falls through to case InstanceIdx:
- case InstanceIdx:
+ case BIIndexType::Instance:
{
rgw_bucket_dir_entry entry;
decode(entry, iter);
accounted_stats->actual_size += entry.meta.size;
}
break;
- case OLHIdx:
+ case BIIndexType::OLH:
{
rgw_bucket_olh_entry entry;
decode(entry, iter);
};
WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
-enum BIIndexType {
- InvalidIdx = 0,
- PlainIdx = 1,
- InstanceIdx = 2,
- OLHIdx = 3,
+enum class BIIndexType : uint8_t {
+ Invalid = 0,
+ Plain = 1,
+ Instance = 2,
+ OLH = 3,
};
struct rgw_bucket_category_stats;
string idx;
bufferlist data;
- rgw_cls_bi_entry() : type(InvalidIdx) {}
+ rgw_cls_bi_entry() : type(BIIndexType::Invalid) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- encode((uint8_t)type, bl);
+ encode(type, bl);
encode(idx, bl);
encode(data, bl);
ENCODE_FINISH(bl);
BIIndexType get_bi_index_type(const string& type_str) {
if (type_str == "plain")
- return PlainIdx;
+ return BIIndexType::Plain;
if (type_str == "instance")
- return InstanceIdx;
+ return BIIndexType::Instance;
if (type_str == "olh")
- return OLHIdx;
+ return BIIndexType::OLH;
- return InvalidIdx;
+ return BIIndexType::Invalid;
}
void dump_bi_entry(bufferlist& bl, BIIndexType index_type, Formatter *formatter)
{
bufferlist::iterator iter = bl.begin();
switch (index_type) {
- case PlainIdx:
- case InstanceIdx:
+ case BIIndexType::Plain:
+ case BIIndexType::Instance:
{
rgw_bucket_dir_entry entry;
decode(entry, iter);
encode_json("entry", entry, formatter);
}
break;
- case OLHIdx:
+ case BIIndexType::OLH:
{
rgw_bucket_olh_entry entry;
decode(entry, iter);
uint64_t max_rewrite_size = ULLONG_MAX;
uint64_t min_rewrite_stripe_size = 0;
- BIIndexType bi_index_type = PlainIdx;
+ BIIndexType bi_index_type = BIIndexType::Plain;
string job_id;
int num_shards = 0;
} else if (ceph_argparse_witharg(args, i, &val, "--index-type", (char*)NULL)) {
string index_type_str = val;
bi_index_type = get_bi_index_type(index_type_str);
- if (bi_index_type == InvalidIdx) {
+ if (bi_index_type == BIIndexType::Invalid) {
cerr << "ERROR: invalid bucket index entry type" << std::endl;
return EINVAL;
}
}
rgw_cls_bi_entry bi_entry;
- r = bi_get(obj.bucket, obj, InstanceIdx, &bi_entry);
+ r = bi_get(obj.bucket, obj, BIIndexType::Instance, &bi_entry);
if (r < 0 && r != -ENOENT) {
ldout(cct, 0) << "ERROR: bi_get() returned r=" << r << dendl;
}