Documentation ¶
Index ¶
- Constants
- Variables
- func InitDB(address string, dbName string) error
- func NewDriver(blockAddress string, dbAddress string, dbName string) (drive.Driver, error)
- func RemoveDB(address string, dbName string) error
- type ErrBranchExists
- type ErrCommitFinished
- type ErrCommitNotFound
- type PrimaryKey
- type Table
Constants ¶
const (
// ErrConflictFileTypeMsg is used when we see a file that is both a file and directory
ErrConflictFileTypeMsg = "file type conflict"
)
Variables ¶
var ClockBranchIndex = &index{ Name: "ClockBranchIndex", Table: clockTable, CreateFunction: func(row gorethink.Term) interface{} { return []interface{}{ row.Field("Repo"), row.Field("Branch"), } }, }
ClockBranchIndex maps a branch to a clock
var CommitClockIndex = &index{ Name: "CommitClockIndex", Table: commitTable, CreateFunction: func(row gorethink.Term) interface{} { lastClock := row.Field("FullClock").Nth(-1) return []interface{}{ row.Field("Repo"), lastClock.Field("Branch"), lastClock.Field("Clock"), } }, }
CommitClockIndex maps clocks to commits Format: repo + head of clocks Example: A commit that has the clock [(master, 2), (foo, 3)] will be indexed to: ["repo", "foo", 3]
var CommitFullClockIndex = &index{ Name: "CommitFullClockIndex", Table: commitTable, CreateFunction: func(row gorethink.Term) interface{} { return []interface{}{ row.Field("Repo"), persist.FullClockToArray(row.Field("FullClock")), } }, }
CommitFullClockIndex indexes the FullClock of a commit
var DiffClockIndex = &index{ Name: "DiffClockIndex", Table: diffTable, CreateFunction: func(row gorethink.Term) interface{} { clock := row.Field("Clock") return []interface{}{row.Field("Repo"), clock.Field("Branch"), clock.Field("Clock")} }, }
DiffClockIndex maps a clock to diffs Format: [repo, branch, clock] Example: ["test", "master", 1]
var DiffParentIndex = &index{ Name: "DiffParentIndex", Table: diffTable, CreateFunction: func(row gorethink.Term) interface{} { parent := row.Field("Path").Split("/").DeleteAt(-1).Fold("", func(acc, part gorethink.Term) gorethink.Term { return gorethink.Branch( acc.Eq("/"), acc.Add(part), acc.Add("/").Add(part), ) }) return []interface{}{row.Field("Repo"), parent, persist.ClockToArray(row.Field("Clock"))} }, }
DiffParentIndex maps a path to diffs that have the path as direct parent Format: [repo, parent, clocks] Example: For the diff: "/foo/bar/buzz", (master, 1) We'd have the following index entries: ["/foo/bar", (master, 1)]
var DiffPathIndex = &index{ Name: "diffPathIndex", Table: diffTable, CreateFunction: func(row gorethink.Term) interface{} { return []interface{}{row.Field("Repo"), row.Field("Path"), persist.ClockToArray(row.Field("Clock"))} }, }
DiffPathIndex maps a path to diffs that for that path Format: [repo, path, clocks] Example: For the diff: "/foo/bar/buzz", (master, 1) We'd have the following index entries: ["/foo/bar/buzz", (master, 1)]
var DiffPrefixIndex = &index{ Name: "DiffPrefixIndex", Table: diffTable, CreateFunction: func(row gorethink.Term) interface{} { return row.Field("Path").Split("/").DeleteAt(-1).Fold("", func(acc, part gorethink.Term) gorethink.Term { return gorethink.Branch( acc.Eq("/"), acc.Add(part), acc.Add("/").Add(part), ) }, gorethink.FoldOpts{ Emit: func(acc, row, newAcc gorethink.Term) []interface{} { return []interface{}{newAcc} }, }).Map(func(path gorethink.Term) interface{} { return []interface{}{row.Field("Repo"), path, persist.ClockToArray(row.Field("Clock"))} }) }, CreateOptions: gorethink.IndexCreateOpts{ Multi: true, }, }
DiffPrefixIndex maps a path to diffs that have the path as prefix // Format: [repo, prefix, clocks] Example: For the diff: "/foo/bar/buzz", (master, 1) We'd have the following index entries: ["/", (master, 1)] ["/foo", (master, 1)] ["/foo/bar", (master, 1)]
var Indexes = []*index{ DiffPathIndex, DiffPrefixIndex, DiffParentIndex, DiffClockIndex, ClockBranchIndex, CommitClockIndex, CommitFullClockIndex, }
Indexes is a collection of indexes for easier initialization
Functions ¶
Types ¶
type ErrBranchExists ¶
type ErrBranchExists struct {
// contains filtered or unexported fields
}
ErrBranchExists is specified if the branch already exists
type ErrCommitFinished ¶
type ErrCommitFinished struct {
// contains filtered or unexported fields
}
ErrCommitFinished is specified if the operation is disallowed on Finished Commits
type ErrCommitNotFound ¶
type ErrCommitNotFound struct {
// contains filtered or unexported fields
}
ErrCommitNotFound is specified when the commit is not found