forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pika_bit.h
122 lines (94 loc) · 2.35 KB
/
pika_bit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_BIT_H_
#define PIKA_BIT_H_
#include "pika_command.h"
/*
* bitoperation
*/
// TODO: 17/3/5 by zmyer
class BitGetCmd : public Cmd {
public:
BitGetCmd() { };
virtual void Do();
private:
std::string key_;
int64_t bit_offset_;
virtual void Clear() {
key_ = "";
bit_offset_ = -1;
}
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo *const ptr_info);
};
// TODO: 17/3/5 by zmyer
class BitSetCmd : public Cmd {
public:
BitSetCmd() { };
virtual void Do();
private:
std::string key_;
int64_t bit_offset_;
int64_t on_;
virtual void Clear() {
key_ = "";
bit_offset_ = -1;
on_ = -1;
}
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo *const ptr_info);
};
class BitCountCmd : public Cmd {
public:
BitCountCmd() { }
virtual void Do();
private:
std::string key_;
bool count_all_;
int64_t start_offset_;
int64_t end_offset_;
virtual void Clear() {
key_ = "";
count_all_ = false;
start_offset_ = -1;
end_offset_ = -1;
}
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo *const ptr_info);
};
class BitPosCmd : public Cmd {
public:
BitPosCmd() { };
virtual void Do();
private:
std::string key_;
bool pos_all_;
bool endoffset_set_;
int64_t bit_val_;
int64_t start_offset_;
int64_t end_offset_;
virtual void Clear() {
key_ = "";
pos_all_ = false;
endoffset_set_ = false;
bit_val_ = -1;
start_offset_ = -1;
end_offset_ = -1;
}
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo *const ptr_info);
};
class BitOpCmd : public Cmd {
public:
BitOpCmd() { };
virtual void Do();
private:
std::string dest_key_;
std::vector<std::string> src_keys_;
nemo::BitOpType op_;
virtual void Clear() {
dest_key_ = "";
src_keys_.clear();
op_ = nemo::kBitOpDefault;
}
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo *const ptr_info);
};
#endif