<commit_before>package collection

import (
	"context"
	"fmt"
	"log"
	"path"
	"path/filepath"
	"reflect"
	"strconv"
	"strings"
	"sync/atomic"

	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"

	"github.com/pachyderm/pachyderm/src/server/pkg/errutil"
	"github.com/pachyderm/pachyderm/src/server/pkg/watch"

	etcd "github.com/coreos/etcd/clientv3"
	"github.com/coreos/etcd/mvcc/mvccpb"
	"github.com/gogo/protobuf/proto"
)

const defaultLimit int64 = 1024

type order int

const (
	// Descend is passed to iterative methods to order the objects newest-to-oldest.
	Descend order = iota
	// Ascend is passed to iteration methods to order the objects oldest-to-newest.
	Ascend
)

type collection struct {
	etcdClient *etcd.Client
	prefix     string
	indexes    []Index
	// The limit used when listing the collection. This gets automatically
	// tuned when requests fail so it's stored per collection.
	limit int64
	// We need this to figure out the concrete type of the objects
	// that this collection is storing. It's pretty retarded, but
	// not sure what else we can do since types in Go are not first-class
	// objects.
	// To be clear, this is only necessary because of `Delete`, where we<commit_msg>Greatly increase defaultLimit.<commit_after>package collection

import (
	"context"
	"fmt"
	"log"
	"path"
	"path/filepath"
	"reflect"
	"strconv"
	"strings"
	"sync/atomic"

	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"

	"github.com/pachyderm/pachyderm/src/server/pkg/errutil"
	"github.com/pachyderm/pachyderm/src/server/pkg/watch"

	etcd "github.com/coreos/etcd/clientv3"
	"github.com/coreos/etcd/mvcc/mvccpb"
	"github.com/gogo/protobuf/proto"
)

// defaultLimit was experimentally determined to be the highest value that could work
// (It gets scaled down for specific collections if they trip the max-message size.)
const defaultLimit int64 = 262144

type order int

const (
	// Descend is passed to iterative methods to order the objects newest-to-oldest.
	Descend order = iota
	// Ascend is passed to iteration methods to order the objects oldest-to-newest.
	Ascend
)

type collection struct {
	etcdClient *etcd.Client
	prefix     string
	indexes    []Index
	// The limit used when listing the collection. This gets automatically
	// tuned when requests fail so it's stored per collection.
	limit int64
	// We need this to figure out the concrete type of the objects
	// that this collection is storing. It's pretty retarded, but
	// not sure what else we can do since types in Go are not first-class
	// objects.
	// To be clear, this is only necessary because of `Delete`, where we
{'fraction_non_alphanumeric': 0.09420289855072464, 'fraction_numerical': 0.007627765064836003, 'mean_word_length': 3.7091561938958706, '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': '5512461', 'n_tokens_mistral': 899, 'n_tokens_neox': 853, 'n_words': 290}