persist

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrConflictFileTypeMsg is used when we see a file that is both a file and directory
	ErrConflictFileTypeMsg = "file type conflict"
)

Variables

View Source
var CommitBranchIndex = &index{
	Name:  "CommitBranchIndex",
	Table: commitTable,
	CreateFunction: func(row gorethink.Term) interface{} {
		lastClock := row.Field("FullClock").Nth(-1)
		return []interface{}{
			row.Field("Repo"),
			lastClock.Field("Branch"),
		}
	},
}

CommitBranchIndex maps clocks to branches Format: repo + branch Example: A commit that has the clock [(master, 2), (foo, 3)] will be indexed to: ["repo", "foo"]

View Source
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]

View Source
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

View Source
var DiffClockIndex = &index{
	Name:  "DiffClockIndex",
	Table: diffTable,
	CreateFunction: func(row gorethink.Term) interface{} {
		clock := row.Field("Clock").Nth(-1)
		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]

View Source
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").Nth(-1))}
	},
}

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)]

View Source
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").Nth(-1))}
	},
}

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)]

View Source
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").Nth(-1))}
		})
	},
	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)]

Indexes is a collection of indexes for easier initialization

Functions

func DbConnect added in v1.2.3

func DbConnect(address string) (*gorethink.Session, error)

DbConnect returns a rethink DB session connected to the provided address

func InitDB

func InitDB(address string, dbName string) error

InitDB is used to setup the database with the tables and indices that PFS requires

func NewDriver

func NewDriver(blockAddress string, dbAddress string, dbName string) (drive.Driver, error)

NewDriver is used to create a new Driver instance

func RemoveDB

func RemoveDB(address string, dbName string) error

RemoveDB removes the tables in the database that are relavant to PFS It keeps the database around tho, as it might contain other tables that others created (e.g. PPS).

Types

type PrimaryKey

type PrimaryKey string

A PrimaryKey is a rethinkdb primary key identifier.

type Table

type Table string

A Table is a rethinkdb table name.

Directories

Path Synopsis
Package persist is a generated protocol buffer package.
Package persist is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL