<commit_before>// Copyright (c) 2014, Cloudera, inc.
#ifndef KUDU_CLIENT_WRITE_OP_H
#define KUDU_CLIENT_WRITE_OP_H

#include <string>

#include "common/partial_row.h"
#include "common/wire_protocol.pb.h"
#include "gutil/gscoped_ptr.h"
#include "gutil/ref_counted.h"

namespace kudu {

class EncodedKey;

namespace client {

namespace internal {
class Batcher;
} // namespace internal

class KuduTable;

// A write operation operates on a single table and partial row.
// The KuduWriteOperation class itself allows the batcher to get to the
// generic information that it needs to process all write operations.
//
// On its own, the class does not represent any specific change and thus cannot
// be constructed independently.
//
// KuduWriteOperation also holds shared ownership of its KuduTable to allow client's
// scope to end while the KuduWriteOperation is still alive.
class KuduWriteOperation {
 public:
  virtual ~KuduWriteOperation();

  const KuduTable* table() const { return table_.get(); }
  const KuduPartialRow& row() const { return row_; }

  // See KuduPartialRow API for field setters, etc.
  KuduPartialRow* mutable_row() { return &row_; }

  virtual RowOperationsPB::Type RowOperationType() const = 0;
  virtual std::string ToString() const = 0;
 protected:
  explicit KuduWriteOperation(KuduTable *table);

  scoped_refptr<KuduTable> const table_;
  KuduPartialRow row_;

 private:
  friend class internal::Batcher; // for CreateKey.

  // Create and encode the key for this write (key must be set)
  //
  // Caller takes ownership of the allocated memory.
  gscoped_ptr<EncodedKey> CreateKey() const;

  DISALLOW_COPY_AND_ASSIGN(KuduWriteOperation);
};

// A single row insert to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being inserted
// An insert requires all key columns from the table schema to be defined.
class KuduInsert : public KuduWriteOperation {
 public:
  virtual ~KuduInsert();

  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::INSERT;
  }
  virtual std::string ToString() const OVERRIDE { return "INSERT " + row_.ToString(); }

 private:
  friend class KuduTable;
  explicit KuduInsert(KuduTable* table);
};


// A single row update to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being updated.
// An update requires the key columns and at least one other column
// in the schema to be defined.
class KuduUpdate : public KuduWriteOperation {
 public:
  virtual ~KuduUpdate();

  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::UPDATE;
  }
  virtual std::string ToString() const OVERRIDE { return "UPDATE " + row_.ToString(); }

 private:
  friend class KuduTable;
  explicit KuduUpdate(KuduTable* table);
};


// A single row delete to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being deleted
// A delete requires just the key columns to be defined.
class KuduDelete : public KuduWriteOperation {
 public:
  virtual ~KuduDelete();

  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::DELETE;
  }
  virtual std::string ToString() const OVERRIDE { return "DELETE " + row_.ToString(); }

 private:
  friend class KuduTable;
  explicit KuduDelete(KuduTable* table);
};

} // namespace client
} // namespace kudu

#endif<commit_msg>C++ client: reduce visibility of WriteOperation::RowOperationType<commit_after>// Copyright (c) 2014, Cloudera, inc.
#ifndef KUDU_CLIENT_WRITE_OP_H
#define KUDU_CLIENT_WRITE_OP_H

#include <string>

#include "common/partial_row.h"
#include "common/wire_protocol.pb.h"
#include "gutil/gscoped_ptr.h"
#include "gutil/ref_counted.h"

namespace kudu {

class EncodedKey;

namespace client {

namespace internal {
class Batcher;
} // namespace internal

class KuduTable;

// A write operation operates on a single table and partial row.
// The KuduWriteOperation class itself allows the batcher to get to the
// generic information that it needs to process all write operations.
//
// On its own, the class does not represent any specific change and thus cannot
// be constructed independently.
//
// KuduWriteOperation also holds shared ownership of its KuduTable to allow client's
// scope to end while the KuduWriteOperation is still alive.
class KuduWriteOperation {
 public:
  virtual ~KuduWriteOperation();

  // See KuduPartialRow API for field setters, etc.
  const KuduPartialRow& row() const { return row_; }
  KuduPartialRow* mutable_row() { return &row_; }

  virtual std::string ToString() const = 0;
 protected:
  explicit KuduWriteOperation(KuduTable *table);
  virtual RowOperationsPB::Type RowOperationType() const = 0;

  scoped_refptr<KuduTable> const table_;
  KuduPartialRow row_;

 private:
  friend class internal::Batcher;

  // Create and encode the key for this write (key must be set)
  //
  // Caller takes ownership of the allocated memory.
  gscoped_ptr<EncodedKey> CreateKey() const;

  const KuduTable* table() const { return table_.get(); }

  DISALLOW_COPY_AND_ASSIGN(KuduWriteOperation);
};

// A single row insert to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being inserted
// An insert requires all key columns from the table schema to be defined.
class KuduInsert : public KuduWriteOperation {
 public:
  virtual ~KuduInsert();

  virtual std::string ToString() const OVERRIDE { return "INSERT " + row_.ToString(); }

 protected:
  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::INSERT;
  }

 private:
  friend class KuduTable;
  explicit KuduInsert(KuduTable* table);
};


// A single row update to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being updated.
// An update requires the key columns and at least one other column
// in the schema to be defined.
class KuduUpdate : public KuduWriteOperation {
 public:
  virtual ~KuduUpdate();

  virtual std::string ToString() const OVERRIDE { return "UPDATE " + row_.ToString(); }

 protected:
  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::UPDATE;
  }

 private:
  friend class KuduTable;
  explicit KuduUpdate(KuduTable* table);
};


// A single row delete to be sent to the cluster.
// Row operation is defined by what's in the PartialRow instance here.
// Use mutable_row() to change the row being deleted
// A delete requires just the key columns to be defined.
class KuduDelete : public KuduWriteOperation {
 public:
  virtual ~KuduDelete();

  virtual std::string ToString() const OVERRIDE { return "DELETE " + row_.ToString(); }

 protected:
  virtual RowOperationsPB::Type RowOperationType() const OVERRIDE {
    return RowOperationsPB::DELETE;
  }

 private:
  friend class KuduTable;
  explicit KuduDelete(KuduTable* table);
};

} // namespace client
} // namespace kudu

#endif
{'fraction_non_alphanumeric': 0.08680603627301675, 'fraction_numerical': 0.0016613595458950575, 'mean_word_length': 4.269146608315099, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6235610', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2128, 'n_words': 805}