<commit_before>// Package store provides a distributed SQLite instance.
//
// Distributed consensus is provided via the Raft algorithm.
package store

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"os"
	"path/filepath"
	"sync"
	"time"

	"github.com/hashicorp/raft"
	"github.com/hashicorp/raft-boltdb"
	sql "github.com/otoolep/rqlite/db"
)

const (
	retainSnapshotCount = 2
	raftTimeout         = 10 * time.Second
	sqliteFile          = "db.sqlite"
	leaderWaitDelay     = 100 * time.Millisecond
	appliedWaitDelay    = 100 * time.Millisecond
)

var (
	// ErrFieldsRequired is returned when a node attempts to execute a leader-only
	// operation.
	ErrNotLeader = errors.New("not leader")
)

type ConsistencyLevel int

const (
	None ConsistencyLevel = iota
	Soft
	Hard
)

type commandType int

const (
	execute commandType = iota
	query
)

type command struct {
	Typ     commandType `json:"typ,omitempty"`
	Tx      bool        `json:"tx,omitempty"`
	Queries []string    `json:"queries,omitempty"`
	Timings bool        `json:"timings",omitempty"`
}

// Store is a SQLite database, where all changes are made via Raft consensus.
type Store struct {
	raftDir  string
	raftBind string<commit_msg>Fix 'timings' JSON tag<commit_after>// Package store provides a distributed SQLite instance.
//
// Distributed consensus is provided via the Raft algorithm.
package store

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"os"
	"path/filepath"
	"sync"
	"time"

	"github.com/hashicorp/raft"
	"github.com/hashicorp/raft-boltdb"
	sql "github.com/otoolep/rqlite/db"
)

const (
	retainSnapshotCount = 2
	raftTimeout         = 10 * time.Second
	sqliteFile          = "db.sqlite"
	leaderWaitDelay     = 100 * time.Millisecond
	appliedWaitDelay    = 100 * time.Millisecond
)

var (
	// ErrFieldsRequired is returned when a node attempts to execute a leader-only
	// operation.
	ErrNotLeader = errors.New("not leader")
)

type ConsistencyLevel int

const (
	None ConsistencyLevel = iota
	Soft
	Hard
)

type commandType int

const (
	execute commandType = iota
	query
)

type command struct {
	Typ     commandType `json:"typ,omitempty"`
	Tx      bool        `json:"tx,omitempty"`
	Queries []string    `json:"queries,omitempty"`
	Timings bool        `json:"timings,omitempty"`
}

// Store is a SQLite database, where all changes are made via Raft consensus.
type Store struct {
	raftDir  string
	raftBind string
{'fraction_non_alphanumeric': 0.10349025974025974, 'fraction_numerical': 0.007305194805194805, 'mean_word_length': 3.433453237410072, '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': '1821923', 'n_tokens_mistral': 867, 'n_tokens_neox': 840, 'n_words': 236}