<commit_before>// Copyright (C) 2015  The GoHBase Authors.  All rights reserved.
// This file is part of GoHBase.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.

package hrpc

import (
	"github.com/golang/protobuf/proto"
	"github.com/tsuna/gohbase/pb"
)

// Mutate represents a mutation on HBase.
type Mutate struct {
	base

	row          *[]byte
	mutationType pb.MutationProto_MutationType //*int32

	//values is a map of column families to a map of column qualifiers to bytes
	values map[string]map[string][]byte
}

// NewPutStr creates a new Mutation request that will put the given values into
// HBase under the given table and key.
func NewPutStr(table, key string, values map[string]map[string][]byte) *Mutate {
	return &Mutate{
		base: base{
			table: []byte(table),
			key:   []byte(key),
		},
		mutationType: pb.MutationProto_PUT,
		values:       values,
	}
}

// NewDelStr creates a new Mutation request that will delete the given values
// from HBase under the given table and key.
func NewDelStr(table, key string, values map[string]map[string][]byte) *Mutate {
	return &Mutate{
		base: base{
			table: []byte(table),
			key:   []byte(key),
		},
		mutationType: pb.MutationProto_DELETE,
		values:       values,
	}
}

// NewAppStr creates a new Mutation request that will append the given values
// to their existing values in HBase under the given table and key.
func NewAppStr(table, key string, values map[string]map[string][]byte) *Mutate {
	return &Mutate{
		base: base{
			table: []byte(table),
			key:   []byte(key),
		},
		mutationType: pb.MutationProto_APPEND,
		values:       values,
	}
}

// NewIncStr creates a new Mutation request that will increment the given values
// in HBase under the given table and key.
func NewIncStr(table, key string, values map[string]map[string][]byte) *Mutate {
	return &Mutate{
		base: base{
			table: []byte(table),
			key:   []byte(key),
		},
		mutationType: pb.MutationProto_INCREMENT,
		values:       values,
	}
}

// Name returns the name of this RPC call.
func (m *Mutate) Name() string {
	return "Mutate"
}
<commit_msg>Factor out some duplicated code.<commit_after>// Copyright (C) 2015  The GoHBase Authors.  All rights reserved.
// This file is part of GoHBase.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.

package hrpc

import (
	"github.com/golang/protobuf/proto"
	"github.com/tsuna/gohbase/pb"
)

// Mutate represents a mutation on HBase.
type Mutate struct {
	base

	row          *[]byte
	mutationType pb.MutationProto_MutationType //*int32

	//values is a map of column families to a map of column qualifiers to bytes
	values map[string]map[string][]byte
}

// baseMutate will return a Mutate struct without the mutationType filled in.
func baseMutate(table, key string, values map[string]map[string][]byte) *Mutate {
	return &Mutate{
		base: base{
			table: []byte(table),
			key:   []byte(key),
		},
		values: values,
	}
}

// NewPutStr creates a new Mutation request that will put the given values into
// HBase under the given table and key.
func NewPutStr(table, key string, values map[string]map[string][]byte) *Mutate {
	m := baseMutate(table, key, values)
	m.mutationType = pb.MutationProto_PUT
	return m
}

// NewDelStr creates a new Mutation request that will delete the given values
// from HBase under the given table and key.
func NewDelStr(table, key string, values map[string]map[string][]byte) *Mutate {
	m := baseMutate(table, key, values)
	m.mutationType = pb.MutationProto_DELETE
	return m
}

// NewAppStr creates a new Mutation request that will append the given values
// to their existing values in HBase under the given table and key.
func NewAppStr(table, key string, values map[string]map[string][]byte) *Mutate {
	m := baseMutate(table, key, values)
	m.mutationType = pb.MutationProto_APPEND
	return m
}

// NewIncStr creates a new Mutation request that will increment the given values
// in HBase under the given table and key.
func NewIncStr(table, key string, values map[string]map[string][]byte) *Mutate {
	m := baseMutate(table, key, values)
	m.mutationType = pb.MutationProto_INCREMENT
	return m
}

// Name returns the name of this RPC call.
func (m *Mutate) Name() string {
	return "Mutate"
}

{'fraction_non_alphanumeric': 0.10233850428339894, 'fraction_numerical': 0.0037045612410280156, 'mean_word_length': 3.8484848484848486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5345163', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1400, 'n_words': 512}