Files
dolt/go/datas/commit.go
cmasone-attic 74a0c98d75 Go: Use unified ref-height-based Pull algorithm (#1722)
Change Dataset.Pull to use a single algorithm to pull data from a
source to a sink, regardless of which (if any) is local. The basic
algorithm is described in the first section of pulling.md. This
implementation is equivalent but phrased a bit differently. The
algorithm actually used is described in the second section of
pulling.md

The main changes:
- datas.Pull(), which implements the new pulling algorithm
- RefHeap, a priority queue that sorts types.Ref by ref-height and
  then by ref.TargetHash()
- Add has() to both Database implementations. Cache has() checks.
- Switch Dataset to use new datas.Pull(). Currently not concurrent.

Toward #1568


Mostly, prune reachableChunks
2016-06-08 08:57:48 -07:00

58 lines
1.3 KiB
Go

// Copyright 2016 The Noms Authors. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package datas
import "github.com/attic-labs/noms/go/types"
var commitType *types.Type
var refOfCommitType *types.Type
const (
ParentsField = "parents"
ValueField = "value"
)
func init() {
structName := "Commit"
// struct Commit {
// parents: Set<Ref<Commit>>
// value: Value
// }
fieldTypes := types.TypeMap{
ParentsField: nil,
ValueField: types.ValueType,
}
commitType = types.MakeStructType(structName, fieldTypes)
commitType.Desc.(types.StructDesc).SetField(ParentsField, types.MakeSetType(types.MakeRefType(commitType)))
refOfCommitType = types.MakeRefType(commitType)
}
func NewCommit() types.Struct {
initialFields := map[string]types.Value{
ValueField: types.NewString(""),
ParentsField: types.NewSet(),
}
return types.NewStructWithType(commitType, initialFields)
}
func typeForMapOfStringToRefOfCommit() *types.Type {
return types.MakeMapType(types.StringType, refOfCommitType)
}
func NewMapOfStringToRefOfCommit() types.Map {
return types.NewMap()
}
func typeForSetOfRefOfCommit() *types.Type {
return types.MakeSetType(refOfCommitType)
}
func CommitType() *types.Type {
return commitType
}