<commit_before>// Copyright 2012 <NAME>. All Rights Reserved.
// Author: <EMAIL> (<NAME>)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package sdb

import (
	"fmt"
	"github.com/jacobsa/aws/exp/sdb/conn"
)

type batchPutPair struct {
	Item ItemName
	Updates []PutUpdate
}

func getSortedPairs(updateMap map[ItemName][]PutUpdate) []batchPutPair

func validateUpdate(u PutUpdate) (err error) {
	// Make sure the attribute name is legal.
	if u.Name == "" {
		return fmt.Errorf("Invalid attribute name; names must be non-empty.")
	}

	if err = validateValue(string(u.Name)); err != nil {
		return fmt.Errorf("Invalid attribute name: %v", err)<commit_msg>Fixed a bug.<commit_after>// Copyright 2012 <NAME>. All Rights Reserved.
// Author: <EMAIL> (<NAME>)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package sdb

import (
	"fmt"
	"github.com/jacobsa/aws/exp/sdb/conn"
	"sort"
)

type batchPutPair struct {
	Item ItemName
	Updates []PutUpdate
}

type batchPutPairList []batchPutPair

func (l batchPutPairList) Len() int           { return len(l) }
func (l batchPutPairList) Less(i, j int) bool { return l[i].Item < l[j].Item }
func (l batchPutPairList) Swap(i, j int)      { l[j], l[i] = l[i], l[j] }

// Return the elements of the map sorted by item name.
func getSortedPairs(updateMap map[ItemName][]PutUpdate) batchPutPairList {
	res := batchPutPairList{}
	for item, updates := range updateMap {
		res = append(res, batchPutPair{item, updates})
	}

	sort.Sort(res)
	return res
}

func validateUpdate(u PutUpdate) (err error) {
	// Make sure the attribute name is legal.
	if u.Name == "" {
		return fmt.Errorf("Invalid attribute name; names must be non-empty.")
	}

	if err = validateValue(string(u.Name)); err != nil {
		return fmt.Errorf("Invalid attribute name: %v", err)
{'fraction_non_alphanumeric': 0.11758398856325947, 'fraction_numerical': 0.005718370264474625, 'mean_word_length': 3.7521222410865875, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5580901', 'n_tokens_mistral': 861, 'n_tokens_neox': 837, 'n_words': 330}