YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/client/in_flight_op.h
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_CLIENT_IN_FLIGHT_OP_H
15
#define YB_CLIENT_IN_FLIGHT_OP_H
16
17
#include <string>
18
19
#include <gflags/gflags_declare.h>
20
21
#include "yb/client/client_fwd.h"
22
23
#include "yb/gutil/ref_counted.h"
24
25
#include "yb/util/enums.h"
26
#include "yb/util/status.h"
27
28
namespace yb {
29
namespace client {
30
namespace internal {
31
32
// An operation which has been submitted to the batcher and not yet completed.
33
// The operation goes through a state machine as it progresses through the
34
// various stages of a request. See the State enum for details.
35
//
36
// Note that in-flight ops *conceptually* hold a reference to the Batcher object.
37
// However, since there might be millions of these objects floating around,
38
// we can save a pointer per object by manually incrementing the Batcher ref-count
39
// when we create the object, and decrementing when we delete it.
40
struct InFlightOp {
41
  InFlightOp(std::shared_ptr<YBOperation> yb_op_, size_t seq_no);
42
43
  InFlightOp(const InFlightOp& rhs) = delete;
44
  void operator=(const InFlightOp& rhs) = delete;
45
3.74M
  InFlightOp(InFlightOp&& rhs) = default;
46
7.78M
  InFlightOp& operator=(InFlightOp&& rhs) = default;
47
48
  // The actual operation.
49
  std::shared_ptr<YBOperation> yb_op;
50
51
  std::string partition_key;
52
53
  // The tablet the operation is destined for.
54
  // This is only filled in after passing through the kLookingUpTablet state.
55
  RemoteTabletPtr tablet;
56
57
  Status error;
58
59
  // Each operation has a unique sequence number which preserves the user's intended
60
  // order of operations. This is important when multiple operations act on the same row.
61
  size_t sequence_number;
62
63
  // Set only for the first operation in group.
64
  // Operations are groupped by tablet and operation kind (write, leader read, follower read).
65
  int64_t batch_idx = -1;
66
67
  std::string ToString() const;
68
};
69
70
} // namespace internal
71
} // namespace client
72
} // namespace yb
73
74
#endif // YB_CLIENT_IN_FLIGHT_OP_H