mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 10:33:08 -06:00
Merge pull request #1268 from aboodman/rmrf
Remove all the examples that rely on Go codegen
This commit is contained in:
@@ -20,11 +20,6 @@ before_script:
|
||||
- ./build.py
|
||||
- npm test
|
||||
- popd
|
||||
- pushd clients/crunchbase/ui
|
||||
- npm prune
|
||||
- ./build.py
|
||||
- npm test
|
||||
- popd
|
||||
- pushd nomdl/codegen/test
|
||||
- npm prune
|
||||
- npm install
|
||||
@@ -44,7 +39,6 @@ notifications:
|
||||
cache:
|
||||
directories:
|
||||
- js/node_modules
|
||||
- clients/crunchbase/ui/node_modules
|
||||
- clients/splore/node_modules
|
||||
- nomdl/codegen/test/node_modules
|
||||
deploy:
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
struct Geoposition {
|
||||
Latitude: Float32
|
||||
Longitude: Float32
|
||||
}
|
||||
|
||||
struct Georectangle {
|
||||
TopLeft: Geoposition
|
||||
BottomRight: Geoposition
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
alias geo = import "geo.noms"
|
||||
|
||||
struct Incident {
|
||||
ID: Int64
|
||||
Category: String
|
||||
Description: String
|
||||
// TODO: Combine DayOfWeek/Date/Time into single date.Date field, see https://github.com/attic-labs/noms/issues/850.
|
||||
DayOfWeek: String
|
||||
Date: String
|
||||
Time: String
|
||||
PdDistrict: String
|
||||
Resolution: String
|
||||
Address: String
|
||||
Geoposition: geo.Geoposition
|
||||
PdID: String
|
||||
}
|
||||
|
||||
using List<Ref<Incident>>
|
||||
@@ -1,511 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Incident",
|
||||
[]types.Field{
|
||||
types.Field{"ID", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
types.Field{"Category", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Description", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"DayOfWeek", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Time", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"PdDistrict", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Resolution", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Address", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Geoposition", types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0), false},
|
||||
types.Field{"PdID", types.MakePrimitiveType(types.StringKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Incident
|
||||
|
||||
type Incident struct {
|
||||
_ID int64
|
||||
_Category string
|
||||
_Description string
|
||||
_DayOfWeek string
|
||||
_Date string
|
||||
_Time string
|
||||
_PdDistrict string
|
||||
_Resolution string
|
||||
_Address string
|
||||
_Geoposition Geoposition
|
||||
_PdID string
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewIncident() Incident {
|
||||
return Incident{
|
||||
_ID: int64(0),
|
||||
_Category: "",
|
||||
_Description: "",
|
||||
_DayOfWeek: "",
|
||||
_Date: "",
|
||||
_Time: "",
|
||||
_PdDistrict: "",
|
||||
_Resolution: "",
|
||||
_Address: "",
|
||||
_Geoposition: NewGeoposition(),
|
||||
_PdID: "",
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type IncidentDef struct {
|
||||
ID int64
|
||||
Category string
|
||||
Description string
|
||||
DayOfWeek string
|
||||
Date string
|
||||
Time string
|
||||
PdDistrict string
|
||||
Resolution string
|
||||
Address string
|
||||
Geoposition GeopositionDef
|
||||
PdID string
|
||||
}
|
||||
|
||||
func (def IncidentDef) New() Incident {
|
||||
return Incident{
|
||||
_ID: def.ID,
|
||||
_Category: def.Category,
|
||||
_Description: def.Description,
|
||||
_DayOfWeek: def.DayOfWeek,
|
||||
_Date: def.Date,
|
||||
_Time: def.Time,
|
||||
_PdDistrict: def.PdDistrict,
|
||||
_Resolution: def.Resolution,
|
||||
_Address: def.Address,
|
||||
_Geoposition: def.Geoposition.New(),
|
||||
_PdID: def.PdID,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Incident) Def() (d IncidentDef) {
|
||||
d.ID = s._ID
|
||||
d.Category = s._Category
|
||||
d.Description = s._Description
|
||||
d.DayOfWeek = s._DayOfWeek
|
||||
d.Date = s._Date
|
||||
d.Time = s._Time
|
||||
d.PdDistrict = s._PdDistrict
|
||||
d.Resolution = s._Resolution
|
||||
d.Address = s._Address
|
||||
d.Geoposition = s._Geoposition.Def()
|
||||
d.PdID = s._PdID
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForIncident types.Type
|
||||
|
||||
func (m Incident) Type() types.Type {
|
||||
return __typeForIncident
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForIncident = types.MakeType(ref.Parse("sha1-a4e6ece8b3bc70057c3019cbc9f1c2caf1dd25d7"), 0)
|
||||
types.RegisterStruct(__typeForIncident, builderForIncident, readerForIncident)
|
||||
}
|
||||
|
||||
func builderForIncident(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Incident{ref: &ref.Ref{}}
|
||||
s._ID = int64(values[i].(types.Int64))
|
||||
i++
|
||||
s._Category = values[i].(types.String).String()
|
||||
i++
|
||||
s._Description = values[i].(types.String).String()
|
||||
i++
|
||||
s._DayOfWeek = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(types.String).String()
|
||||
i++
|
||||
s._Time = values[i].(types.String).String()
|
||||
i++
|
||||
s._PdDistrict = values[i].(types.String).String()
|
||||
i++
|
||||
s._Resolution = values[i].(types.String).String()
|
||||
i++
|
||||
s._Address = values[i].(types.String).String()
|
||||
i++
|
||||
s._Geoposition = values[i].(Geoposition)
|
||||
i++
|
||||
s._PdID = values[i].(types.String).String()
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForIncident(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Incident)
|
||||
values = append(values, types.Int64(s._ID))
|
||||
values = append(values, types.NewString(s._Category))
|
||||
values = append(values, types.NewString(s._Description))
|
||||
values = append(values, types.NewString(s._DayOfWeek))
|
||||
values = append(values, types.NewString(s._Date))
|
||||
values = append(values, types.NewString(s._Time))
|
||||
values = append(values, types.NewString(s._PdDistrict))
|
||||
values = append(values, types.NewString(s._Resolution))
|
||||
values = append(values, types.NewString(s._Address))
|
||||
values = append(values, s._Geoposition)
|
||||
values = append(values, types.NewString(s._PdID))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Incident) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForIncident.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Incident) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Incident) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForIncident.Chunks()...)
|
||||
chunks = append(chunks, s._Geoposition.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Incident) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._ID))
|
||||
ret = append(ret, types.NewString(s._Category))
|
||||
ret = append(ret, types.NewString(s._Description))
|
||||
ret = append(ret, types.NewString(s._DayOfWeek))
|
||||
ret = append(ret, types.NewString(s._Date))
|
||||
ret = append(ret, types.NewString(s._Time))
|
||||
ret = append(ret, types.NewString(s._PdDistrict))
|
||||
ret = append(ret, types.NewString(s._Resolution))
|
||||
ret = append(ret, types.NewString(s._Address))
|
||||
ret = append(ret, s._Geoposition)
|
||||
ret = append(ret, types.NewString(s._PdID))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Incident) ID() int64 {
|
||||
return s._ID
|
||||
}
|
||||
|
||||
func (s Incident) SetID(val int64) Incident {
|
||||
s._ID = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Category() string {
|
||||
return s._Category
|
||||
}
|
||||
|
||||
func (s Incident) SetCategory(val string) Incident {
|
||||
s._Category = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Description() string {
|
||||
return s._Description
|
||||
}
|
||||
|
||||
func (s Incident) SetDescription(val string) Incident {
|
||||
s._Description = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) DayOfWeek() string {
|
||||
return s._DayOfWeek
|
||||
}
|
||||
|
||||
func (s Incident) SetDayOfWeek(val string) Incident {
|
||||
s._DayOfWeek = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Date() string {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s Incident) SetDate(val string) Incident {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Time() string {
|
||||
return s._Time
|
||||
}
|
||||
|
||||
func (s Incident) SetTime(val string) Incident {
|
||||
s._Time = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) PdDistrict() string {
|
||||
return s._PdDistrict
|
||||
}
|
||||
|
||||
func (s Incident) SetPdDistrict(val string) Incident {
|
||||
s._PdDistrict = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Resolution() string {
|
||||
return s._Resolution
|
||||
}
|
||||
|
||||
func (s Incident) SetResolution(val string) Incident {
|
||||
s._Resolution = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Address() string {
|
||||
return s._Address
|
||||
}
|
||||
|
||||
func (s Incident) SetAddress(val string) Incident {
|
||||
s._Address = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) Geoposition() Geoposition {
|
||||
return s._Geoposition
|
||||
}
|
||||
|
||||
func (s Incident) SetGeoposition(val Geoposition) Incident {
|
||||
s._Geoposition = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) PdID() string {
|
||||
return s._PdID
|
||||
}
|
||||
|
||||
func (s Incident) SetPdID(val string) Incident {
|
||||
s._PdID = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// ListOfRefOfIncident
|
||||
|
||||
type ListOfRefOfIncident struct {
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfRefOfIncident() ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{types.NewTypedList(__typeForListOfRefOfIncident), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfRefOfIncidentDef []ref.Ref
|
||||
|
||||
func (def ListOfRefOfIncidentDef) New() ListOfRefOfIncident {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = NewRefOfIncident(d)
|
||||
}
|
||||
return ListOfRefOfIncident{types.NewTypedList(__typeForListOfRefOfIncident, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Def() ListOfRefOfIncidentDef {
|
||||
d := make([]ref.Ref, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = l.l.Get(i).(RefOfIncident).TargetRef()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForListOfRefOfIncident.Equals(other.Type()) && l.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Ref() ref.Ref {
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, l.Type().Chunks()...)
|
||||
chunks = append(chunks, l.l.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, l.l.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes ListOfRefOfIncident.
|
||||
var __typeForListOfRefOfIncident types.Type
|
||||
|
||||
func (m ListOfRefOfIncident) Type() types.Type {
|
||||
return __typeForListOfRefOfIncident
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForListOfRefOfIncident = types.MakeCompoundType(types.ListKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-a4e6ece8b3bc70057c3019cbc9f1c2caf1dd25d7"), 0)))
|
||||
types.RegisterValue(__typeForListOfRefOfIncident, builderForListOfRefOfIncident, readerForListOfRefOfIncident)
|
||||
}
|
||||
|
||||
func builderForListOfRefOfIncident(v types.Value) types.Value {
|
||||
return ListOfRefOfIncident{v.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForListOfRefOfIncident(v types.Value) types.Value {
|
||||
return v.(ListOfRefOfIncident).l
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Len() uint64 {
|
||||
return l.l.Len()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Empty() bool {
|
||||
return l.Len() == uint64(0)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Get(i uint64) RefOfIncident {
|
||||
return l.l.Get(i).(RefOfIncident)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Slice(idx uint64, end uint64) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Set(i uint64, val RefOfIncident) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Append(v ...RefOfIncident) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Insert(idx uint64, v ...RefOfIncident) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) Remove(idx uint64, end uint64) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) RemoveAt(idx uint64) ListOfRefOfIncident {
|
||||
return ListOfRefOfIncident{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) fromElemSlice(p []RefOfIncident) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ListOfRefOfIncidentIterCallback func(v RefOfIncident, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfRefOfIncident) Iter(cb ListOfRefOfIncidentIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfIncident), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfIncidentIterAllCallback func(v RefOfIncident, i uint64)
|
||||
|
||||
func (l ListOfRefOfIncident) IterAll(cb ListOfRefOfIncidentIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfIncident), i)
|
||||
})
|
||||
}
|
||||
|
||||
func (l ListOfRefOfIncident) IterAllP(concurrency int, cb ListOfRefOfIncidentIterAllCallback) {
|
||||
l.l.IterAllP(concurrency, func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfIncident), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfIncidentFilterCallback func(v RefOfIncident, i uint64) (keep bool)
|
||||
|
||||
func (l ListOfRefOfIncident) Filter(cb ListOfRefOfIncidentFilterCallback) ListOfRefOfIncident {
|
||||
out := l.l.Filter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfIncident), i)
|
||||
})
|
||||
return ListOfRefOfIncident{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfIncident
|
||||
|
||||
type RefOfIncident struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfIncident(target ref.Ref) RefOfIncident {
|
||||
return RefOfIncident{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfIncident) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfIncident) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfIncident) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfIncident.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfIncident) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfIncident) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfIncident.
|
||||
var __typeForRefOfIncident types.Type
|
||||
|
||||
func (r RefOfIncident) Type() types.Type {
|
||||
return __typeForRefOfIncident
|
||||
}
|
||||
|
||||
func (r RefOfIncident) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfIncident = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-a4e6ece8b3bc70057c3019cbc9f1c2caf1dd25d7"), 0))
|
||||
types.RegisterRef(__typeForRefOfIncident, builderForRefOfIncident)
|
||||
}
|
||||
|
||||
func builderForRefOfIncident(r ref.Ref) types.RefBase {
|
||||
return NewRefOfIncident(r)
|
||||
}
|
||||
|
||||
func (r RefOfIncident) TargetValue(vr types.ValueReader) Incident {
|
||||
return vr.ReadValue(r.target).(Incident)
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
alias date = import "date.noms"
|
||||
alias geo = import "geo.noms"
|
||||
|
||||
struct RemotePhoto {
|
||||
Id: String
|
||||
Title: String
|
||||
Date: date.Date
|
||||
Geoposition: geo.Geoposition
|
||||
Sizes: Map<Size, String>
|
||||
Tags: Set<String>
|
||||
Faces: Set<Face>
|
||||
}
|
||||
|
||||
struct Face {
|
||||
// These coordinates are in the range [0-1]
|
||||
Top: Float32
|
||||
Left: Float32
|
||||
Width: Float32
|
||||
Height: Float32
|
||||
PersonName: String
|
||||
}
|
||||
|
||||
struct Size {
|
||||
Width: Uint32
|
||||
Height: Uint32
|
||||
}
|
||||
|
||||
using Map<Size, String>
|
||||
using Set<String>
|
||||
@@ -1,263 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
const (
|
||||
maxNodes = 16
|
||||
maxDepth = 10
|
||||
tl = "TopLeft"
|
||||
bl = "BottomLeft"
|
||||
tr = "TopRight"
|
||||
br = "BottomRight"
|
||||
)
|
||||
|
||||
var (
|
||||
quadrants = []string{tl, bl, tr, br}
|
||||
saveCount = 0
|
||||
)
|
||||
|
||||
// Query returns a slice of Nodes that are a maximum of "kilometers" away from "p"
|
||||
func (qt *QuadTree) Query(p GeopositionDef, kilometers float64) (GeorectangleDef, []Node) {
|
||||
r := BoundingRectangle(p, kilometers)
|
||||
nodes := qt.Search(r, p, float32(kilometers))
|
||||
return r, nodes
|
||||
}
|
||||
|
||||
// Search returns a slice of Nodes that are within "r" and a maximum of "kilometers" away from "p"
|
||||
func (qt *QuadTree) Search(r GeorectangleDef, p GeopositionDef, kilometers float32) []Node {
|
||||
nodes := []Node{}
|
||||
if qt.Tiles().Len() > 0 {
|
||||
for _, q := range quadrants {
|
||||
tile := qt.Tiles().Get(q)
|
||||
if IntersectsRect(tile.Georectangle().Def(), r) {
|
||||
tnodes := tile.Search(r, p, kilometers)
|
||||
nodes = append(nodes, tnodes...)
|
||||
}
|
||||
}
|
||||
} else if qt.Nodes().Len() > 0 {
|
||||
qt.Nodes().Iter(func(n Node, i uint64) bool {
|
||||
if DistanceTo(p, n.Geoposition().Def()) < kilometers {
|
||||
nodes = append(nodes, n)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
// Query returns a slice of NodeDefs that are a maximum of "kilometers" away from "p"
|
||||
func (qt *QuadTreeDef) Query(p GeopositionDef, kilometers float64) ListOfNodeDef {
|
||||
r := BoundingRectangle(p, kilometers)
|
||||
return qt.Search(r, p, float32(kilometers))
|
||||
}
|
||||
|
||||
// Search returns a slice of NodeDefs that are within "r" and a maximum of "kilometers" away from "p"
|
||||
func (qt QuadTreeDef) Search(r GeorectangleDef, p GeopositionDef, kilometers float32) ListOfNodeDef {
|
||||
nodes := ListOfNodeDef{}
|
||||
if qt.hasTiles() {
|
||||
for _, q := range quadrants {
|
||||
tile := qt.Tiles[q]
|
||||
if IntersectsRect(tile.Georectangle, r) {
|
||||
tnodes := tile.Search(r, p, kilometers)
|
||||
nodes = append(nodes, tnodes...)
|
||||
}
|
||||
}
|
||||
} else if len(qt.Nodes) > 0 {
|
||||
for _, n := range qt.Nodes {
|
||||
if DistanceTo(p, n.Geoposition) < kilometers {
|
||||
nodes = append(nodes, n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
func (qt *QuadTreeDef) hasTiles() bool {
|
||||
return len(qt.Tiles) > 0
|
||||
}
|
||||
|
||||
// MTraverseCb declares type of function used as callback in Traverse method.
|
||||
type MTraverseCb func(qt *QuadTreeDef) (stop bool)
|
||||
|
||||
// Traverse calls the func "cb" for each tile in the QuadTreeDef in "prefix" order.
|
||||
func (qt *QuadTreeDef) Traverse(cb MTraverseCb) {
|
||||
if !cb(qt) && len(qt.Tiles) > 0 {
|
||||
for _, q := range quadrants {
|
||||
tile := qt.Tiles[q]
|
||||
tile.Traverse(cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Analyze prints some useful stats for debugging QuadTreeDef trees.
|
||||
func (qt *QuadTreeDef) Analyze() {
|
||||
qtCount := 0
|
||||
qtEmpty := 0
|
||||
qtCountsByLevel := []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
nodeCountsByLevel := []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
qtEmptyByLevel := []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
mDepth := uint8(0)
|
||||
qt.Traverse(func(qt *QuadTreeDef) (stop bool) {
|
||||
qtCount++
|
||||
nodeCount := len(qt.Nodes)
|
||||
depth := uint8(qt.Depth)
|
||||
mDepth = max(mDepth, depth)
|
||||
qtCountsByLevel[depth]++
|
||||
nodeCountsByLevel[depth] += uint64(nodeCount)
|
||||
if !qt.hasTiles() && nodeCount == 0 {
|
||||
qtEmpty++
|
||||
qtEmptyByLevel[depth]++
|
||||
}
|
||||
return false
|
||||
})
|
||||
fmt.Printf("qtCount: %d, emptyQtCount: %d, qtCountByLevel: %d, nodeCountsByLevel: %v, emptyQtCountByLevel: %v, maxDepth: %d\n",
|
||||
qtCount, qtEmpty, qtCountsByLevel, nodeCountsByLevel, qtEmptyByLevel, mDepth)
|
||||
}
|
||||
|
||||
// Append appends a NodeDef to MQuadTree
|
||||
func (qt *QuadTreeDef) Append(n *NodeDef) {
|
||||
if qt.hasTiles() {
|
||||
quadrant, tile := qt.tileContaining(n.Geoposition)
|
||||
tile.Append(n)
|
||||
qt.Tiles[quadrant] = tile
|
||||
qt.NumDescendents++
|
||||
} else if len(qt.Nodes) < maxNodes || qt.Depth == maxDepth {
|
||||
qt.Nodes = append(qt.Nodes, *n)
|
||||
} else {
|
||||
qt.split()
|
||||
qt.NumDescendents = maxNodes
|
||||
qt.Append(n)
|
||||
}
|
||||
}
|
||||
|
||||
// split() creates a child quadTree for each quadrant in qt and re-distributes qt's nodes
|
||||
// among the four children
|
||||
func (qt *QuadTreeDef) split() {
|
||||
d.Exp.False(qt.hasTiles(), "attempt to Split QuadTree that already has tiles")
|
||||
|
||||
qt.makeChildren()
|
||||
for _, n := range qt.Nodes {
|
||||
quadrant, tile := qt.tileContaining(n.Geoposition)
|
||||
tile.Append(&n)
|
||||
qt.Tiles[quadrant] = tile
|
||||
}
|
||||
|
||||
qt.NumDescendents = uint32(len(qt.Nodes))
|
||||
qt.Nodes = ListOfNodeDef{}
|
||||
}
|
||||
|
||||
func (qt *QuadTreeDef) tileContaining(p GeopositionDef) (quadrant string, tile QuadTreeDef) {
|
||||
d.Chk.True(qt.hasTiles(), "tileContaining method called on QuadTree node with no tiles")
|
||||
|
||||
if ContainsPoint(qt.Tiles[tl].Georectangle, p) {
|
||||
quadrant, tile = tl, qt.Tiles[tl]
|
||||
} else if ContainsPoint(qt.Tiles[bl].Georectangle, p) {
|
||||
quadrant, tile = bl, qt.Tiles[bl]
|
||||
} else if ContainsPoint(qt.Tiles[tr].Georectangle, p) {
|
||||
quadrant, tile = tr, qt.Tiles[tr]
|
||||
} else if ContainsPoint(qt.Tiles[br].Georectangle, p) {
|
||||
quadrant, tile = br, qt.Tiles[br]
|
||||
}
|
||||
|
||||
return quadrant, tile
|
||||
}
|
||||
|
||||
// CreateNewQuadTreeDef is a convenience method for creating a new QuadTreeDef.
|
||||
func CreateNewQuadTreeDef(depth uint8, path string, rect GeorectangleDef) QuadTreeDef {
|
||||
nodes := make(ListOfNodeDef, 0, maxNodes)
|
||||
qt := QuadTreeDef{
|
||||
Nodes: nodes,
|
||||
Tiles: MapOfStringToQuadTreeDef{},
|
||||
Depth: depth,
|
||||
NumDescendents: 0,
|
||||
Path: path,
|
||||
Georectangle: rect,
|
||||
}
|
||||
return qt
|
||||
}
|
||||
|
||||
// makeChildren() handles the dirty work of splitting up the Georectangle in qt
|
||||
// into 4 quadrants
|
||||
func (qt *QuadTreeDef) makeChildren() {
|
||||
tlRect, blRect, trRect, brRect := Split(qt.Georectangle)
|
||||
qt.Tiles[tl] = CreateNewQuadTreeDef(qt.Depth+1, qt.Path+"a", tlRect)
|
||||
qt.Tiles[bl] = CreateNewQuadTreeDef(qt.Depth+1, qt.Path+"b", blRect)
|
||||
qt.Tiles[tr] = CreateNewQuadTreeDef(qt.Depth+1, qt.Path+"c", trRect)
|
||||
qt.Tiles[br] = CreateNewQuadTreeDef(qt.Depth+1, qt.Path+"d", brRect)
|
||||
}
|
||||
|
||||
func (qt *QuadTreeDef) SaveToNoms(vw types.ValueWriter, start time.Time, quiet bool) *SQuadTree {
|
||||
wChan := make(chan *SQuadTree, 1024)
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 32; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
for sqt := range wChan {
|
||||
vw.WriteValue(*sqt)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
if util.MaybeStartCPUProfile() {
|
||||
defer util.StopCPUProfile()
|
||||
}
|
||||
|
||||
sqt := qt.saveNodeToNoms(wChan, vw, start, quiet)
|
||||
close(wChan)
|
||||
wg.Wait()
|
||||
return sqt
|
||||
}
|
||||
|
||||
func (qt *QuadTreeDef) saveNodeToNoms(wChan chan *SQuadTree, vw types.ValueWriter, start time.Time, quiet bool) *SQuadTree {
|
||||
tileRefs := MapOfStringToRefOfSQuadTreeDef{}
|
||||
nrefs := make(ListOfRefOfValueDef, 0, len(qt.Nodes))
|
||||
if qt.hasTiles() {
|
||||
for q, tile := range qt.Tiles {
|
||||
child := tile.saveNodeToNoms(wChan, vw, start, quiet)
|
||||
ref := child.Ref()
|
||||
tileRefs[q] = ref
|
||||
}
|
||||
} else if len(qt.Nodes) > 0 {
|
||||
for _, n := range qt.Nodes {
|
||||
nrefs = append(nrefs, n.Reference)
|
||||
}
|
||||
}
|
||||
sqt := SQuadTreeDef{
|
||||
Nodes: nrefs,
|
||||
Tiles: tileRefs,
|
||||
Depth: qt.Depth,
|
||||
NumDescendents: qt.NumDescendents,
|
||||
Path: qt.Path,
|
||||
Georectangle: qt.Georectangle,
|
||||
}.New()
|
||||
sqtp := &sqt
|
||||
|
||||
wChan <- sqtp
|
||||
saveCount++
|
||||
if saveCount%1e4 == 0 && !quiet {
|
||||
fmt.Printf("Nodes Saved: %d, elapsed time: %.2f secs\n", saveCount, SecsSince(start))
|
||||
}
|
||||
return sqtp
|
||||
}
|
||||
|
||||
func max(x, y uint8) uint8 {
|
||||
if x >= y {
|
||||
return x
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func SecsSince(start time.Time) float64 {
|
||||
return time.Now().Sub(start).Seconds()
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
alias Geo = import "geo.noms"
|
||||
|
||||
struct Node {
|
||||
Geoposition: Geo.Geoposition
|
||||
Reference: Ref<Value>
|
||||
}
|
||||
|
||||
struct QuadTree {
|
||||
Nodes: List<Node>
|
||||
Tiles: Map<String, QuadTree>
|
||||
Depth: Uint8
|
||||
NumDescendents: Uint32
|
||||
Path: String
|
||||
Georectangle: Geo.Georectangle
|
||||
}
|
||||
|
||||
struct SQuadTree {
|
||||
Nodes: List<Ref<Value>>
|
||||
Tiles: Map<String, Ref<SQuadTree>>
|
||||
Depth: Uint8
|
||||
NumDescendents: Uint32
|
||||
Path: String
|
||||
Georectangle: Geo.Georectangle
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
||||
package common
|
||||
|
||||
import "github.com/attic-labs/noms/types"
|
||||
|
||||
func (qt *SQuadTree) Query(p GeopositionDef, kilometers float64, vr types.ValueReader) (GeorectangleDef, []Incident) {
|
||||
r := BoundingRectangle(p, kilometers)
|
||||
nodes := qt.Search(r, p, float32(kilometers), vr)
|
||||
return r, nodes
|
||||
}
|
||||
|
||||
func (qt *SQuadTree) Search(r GeorectangleDef, p GeopositionDef, kilometers float32, vr types.ValueReader) []Incident {
|
||||
nodes := []Incident{}
|
||||
if qt.Tiles().Len() > 0 {
|
||||
for _, q := range quadrants {
|
||||
tile := qt.Tiles().Get(q).TargetValue(vr)
|
||||
if IntersectsRect(tile.Georectangle().Def(), r) {
|
||||
tnodes := tile.Search(r, p, kilometers, vr)
|
||||
nodes = append(nodes, tnodes...)
|
||||
}
|
||||
}
|
||||
} else if qt.Nodes().Len() > 0 {
|
||||
qt.Nodes().Iter(func(r RefOfValue, i uint64) bool {
|
||||
incident := r.TargetValue(vr).(Incident)
|
||||
if DistanceTo(p, incident.Geoposition().Def()) < kilometers {
|
||||
nodes = append(nodes, incident)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
alias date = import "../common/date.noms"
|
||||
|
||||
struct Company {
|
||||
Permalink: String
|
||||
Name: String
|
||||
HomepageUrl: String
|
||||
CategoryList: Set<String>
|
||||
Market: String
|
||||
FundingTotalUsd: Float64
|
||||
Status: String
|
||||
CountryCode: String
|
||||
StateCode: String
|
||||
Region: String
|
||||
City: String
|
||||
FundingRounds: Uint16
|
||||
FoundedAt: date.Date
|
||||
FirstFundingAt: date.Date
|
||||
LastFundingAt: date.Date
|
||||
Rounds: Set<Ref<Round>>
|
||||
}
|
||||
|
||||
struct Round {
|
||||
CompanyPermalink: String
|
||||
FundingRoundPermalink: String
|
||||
FundingRoundType: String
|
||||
FundingRoundCode: String
|
||||
FundedAt: date.Date
|
||||
RaisedAmountUsd: Float64
|
||||
}
|
||||
1
clients/crunchbase/importer/.gitignore
vendored
1
clients/crunchbase/importer/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
importer
|
||||
@@ -1,261 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"flag"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/tealeg/xlsx"
|
||||
)
|
||||
|
||||
var (
|
||||
date1904 = false
|
||||
dsFlags = dataset.NewFlags()
|
||||
)
|
||||
|
||||
func main() {
|
||||
var ds *dataset.Dataset
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Println("Usage: crunchbase [options] url\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
httpClient := util.CachingHttpClient()
|
||||
ds = dsFlags.CreateDataset()
|
||||
url := flag.Arg(0)
|
||||
if httpClient == nil || ds == nil || url == "" {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
fmt.Print("Fetching excel file - this can take a minute or so...")
|
||||
resp, err := httpClient.Get(url)
|
||||
d.Exp.NoError(err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
tempFile, err := ioutil.TempFile(os.TempDir(), "")
|
||||
defer tempFile.Close()
|
||||
d.Chk.NoError(err)
|
||||
|
||||
h := sha1.New()
|
||||
_, err = io.Copy(io.MultiWriter(h, tempFile), resp.Body)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
companiesRef := getExistingCompaniesRef(*ds, h)
|
||||
if !companiesRef.IsEmpty() {
|
||||
fmt.Println("\rExcel file hasn't changed since last run, nothing to do.")
|
||||
} else {
|
||||
companiesRef = importCompanies(*ds, tempFile.Name())
|
||||
}
|
||||
|
||||
imp := ImportDef{
|
||||
ref.FromHash(h).String(),
|
||||
DateDef{msSinceEpoch(time.Now())},
|
||||
companiesRef,
|
||||
}.New()
|
||||
|
||||
// Commit ref of the companiesRef list
|
||||
_, err = ds.Commit(imp)
|
||||
d.Exp.NoError(err)
|
||||
}
|
||||
|
||||
func importCompanies(ds dataset.Dataset, fileName string) ref.Ref {
|
||||
fmt.Print("\rOpening excel file - this can take a minute or so...")
|
||||
|
||||
xlFile, err := xlsx.OpenFile(fileName)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
fmt.Print("\rImporting...")
|
||||
|
||||
date1904 = xlFile.Date1904
|
||||
|
||||
// Read in Rounds and group according to CompanyPermalink
|
||||
roundsByPermalink := map[string][]Round{}
|
||||
roundsSheet := xlFile.Sheet["Rounds"]
|
||||
roundsColIndexes := readIndexesFromHeaderRow(roundsSheet)
|
||||
numRounds := 0
|
||||
for i, row := range roundsSheet.Rows {
|
||||
if i != 0 {
|
||||
round := newRoundFromRow(roundsColIndexes, row, i)
|
||||
pl := round.CompanyPermalink()
|
||||
roundsByPermalink[pl] = append(roundsByPermalink[pl], round)
|
||||
numRounds++
|
||||
}
|
||||
}
|
||||
|
||||
// Read in Companies and map to permalink
|
||||
companyRefsDef := MapOfStringToRefOfCompanyDef{}
|
||||
companySheet := xlFile.Sheet["Companies"]
|
||||
companyColIndexes := readIndexesFromHeaderRow(companySheet)
|
||||
for i, row := range companySheet.Rows {
|
||||
fmt.Printf("\rImporting %d of %d companies... (%.2f%%)", i, len(companySheet.Rows), float64(i)/float64(len(companySheet.Rows))*float64(100))
|
||||
if i != 0 {
|
||||
company := newCompanyFromRow(companyColIndexes, row, i)
|
||||
permalink := company.Permalink()
|
||||
|
||||
rounds := roundsByPermalink[permalink]
|
||||
roundRefs := SetOfRefOfRoundDef{}
|
||||
for _, r := range rounds {
|
||||
ref := ds.Store().WriteValue(r).TargetRef()
|
||||
roundRefs[ref] = true
|
||||
}
|
||||
company = company.SetRounds(roundRefs.New())
|
||||
ref := ds.Store().WriteValue(company).TargetRef()
|
||||
companyRefsDef[company.Permalink()] = ref
|
||||
}
|
||||
}
|
||||
|
||||
companyRefs := companyRefsDef.New()
|
||||
|
||||
// Uncomment this line of code once Len() is implemented on compoundLists
|
||||
// fmt.Printf("\rImported %d companies with %d rounds\n", companyRefs.Len(), numRounds)
|
||||
|
||||
// Write the list of companyRefs
|
||||
return ds.Store().WriteValue(companyRefs).TargetRef()
|
||||
}
|
||||
|
||||
func getExistingCompaniesRef(ds dataset.Dataset, h hash.Hash) ref.Ref {
|
||||
if head, ok := ds.MaybeHead(); ok {
|
||||
if imp, ok := head.Value().(Import); ok {
|
||||
if imp.FileSHA1() == ref.FromHash(h).String() {
|
||||
return imp.Companies().TargetRef()
|
||||
}
|
||||
}
|
||||
}
|
||||
return ref.Ref{}
|
||||
}
|
||||
|
||||
func newCompanyFromRow(idxs columnIndexes, row *xlsx.Row, rowNum int) Company {
|
||||
cells := row.Cells
|
||||
|
||||
company := CompanyDef{
|
||||
Permalink: idxs.getString("permalink", cells),
|
||||
Name: idxs.getString("name", cells),
|
||||
HomepageUrl: idxs.getString("homepage_url", cells),
|
||||
CategoryList: idxs.getListOfCategory("category_list", cells),
|
||||
Market: idxs.getString("market", cells),
|
||||
FundingTotalUsd: idxs.getFloat("fundingTotalUsd", cells, "Company.FundingTotalUsd", rowNum),
|
||||
Status: idxs.getString("status", cells),
|
||||
CountryCode: idxs.getString("country_code", cells),
|
||||
StateCode: idxs.getString("state_code", cells),
|
||||
Region: idxs.getString("region", cells),
|
||||
City: idxs.getString("city", cells),
|
||||
FundingRounds: uint16(idxs.getInt("funding_rounds", cells, "Company.FundingRounds", rowNum)),
|
||||
FoundedAt: idxs.getDate("founded_at", cells, "Company.FoundedAt", rowNum),
|
||||
FirstFundingAt: idxs.getDate("first_funding_at", cells, "Company.FirstFundingAt", rowNum),
|
||||
LastFundingAt: idxs.getDate("last_funding_at", cells, "Company.LastFundingAt", rowNum),
|
||||
}
|
||||
return company.New()
|
||||
}
|
||||
|
||||
func newRoundFromRow(idxs columnIndexes, row *xlsx.Row, rowNum int) Round {
|
||||
cells := row.Cells
|
||||
|
||||
round := RoundDef{
|
||||
CompanyPermalink: idxs.getString("company_permalink", cells),
|
||||
FundingRoundPermalink: idxs.getString("funding_round_permalink", cells),
|
||||
FundingRoundType: idxs.getString("funding_round_type", cells),
|
||||
FundingRoundCode: idxs.getString("funding_round_code", cells),
|
||||
FundedAt: idxs.getDate("funded_at", cells, "Round.fundedAt", rowNum),
|
||||
RaisedAmountUsd: idxs.getFloat("raised_amount_usd", cells, "Round.raisedAmountUsd", rowNum),
|
||||
}
|
||||
return round.New()
|
||||
}
|
||||
|
||||
type columnIndexes map[string]int
|
||||
|
||||
func readIndexesFromHeaderRow(sheet *xlsx.Sheet) columnIndexes {
|
||||
m := columnIndexes{}
|
||||
for i, cell := range sheet.Rows[0].Cells {
|
||||
m[cell.Value] = i
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (cn columnIndexes) getString(key string, cells []*xlsx.Cell) string {
|
||||
if cellIndex, ok := cn[key]; ok && cellIndex < len(cells) {
|
||||
return cells[cellIndex].Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (cn columnIndexes) getListOfCategory(key string, cells []*xlsx.Cell) SetOfStringDef {
|
||||
realElems := SetOfStringDef{}
|
||||
s := cn.getString(key, cells)
|
||||
elems := strings.Split(s, "|")
|
||||
for _, elem := range elems {
|
||||
s1 := strings.TrimSpace(elem)
|
||||
if s1 != "" {
|
||||
realElems[s1] = true
|
||||
}
|
||||
}
|
||||
return realElems
|
||||
}
|
||||
|
||||
func (cn columnIndexes) getFloat(key string, cells []*xlsx.Cell, field string, rowNum int) float64 {
|
||||
parsedValue := float64(0)
|
||||
s := cn.getString(key, cells)
|
||||
if s != "" && s != "-" {
|
||||
var err error
|
||||
parsedValue, err = strconv.ParseFloat(s, 64)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to parse Float, row: %d, field: %s, err: %s\n", rowNum, field, err)
|
||||
parsedValue = float64(0)
|
||||
}
|
||||
}
|
||||
return float64(parsedValue)
|
||||
}
|
||||
|
||||
func (cn columnIndexes) getInt(key string, cells []*xlsx.Cell, field string, rowNum int) int {
|
||||
parsedValue := int64(0)
|
||||
s := cn.getString(key, cells)
|
||||
if s != "" && s != "-" {
|
||||
var err error
|
||||
parsedValue, err = strconv.ParseInt(s, 10, 32)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to parse Int, row: %d, field: %s, err: %s\n", rowNum, field, err)
|
||||
parsedValue = 0
|
||||
}
|
||||
}
|
||||
return int(parsedValue)
|
||||
}
|
||||
|
||||
func (cn columnIndexes) getDate(key string, cells []*xlsx.Cell, field string, rowNum int) DateDef {
|
||||
s := cn.getString(key, cells)
|
||||
if s != "" && s != "-" {
|
||||
if f, err := strconv.ParseFloat(s, 64); err == nil {
|
||||
return DateDef{msSinceEpoch(xlsx.TimeFromExcelTime(f, date1904))}
|
||||
}
|
||||
const shortForm = "2006-01-02"
|
||||
var err error
|
||||
var t time.Time
|
||||
if t, err = time.Parse(shortForm, s); err == nil {
|
||||
return DateDef{msSinceEpoch(t)}
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Unable to parse Date, row: %d, field: %s, value: %s, err: %s\n", rowNum, field, s, err)
|
||||
}
|
||||
return DateDef{0}
|
||||
}
|
||||
|
||||
func msSinceEpoch(t time.Time) int64 {
|
||||
return t.Unix() * 1e3
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
alias cb = import "../crunchbase.noms"
|
||||
alias date = import "../../common/date.noms"
|
||||
|
||||
struct Import {
|
||||
FileSHA1: String
|
||||
Date: date.Date
|
||||
Companies: Ref<Map<String, Ref<cb.Company>>>
|
||||
}
|
||||
@@ -1,401 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Import",
|
||||
[]types.Field{
|
||||
types.Field{"FileSHA1", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Companies", types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Import
|
||||
|
||||
type Import struct {
|
||||
_FileSHA1 string
|
||||
_Date Date
|
||||
_Companies RefOfMapOfStringToRefOfCompany
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewImport() Import {
|
||||
return Import{
|
||||
_FileSHA1: "",
|
||||
_Date: NewDate(),
|
||||
_Companies: NewRefOfMapOfStringToRefOfCompany(ref.Ref{}),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type ImportDef struct {
|
||||
FileSHA1 string
|
||||
Date DateDef
|
||||
Companies ref.Ref
|
||||
}
|
||||
|
||||
func (def ImportDef) New() Import {
|
||||
return Import{
|
||||
_FileSHA1: def.FileSHA1,
|
||||
_Date: def.Date.New(),
|
||||
_Companies: NewRefOfMapOfStringToRefOfCompany(def.Companies),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Import) Def() (d ImportDef) {
|
||||
d.FileSHA1 = s._FileSHA1
|
||||
d.Date = s._Date.Def()
|
||||
d.Companies = s._Companies.TargetRef()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForImport types.Type
|
||||
|
||||
func (m Import) Type() types.Type {
|
||||
return __typeForImport
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForImport = types.MakeType(ref.Parse("sha1-6c64b08a509e25f9814dbf036489267c957a6fd8"), 0)
|
||||
types.RegisterStruct(__typeForImport, builderForImport, readerForImport)
|
||||
}
|
||||
|
||||
func builderForImport(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Import{ref: &ref.Ref{}}
|
||||
s._FileSHA1 = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(Date)
|
||||
i++
|
||||
s._Companies = values[i].(RefOfMapOfStringToRefOfCompany)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForImport(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Import)
|
||||
values = append(values, types.NewString(s._FileSHA1))
|
||||
values = append(values, s._Date)
|
||||
values = append(values, s._Companies)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Import) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForImport.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Import) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Import) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForImport.Chunks()...)
|
||||
chunks = append(chunks, s._Date.Chunks()...)
|
||||
chunks = append(chunks, s._Companies.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Import) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._FileSHA1))
|
||||
ret = append(ret, s._Date)
|
||||
ret = append(ret, s._Companies)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Import) FileSHA1() string {
|
||||
return s._FileSHA1
|
||||
}
|
||||
|
||||
func (s Import) SetFileSHA1(val string) Import {
|
||||
s._FileSHA1 = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Import) Date() Date {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s Import) SetDate(val Date) Import {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Import) Companies() RefOfMapOfStringToRefOfCompany {
|
||||
return s._Companies
|
||||
}
|
||||
|
||||
func (s Import) SetCompanies(val RefOfMapOfStringToRefOfCompany) Import {
|
||||
s._Companies = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// RefOfMapOfStringToRefOfCompany
|
||||
|
||||
type RefOfMapOfStringToRefOfCompany struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfMapOfStringToRefOfCompany(target ref.Ref) RefOfMapOfStringToRefOfCompany {
|
||||
return RefOfMapOfStringToRefOfCompany{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfMapOfStringToRefOfCompany.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfMapOfStringToRefOfCompany.
|
||||
var __typeForRefOfMapOfStringToRefOfCompany types.Type
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Type() types.Type {
|
||||
return __typeForRefOfMapOfStringToRefOfCompany
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfMapOfStringToRefOfCompany = types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0))))
|
||||
types.RegisterRef(__typeForRefOfMapOfStringToRefOfCompany, builderForRefOfMapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForRefOfMapOfStringToRefOfCompany(r ref.Ref) types.RefBase {
|
||||
return NewRefOfMapOfStringToRefOfCompany(r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) TargetValue(vr types.ValueReader) MapOfStringToRefOfCompany {
|
||||
return vr.ReadValue(r.target).(MapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
// MapOfStringToRefOfCompany
|
||||
|
||||
type MapOfStringToRefOfCompany struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToRefOfCompany() MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{types.NewTypedMap(__typeForMapOfStringToRefOfCompany), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyDef map[string]ref.Ref
|
||||
|
||||
func (def MapOfStringToRefOfCompanyDef) New() MapOfStringToRefOfCompany {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), NewRefOfCompany(v))
|
||||
}
|
||||
return MapOfStringToRefOfCompany{types.NewTypedMap(__typeForMapOfStringToRefOfCompany, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Def() MapOfStringToRefOfCompanyDef {
|
||||
def := make(map[string]ref.Ref)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = v.(RefOfCompany).TargetRef()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfStringToRefOfCompany.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfStringToRefOfCompany.
|
||||
var __typeForMapOfStringToRefOfCompany types.Type
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Type() types.Type {
|
||||
return __typeForMapOfStringToRefOfCompany
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfStringToRefOfCompany = types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)))
|
||||
types.RegisterValue(__typeForMapOfStringToRefOfCompany, builderForMapOfStringToRefOfCompany, readerForMapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForMapOfStringToRefOfCompany(v types.Value) types.Value {
|
||||
return MapOfStringToRefOfCompany{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfStringToRefOfCompany(v types.Value) types.Value {
|
||||
return v.(MapOfStringToRefOfCompany).m
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Has(p string) bool {
|
||||
return m.m.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Get(p string) RefOfCompany {
|
||||
return m.m.Get(types.NewString(p)).(RefOfCompany)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) MaybeGet(p string) (RefOfCompany, bool) {
|
||||
v, ok := m.m.MaybeGet(types.NewString(p))
|
||||
if !ok {
|
||||
return NewRefOfCompany(ref.Ref{}), false
|
||||
}
|
||||
return v.(RefOfCompany), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Set(k string, v RefOfCompany) MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Remove(p string) MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyIterCallback func(k string, v RefOfCompany) (stop bool)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Iter(cb MapOfStringToRefOfCompanyIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyIterAllCallback func(k string, v RefOfCompany)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) IterAll(cb MapOfStringToRefOfCompanyIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) IterAllP(concurrency int, cb MapOfStringToRefOfCompanyIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyFilterCallback func(k string, v RefOfCompany) (keep bool)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Filter(cb MapOfStringToRefOfCompanyFilterCallback) MapOfStringToRefOfCompany {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
return MapOfStringToRefOfCompany{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfCompany
|
||||
|
||||
type RefOfCompany struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfCompany(target ref.Ref) RefOfCompany {
|
||||
return RefOfCompany{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfCompany) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfCompany.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfCompany) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfCompany.
|
||||
var __typeForRefOfCompany types.Type
|
||||
|
||||
func (r RefOfCompany) Type() types.Type {
|
||||
return __typeForRefOfCompany
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfCompany = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0))
|
||||
types.RegisterRef(__typeForRefOfCompany, builderForRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForRefOfCompany(r ref.Ref) types.RefBase {
|
||||
return NewRefOfCompany(r)
|
||||
}
|
||||
|
||||
func (r RefOfCompany) TargetValue(vr types.ValueReader) Company {
|
||||
return vr.ReadValue(r.target).(Company)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../../nomdl/codegen/codegen.go -package=main -out-dir=.
|
||||
@@ -1,109 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Date",
|
||||
[]types.Field{
|
||||
types.Field{"MsSinceEpoch", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Date
|
||||
|
||||
type Date struct {
|
||||
_MsSinceEpoch int64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDate() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: int64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type DateDef struct {
|
||||
MsSinceEpoch int64
|
||||
}
|
||||
|
||||
func (def DateDef) New() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: def.MsSinceEpoch,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Date) Def() (d DateDef) {
|
||||
d.MsSinceEpoch = s._MsSinceEpoch
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForDate types.Type
|
||||
|
||||
func (m Date) Type() types.Type {
|
||||
return __typeForDate
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForDate = types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0)
|
||||
types.RegisterStruct(__typeForDate, builderForDate, readerForDate)
|
||||
}
|
||||
|
||||
func builderForDate(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Date{ref: &ref.Ref{}}
|
||||
s._MsSinceEpoch = int64(values[i].(types.Int64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForDate(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Date)
|
||||
values = append(values, types.Int64(s._MsSinceEpoch))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Date) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForDate.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Date) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Date) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForDate.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._MsSinceEpoch))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) MsSinceEpoch() int64 {
|
||||
return s._MsSinceEpoch
|
||||
}
|
||||
|
||||
func (s Date) SetMsSinceEpoch(val int64) Date {
|
||||
s._MsSinceEpoch = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,956 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Company",
|
||||
[]types.Field{
|
||||
types.Field{"Permalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Name", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"HomepageUrl", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"CategoryList", types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Market", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingTotalUsd", types.MakePrimitiveType(types.Float64Kind), false},
|
||||
types.Field{"Status", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"CountryCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"StateCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Region", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"City", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRounds", types.MakePrimitiveType(types.Uint16Kind), false},
|
||||
types.Field{"FoundedAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"FirstFundingAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"LastFundingAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Rounds", types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Ref{}, 1))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Round",
|
||||
[]types.Field{
|
||||
types.Field{"CompanyPermalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundPermalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundType", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundedAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"RaisedAmountUsd", types.MakePrimitiveType(types.Float64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Company
|
||||
|
||||
type Company struct {
|
||||
_Permalink string
|
||||
_Name string
|
||||
_HomepageUrl string
|
||||
_CategoryList SetOfString
|
||||
_Market string
|
||||
_FundingTotalUsd float64
|
||||
_Status string
|
||||
_CountryCode string
|
||||
_StateCode string
|
||||
_Region string
|
||||
_City string
|
||||
_FundingRounds uint16
|
||||
_FoundedAt Date
|
||||
_FirstFundingAt Date
|
||||
_LastFundingAt Date
|
||||
_Rounds SetOfRefOfRound
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewCompany() Company {
|
||||
return Company{
|
||||
_Permalink: "",
|
||||
_Name: "",
|
||||
_HomepageUrl: "",
|
||||
_CategoryList: NewSetOfString(),
|
||||
_Market: "",
|
||||
_FundingTotalUsd: float64(0),
|
||||
_Status: "",
|
||||
_CountryCode: "",
|
||||
_StateCode: "",
|
||||
_Region: "",
|
||||
_City: "",
|
||||
_FundingRounds: uint16(0),
|
||||
_FoundedAt: NewDate(),
|
||||
_FirstFundingAt: NewDate(),
|
||||
_LastFundingAt: NewDate(),
|
||||
_Rounds: NewSetOfRefOfRound(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type CompanyDef struct {
|
||||
Permalink string
|
||||
Name string
|
||||
HomepageUrl string
|
||||
CategoryList SetOfStringDef
|
||||
Market string
|
||||
FundingTotalUsd float64
|
||||
Status string
|
||||
CountryCode string
|
||||
StateCode string
|
||||
Region string
|
||||
City string
|
||||
FundingRounds uint16
|
||||
FoundedAt DateDef
|
||||
FirstFundingAt DateDef
|
||||
LastFundingAt DateDef
|
||||
Rounds SetOfRefOfRoundDef
|
||||
}
|
||||
|
||||
func (def CompanyDef) New() Company {
|
||||
return Company{
|
||||
_Permalink: def.Permalink,
|
||||
_Name: def.Name,
|
||||
_HomepageUrl: def.HomepageUrl,
|
||||
_CategoryList: def.CategoryList.New(),
|
||||
_Market: def.Market,
|
||||
_FundingTotalUsd: def.FundingTotalUsd,
|
||||
_Status: def.Status,
|
||||
_CountryCode: def.CountryCode,
|
||||
_StateCode: def.StateCode,
|
||||
_Region: def.Region,
|
||||
_City: def.City,
|
||||
_FundingRounds: def.FundingRounds,
|
||||
_FoundedAt: def.FoundedAt.New(),
|
||||
_FirstFundingAt: def.FirstFundingAt.New(),
|
||||
_LastFundingAt: def.LastFundingAt.New(),
|
||||
_Rounds: def.Rounds.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Company) Def() (d CompanyDef) {
|
||||
d.Permalink = s._Permalink
|
||||
d.Name = s._Name
|
||||
d.HomepageUrl = s._HomepageUrl
|
||||
d.CategoryList = s._CategoryList.Def()
|
||||
d.Market = s._Market
|
||||
d.FundingTotalUsd = s._FundingTotalUsd
|
||||
d.Status = s._Status
|
||||
d.CountryCode = s._CountryCode
|
||||
d.StateCode = s._StateCode
|
||||
d.Region = s._Region
|
||||
d.City = s._City
|
||||
d.FundingRounds = s._FundingRounds
|
||||
d.FoundedAt = s._FoundedAt.Def()
|
||||
d.FirstFundingAt = s._FirstFundingAt.Def()
|
||||
d.LastFundingAt = s._LastFundingAt.Def()
|
||||
d.Rounds = s._Rounds.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForCompany types.Type
|
||||
|
||||
func (m Company) Type() types.Type {
|
||||
return __typeForCompany
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForCompany = types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)
|
||||
types.RegisterStruct(__typeForCompany, builderForCompany, readerForCompany)
|
||||
}
|
||||
|
||||
func builderForCompany(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Company{ref: &ref.Ref{}}
|
||||
s._Permalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._Name = values[i].(types.String).String()
|
||||
i++
|
||||
s._HomepageUrl = values[i].(types.String).String()
|
||||
i++
|
||||
s._CategoryList = values[i].(SetOfString)
|
||||
i++
|
||||
s._Market = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingTotalUsd = float64(values[i].(types.Float64))
|
||||
i++
|
||||
s._Status = values[i].(types.String).String()
|
||||
i++
|
||||
s._CountryCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._StateCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._Region = values[i].(types.String).String()
|
||||
i++
|
||||
s._City = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRounds = uint16(values[i].(types.Uint16))
|
||||
i++
|
||||
s._FoundedAt = values[i].(Date)
|
||||
i++
|
||||
s._FirstFundingAt = values[i].(Date)
|
||||
i++
|
||||
s._LastFundingAt = values[i].(Date)
|
||||
i++
|
||||
s._Rounds = values[i].(SetOfRefOfRound)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForCompany(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Company)
|
||||
values = append(values, types.NewString(s._Permalink))
|
||||
values = append(values, types.NewString(s._Name))
|
||||
values = append(values, types.NewString(s._HomepageUrl))
|
||||
values = append(values, s._CategoryList)
|
||||
values = append(values, types.NewString(s._Market))
|
||||
values = append(values, types.Float64(s._FundingTotalUsd))
|
||||
values = append(values, types.NewString(s._Status))
|
||||
values = append(values, types.NewString(s._CountryCode))
|
||||
values = append(values, types.NewString(s._StateCode))
|
||||
values = append(values, types.NewString(s._Region))
|
||||
values = append(values, types.NewString(s._City))
|
||||
values = append(values, types.Uint16(s._FundingRounds))
|
||||
values = append(values, s._FoundedAt)
|
||||
values = append(values, s._FirstFundingAt)
|
||||
values = append(values, s._LastFundingAt)
|
||||
values = append(values, s._Rounds)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Company) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForCompany.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Company) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Company) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForCompany.Chunks()...)
|
||||
chunks = append(chunks, s._CategoryList.Chunks()...)
|
||||
chunks = append(chunks, s._FoundedAt.Chunks()...)
|
||||
chunks = append(chunks, s._FirstFundingAt.Chunks()...)
|
||||
chunks = append(chunks, s._LastFundingAt.Chunks()...)
|
||||
chunks = append(chunks, s._Rounds.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Company) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Permalink))
|
||||
ret = append(ret, types.NewString(s._Name))
|
||||
ret = append(ret, types.NewString(s._HomepageUrl))
|
||||
ret = append(ret, s._CategoryList)
|
||||
ret = append(ret, types.NewString(s._Market))
|
||||
ret = append(ret, types.Float64(s._FundingTotalUsd))
|
||||
ret = append(ret, types.NewString(s._Status))
|
||||
ret = append(ret, types.NewString(s._CountryCode))
|
||||
ret = append(ret, types.NewString(s._StateCode))
|
||||
ret = append(ret, types.NewString(s._Region))
|
||||
ret = append(ret, types.NewString(s._City))
|
||||
ret = append(ret, types.Uint16(s._FundingRounds))
|
||||
ret = append(ret, s._FoundedAt)
|
||||
ret = append(ret, s._FirstFundingAt)
|
||||
ret = append(ret, s._LastFundingAt)
|
||||
ret = append(ret, s._Rounds)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Company) Permalink() string {
|
||||
return s._Permalink
|
||||
}
|
||||
|
||||
func (s Company) SetPermalink(val string) Company {
|
||||
s._Permalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Name() string {
|
||||
return s._Name
|
||||
}
|
||||
|
||||
func (s Company) SetName(val string) Company {
|
||||
s._Name = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) HomepageUrl() string {
|
||||
return s._HomepageUrl
|
||||
}
|
||||
|
||||
func (s Company) SetHomepageUrl(val string) Company {
|
||||
s._HomepageUrl = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) CategoryList() SetOfString {
|
||||
return s._CategoryList
|
||||
}
|
||||
|
||||
func (s Company) SetCategoryList(val SetOfString) Company {
|
||||
s._CategoryList = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Market() string {
|
||||
return s._Market
|
||||
}
|
||||
|
||||
func (s Company) SetMarket(val string) Company {
|
||||
s._Market = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FundingTotalUsd() float64 {
|
||||
return s._FundingTotalUsd
|
||||
}
|
||||
|
||||
func (s Company) SetFundingTotalUsd(val float64) Company {
|
||||
s._FundingTotalUsd = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Status() string {
|
||||
return s._Status
|
||||
}
|
||||
|
||||
func (s Company) SetStatus(val string) Company {
|
||||
s._Status = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) CountryCode() string {
|
||||
return s._CountryCode
|
||||
}
|
||||
|
||||
func (s Company) SetCountryCode(val string) Company {
|
||||
s._CountryCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) StateCode() string {
|
||||
return s._StateCode
|
||||
}
|
||||
|
||||
func (s Company) SetStateCode(val string) Company {
|
||||
s._StateCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Region() string {
|
||||
return s._Region
|
||||
}
|
||||
|
||||
func (s Company) SetRegion(val string) Company {
|
||||
s._Region = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) City() string {
|
||||
return s._City
|
||||
}
|
||||
|
||||
func (s Company) SetCity(val string) Company {
|
||||
s._City = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FundingRounds() uint16 {
|
||||
return s._FundingRounds
|
||||
}
|
||||
|
||||
func (s Company) SetFundingRounds(val uint16) Company {
|
||||
s._FundingRounds = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FoundedAt() Date {
|
||||
return s._FoundedAt
|
||||
}
|
||||
|
||||
func (s Company) SetFoundedAt(val Date) Company {
|
||||
s._FoundedAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FirstFundingAt() Date {
|
||||
return s._FirstFundingAt
|
||||
}
|
||||
|
||||
func (s Company) SetFirstFundingAt(val Date) Company {
|
||||
s._FirstFundingAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) LastFundingAt() Date {
|
||||
return s._LastFundingAt
|
||||
}
|
||||
|
||||
func (s Company) SetLastFundingAt(val Date) Company {
|
||||
s._LastFundingAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Rounds() SetOfRefOfRound {
|
||||
return s._Rounds
|
||||
}
|
||||
|
||||
func (s Company) SetRounds(val SetOfRefOfRound) Company {
|
||||
s._Rounds = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Round
|
||||
|
||||
type Round struct {
|
||||
_CompanyPermalink string
|
||||
_FundingRoundPermalink string
|
||||
_FundingRoundType string
|
||||
_FundingRoundCode string
|
||||
_FundedAt Date
|
||||
_RaisedAmountUsd float64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRound() Round {
|
||||
return Round{
|
||||
_CompanyPermalink: "",
|
||||
_FundingRoundPermalink: "",
|
||||
_FundingRoundType: "",
|
||||
_FundingRoundCode: "",
|
||||
_FundedAt: NewDate(),
|
||||
_RaisedAmountUsd: float64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type RoundDef struct {
|
||||
CompanyPermalink string
|
||||
FundingRoundPermalink string
|
||||
FundingRoundType string
|
||||
FundingRoundCode string
|
||||
FundedAt DateDef
|
||||
RaisedAmountUsd float64
|
||||
}
|
||||
|
||||
func (def RoundDef) New() Round {
|
||||
return Round{
|
||||
_CompanyPermalink: def.CompanyPermalink,
|
||||
_FundingRoundPermalink: def.FundingRoundPermalink,
|
||||
_FundingRoundType: def.FundingRoundType,
|
||||
_FundingRoundCode: def.FundingRoundCode,
|
||||
_FundedAt: def.FundedAt.New(),
|
||||
_RaisedAmountUsd: def.RaisedAmountUsd,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Round) Def() (d RoundDef) {
|
||||
d.CompanyPermalink = s._CompanyPermalink
|
||||
d.FundingRoundPermalink = s._FundingRoundPermalink
|
||||
d.FundingRoundType = s._FundingRoundType
|
||||
d.FundingRoundCode = s._FundingRoundCode
|
||||
d.FundedAt = s._FundedAt.Def()
|
||||
d.RaisedAmountUsd = s._RaisedAmountUsd
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForRound types.Type
|
||||
|
||||
func (m Round) Type() types.Type {
|
||||
return __typeForRound
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRound = types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1)
|
||||
types.RegisterStruct(__typeForRound, builderForRound, readerForRound)
|
||||
}
|
||||
|
||||
func builderForRound(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Round{ref: &ref.Ref{}}
|
||||
s._CompanyPermalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundPermalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundType = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundedAt = values[i].(Date)
|
||||
i++
|
||||
s._RaisedAmountUsd = float64(values[i].(types.Float64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForRound(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Round)
|
||||
values = append(values, types.NewString(s._CompanyPermalink))
|
||||
values = append(values, types.NewString(s._FundingRoundPermalink))
|
||||
values = append(values, types.NewString(s._FundingRoundType))
|
||||
values = append(values, types.NewString(s._FundingRoundCode))
|
||||
values = append(values, s._FundedAt)
|
||||
values = append(values, types.Float64(s._RaisedAmountUsd))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Round) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRound.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Round) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Round) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForRound.Chunks()...)
|
||||
chunks = append(chunks, s._FundedAt.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Round) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._CompanyPermalink))
|
||||
ret = append(ret, types.NewString(s._FundingRoundPermalink))
|
||||
ret = append(ret, types.NewString(s._FundingRoundType))
|
||||
ret = append(ret, types.NewString(s._FundingRoundCode))
|
||||
ret = append(ret, s._FundedAt)
|
||||
ret = append(ret, types.Float64(s._RaisedAmountUsd))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Round) CompanyPermalink() string {
|
||||
return s._CompanyPermalink
|
||||
}
|
||||
|
||||
func (s Round) SetCompanyPermalink(val string) Round {
|
||||
s._CompanyPermalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundPermalink() string {
|
||||
return s._FundingRoundPermalink
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundPermalink(val string) Round {
|
||||
s._FundingRoundPermalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundType() string {
|
||||
return s._FundingRoundType
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundType(val string) Round {
|
||||
s._FundingRoundType = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundCode() string {
|
||||
return s._FundingRoundCode
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundCode(val string) Round {
|
||||
s._FundingRoundCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundedAt() Date {
|
||||
return s._FundedAt
|
||||
}
|
||||
|
||||
func (s Round) SetFundedAt(val Date) Round {
|
||||
s._FundedAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) RaisedAmountUsd() float64 {
|
||||
return s._RaisedAmountUsd
|
||||
}
|
||||
|
||||
func (s Round) SetRaisedAmountUsd(val float64) Round {
|
||||
s._RaisedAmountUsd = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
|
||||
func (def SetOfStringDef) New() SetOfString {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
def := make(map[string]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(types.String).String()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfString.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfString.
|
||||
var __typeForSetOfString types.Type
|
||||
|
||||
func (m SetOfString) Type() types.Type {
|
||||
return __typeForSetOfString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfString = types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForSetOfString, builderForSetOfString, readerForSetOfString)
|
||||
}
|
||||
|
||||
func builderForSetOfString(v types.Value) types.Value {
|
||||
return SetOfString{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfString(v types.Value) types.Value {
|
||||
return v.(SetOfString).s
|
||||
}
|
||||
|
||||
func (s SetOfString) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfString) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfString) Has(p string) bool {
|
||||
return s.s.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
type SetOfStringIterCallback func(p string) (stop bool)
|
||||
|
||||
func (s SetOfString) Iter(cb SetOfStringIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringIterAllCallback func(p string)
|
||||
|
||||
func (s SetOfString) IterAll(cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfString) IterAllP(concurrency int, cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringFilterCallback func(p string) (keep bool)
|
||||
|
||||
func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
return SetOfString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) First() string {
|
||||
return s.s.First().(types.String).String()
|
||||
}
|
||||
|
||||
func (s SetOfString) fromStructSlice(p []SetOfString) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfString) fromElemSlice(p []string) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = types.NewString(v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// SetOfRefOfRound
|
||||
|
||||
type SetOfRefOfRound struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfRefOfRound() SetOfRefOfRound {
|
||||
return SetOfRefOfRound{types.NewTypedSet(__typeForSetOfRefOfRound), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundDef map[ref.Ref]bool
|
||||
|
||||
func (def SetOfRefOfRoundDef) New() SetOfRefOfRound {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = NewRefOfRound(d)
|
||||
i++
|
||||
}
|
||||
return SetOfRefOfRound{types.NewTypedSet(__typeForSetOfRefOfRound, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Def() SetOfRefOfRoundDef {
|
||||
def := make(map[ref.Ref]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(RefOfRound).TargetRef()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfRefOfRound.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfRefOfRound.
|
||||
var __typeForSetOfRefOfRound types.Type
|
||||
|
||||
func (m SetOfRefOfRound) Type() types.Type {
|
||||
return __typeForSetOfRefOfRound
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfRefOfRound = types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1)))
|
||||
types.RegisterValue(__typeForSetOfRefOfRound, builderForSetOfRefOfRound, readerForSetOfRefOfRound)
|
||||
}
|
||||
|
||||
func builderForSetOfRefOfRound(v types.Value) types.Value {
|
||||
return SetOfRefOfRound{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfRefOfRound(v types.Value) types.Value {
|
||||
return v.(SetOfRefOfRound).s
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Has(p RefOfRound) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundIterCallback func(p RefOfRound) (stop bool)
|
||||
|
||||
func (s SetOfRefOfRound) Iter(cb SetOfRefOfRoundIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundIterAllCallback func(p RefOfRound)
|
||||
|
||||
func (s SetOfRefOfRound) IterAll(cb SetOfRefOfRoundIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) IterAllP(concurrency int, cb SetOfRefOfRoundIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundFilterCallback func(p RefOfRound) (keep bool)
|
||||
|
||||
func (s SetOfRefOfRound) Filter(cb SetOfRefOfRoundFilterCallback) SetOfRefOfRound {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRound))
|
||||
})
|
||||
return SetOfRefOfRound{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Insert(p ...RefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Remove(p ...RefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Union(others ...SetOfRefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) First() RefOfRound {
|
||||
return s.s.First().(RefOfRound)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) fromStructSlice(p []SetOfRefOfRound) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) fromElemSlice(p []RefOfRound) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// RefOfRound
|
||||
|
||||
type RefOfRound struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfRound(target ref.Ref) RefOfRound {
|
||||
return RefOfRound{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfRound) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfRound) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfRound) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfRound.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfRound) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfRound) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfRound.
|
||||
var __typeForRefOfRound types.Type
|
||||
|
||||
func (r RefOfRound) Type() types.Type {
|
||||
return __typeForRefOfRound
|
||||
}
|
||||
|
||||
func (r RefOfRound) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfRound = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1))
|
||||
types.RegisterRef(__typeForRefOfRound, builderForRefOfRound)
|
||||
}
|
||||
|
||||
func builderForRefOfRound(r ref.Ref) types.RefBase {
|
||||
return NewRefOfRound(r)
|
||||
}
|
||||
|
||||
func (r RefOfRound) TargetValue(vr types.ValueReader) Round {
|
||||
return vr.ReadValue(r.target).(Round)
|
||||
}
|
||||
1
clients/crunchbase/index/.gitignore
vendored
1
clients/crunchbase/index/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
index
|
||||
@@ -1,198 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
var (
|
||||
inputID = flag.String("in", "", "dataset to pull data from.")
|
||||
outputID = flag.String("out", "", "dataset to store data in.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("Usage: %s -ldb=/path/to/db -in=<dataset> -out=<dataset>\n\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flags := datas.NewFlags()
|
||||
flag.Parse()
|
||||
|
||||
ds, ok := flags.CreateDataStore()
|
||||
if !ok || *inputID == "" || *outputID == "" {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer ds.Close()
|
||||
|
||||
err := d.Try(func() {
|
||||
if util.MaybeStartCPUProfile() {
|
||||
defer util.StopCPUProfile()
|
||||
}
|
||||
inputDataset := dataset.NewDataset(ds, *inputID)
|
||||
outputDataset := dataset.NewDataset(ds, *outputID)
|
||||
|
||||
imp := inputDataset.Head().Value().(Import)
|
||||
v := imp.Companies().TargetValue(ds)
|
||||
|
||||
type entry struct {
|
||||
key Key
|
||||
ref ref.Ref
|
||||
}
|
||||
|
||||
c := make(chan entry, 1024)
|
||||
|
||||
mapOfSets := MapOfRefOfKeyToSetOfRefOfRoundDef{}
|
||||
|
||||
addTimeRounds := func(t time.Time, ref ref.Ref) {
|
||||
year := int32(t.Year())
|
||||
yk := NewKey().SetYear(year)
|
||||
c <- entry{yk, ref}
|
||||
|
||||
q := timeToQuarter(t)
|
||||
qk := NewKey().SetQuarter(QuarterDef{Year: year, Quarter: q}.New())
|
||||
c <- entry{qk, ref}
|
||||
}
|
||||
|
||||
// Compute a cutoff date which is later used to only include rounds after this date to reduce the amount of data.
|
||||
// Hardcode the time.
|
||||
currentYear := time.Date(2015, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||
lastQ := time.Date(2015, time.July, 1, 0, 0, 0, 0, time.UTC)
|
||||
var timeCutoff time.Time
|
||||
if currentYear.Before(lastQ) {
|
||||
timeCutoff = currentYear
|
||||
} else {
|
||||
timeCutoff = lastQ
|
||||
}
|
||||
|
||||
go func() {
|
||||
v.IterAllP(64, func(permalink string, r RefOfCompany) {
|
||||
company := r.TargetValue(ds)
|
||||
categoryList := company.CategoryList()
|
||||
// Skip region for now to reduce size of data.
|
||||
// regionKey := NewKey().SetRegion(company.Region())
|
||||
|
||||
company.Rounds().IterAll(func(r RefOfRound) {
|
||||
round := r.TargetValue(ds)
|
||||
|
||||
dateToTime := func(d Date) time.Time {
|
||||
return time.Unix(d.MsSinceEpoch()/1e3, 0)
|
||||
}
|
||||
|
||||
// HACK: Only include rounds that are newer than the cutoff date.
|
||||
if dateToTime(round.FundedAt()).Before(timeCutoff) {
|
||||
return
|
||||
}
|
||||
|
||||
roundRef := r.TargetRef()
|
||||
categoryList.IterAllP(64, func(category string) {
|
||||
key := NewKey().SetCategory(category)
|
||||
c <- entry{key, roundRef}
|
||||
})
|
||||
|
||||
// Skip region for now to reduce size of data.
|
||||
// c <- entry{regionKey, roundRaiseDef}
|
||||
|
||||
addTimeRounds(dateToTime(round.FundedAt()), roundRef)
|
||||
|
||||
roundType := classifyRoundType(round)
|
||||
roundTypeKey := NewKey().SetRoundType(roundType)
|
||||
c <- entry{roundTypeKey, roundRef}
|
||||
})
|
||||
})
|
||||
|
||||
close(c)
|
||||
}()
|
||||
|
||||
for e := range c {
|
||||
key := e.key
|
||||
ref := e.ref
|
||||
keyRef := ds.WriteValue(key).TargetRef()
|
||||
setDef := mapOfSets[keyRef]
|
||||
if setDef == nil {
|
||||
setDef = SetOfRefOfRoundDef{}
|
||||
}
|
||||
|
||||
setDef[ref] = true
|
||||
mapOfSets[keyRef] = setDef
|
||||
}
|
||||
|
||||
output := mapOfSets.New()
|
||||
_, err := outputDataset.Commit(output)
|
||||
d.Exp.NoError(err)
|
||||
|
||||
util.MaybeWriteMemProfile()
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func classifyRoundType(round Round) RoundTypeEnum {
|
||||
if round.FundingRoundType() == "seed" {
|
||||
return Seed
|
||||
}
|
||||
switch round.FundingRoundCode() {
|
||||
case "A":
|
||||
return SeriesA
|
||||
case "B":
|
||||
return SeriesB
|
||||
case "C":
|
||||
return SeriesC
|
||||
case "D":
|
||||
return SeriesD
|
||||
case "E":
|
||||
return SeriesE
|
||||
case "F":
|
||||
return SeriesF
|
||||
case "G":
|
||||
return SeriesG
|
||||
case "H":
|
||||
return SeriesH
|
||||
default:
|
||||
return UnknownRoundType
|
||||
}
|
||||
}
|
||||
|
||||
func timeToQuarter(t time.Time) QuarterEnum {
|
||||
switch t.Month() {
|
||||
case time.January, time.February, time.March:
|
||||
return Q1
|
||||
case time.April, time.May, time.June:
|
||||
return Q2
|
||||
case time.July, time.August, time.September:
|
||||
return Q3
|
||||
case time.October, time.November, time.December:
|
||||
return Q4
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
func lastQuarter(t time.Time) time.Time {
|
||||
var m time.Month
|
||||
switch t.Month() {
|
||||
case time.January, time.February, time.March:
|
||||
m = time.January
|
||||
case time.April, time.May, time.June:
|
||||
m = time.April
|
||||
case time.July, time.August, time.September:
|
||||
m = time.July
|
||||
case time.October, time.November, time.December:
|
||||
m = time.October
|
||||
}
|
||||
currentQuarter := time.Date(time.Now().Year(), m, 1, 0, 0, 0, 0, time.UTC)
|
||||
return currentQuarter.AddDate(0, -3, 0)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
alias imp = import "../importer/importer.noms"
|
||||
alias cb = import "../crunchbase.noms"
|
||||
|
||||
enum QuarterEnum {
|
||||
Q1
|
||||
Q2
|
||||
Q3
|
||||
Q4
|
||||
}
|
||||
|
||||
struct Quarter {
|
||||
Year: Int32
|
||||
Quarter: QuarterEnum
|
||||
}
|
||||
|
||||
struct Key {
|
||||
union {
|
||||
Category: String
|
||||
Quarter: Quarter
|
||||
Region: String
|
||||
RoundType: RoundTypeEnum
|
||||
Year: Int32
|
||||
}
|
||||
}
|
||||
|
||||
enum RoundTypeEnum {
|
||||
Seed
|
||||
SeriesA
|
||||
SeriesB
|
||||
SeriesC
|
||||
SeriesD
|
||||
SeriesE
|
||||
SeriesF
|
||||
SeriesG
|
||||
SeriesH
|
||||
UnknownRoundType
|
||||
}
|
||||
|
||||
using Map<String, Ref<cb.Company>>
|
||||
using Map<Ref<Key>, Set<Ref<cb.Round>>>
|
||||
@@ -1,660 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeEnumType("QuarterEnum", "Q1", "Q2", "Q3", "Q4"),
|
||||
types.MakeStructType("Quarter",
|
||||
[]types.Field{
|
||||
types.Field{"Year", types.MakePrimitiveType(types.Int32Kind), false},
|
||||
types.Field{"Quarter", types.MakeType(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Key",
|
||||
[]types.Field{},
|
||||
types.Choices{
|
||||
types.Field{"Category", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Quarter", types.MakeType(ref.Ref{}, 1), false},
|
||||
types.Field{"Region", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"RoundType", types.MakeType(ref.Ref{}, 3), false},
|
||||
types.Field{"Year", types.MakePrimitiveType(types.Int32Kind), false},
|
||||
},
|
||||
),
|
||||
types.MakeEnumType("RoundTypeEnum", "Seed", "SeriesA", "SeriesB", "SeriesC", "SeriesD", "SeriesE", "SeriesF", "SeriesG", "SeriesH", "UnknownRoundType"),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-6c64b08a509e25f9814dbf036489267c957a6fd8"),
|
||||
ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// QuarterEnum
|
||||
|
||||
type QuarterEnum uint32
|
||||
|
||||
const (
|
||||
Q1 QuarterEnum = iota
|
||||
Q2
|
||||
Q3
|
||||
Q4
|
||||
)
|
||||
|
||||
func NewQuarterEnum() QuarterEnum {
|
||||
return QuarterEnum(0)
|
||||
}
|
||||
|
||||
var __typeForQuarterEnum types.Type
|
||||
|
||||
func (e QuarterEnum) Type() types.Type {
|
||||
return __typeForQuarterEnum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForQuarterEnum = types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 0)
|
||||
types.RegisterEnum(__typeForQuarterEnum, builderForQuarterEnum, readerForQuarterEnum)
|
||||
}
|
||||
|
||||
func builderForQuarterEnum(v uint32) types.Value {
|
||||
return QuarterEnum(v)
|
||||
}
|
||||
|
||||
func readerForQuarterEnum(v types.Value) uint32 {
|
||||
return uint32(v.(QuarterEnum))
|
||||
}
|
||||
|
||||
func (e QuarterEnum) Equals(other types.Value) bool {
|
||||
return e == other
|
||||
}
|
||||
|
||||
func (e QuarterEnum) Ref() ref.Ref {
|
||||
throwaway := ref.Ref{}
|
||||
return types.EnsureRef(&throwaway, e)
|
||||
}
|
||||
|
||||
func (e QuarterEnum) Chunks() []types.RefBase {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e QuarterEnum) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Quarter
|
||||
|
||||
type Quarter struct {
|
||||
_Year int32
|
||||
_Quarter QuarterEnum
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewQuarter() Quarter {
|
||||
return Quarter{
|
||||
_Year: int32(0),
|
||||
_Quarter: NewQuarterEnum(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type QuarterDef struct {
|
||||
Year int32
|
||||
Quarter QuarterEnum
|
||||
}
|
||||
|
||||
func (def QuarterDef) New() Quarter {
|
||||
return Quarter{
|
||||
_Year: def.Year,
|
||||
_Quarter: def.Quarter,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Quarter) Def() (d QuarterDef) {
|
||||
d.Year = s._Year
|
||||
d.Quarter = s._Quarter
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForQuarter types.Type
|
||||
|
||||
func (m Quarter) Type() types.Type {
|
||||
return __typeForQuarter
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForQuarter = types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 1)
|
||||
types.RegisterStruct(__typeForQuarter, builderForQuarter, readerForQuarter)
|
||||
}
|
||||
|
||||
func builderForQuarter(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Quarter{ref: &ref.Ref{}}
|
||||
s._Year = int32(values[i].(types.Int32))
|
||||
i++
|
||||
s._Quarter = values[i].(QuarterEnum)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForQuarter(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Quarter)
|
||||
values = append(values, types.Int32(s._Year))
|
||||
values = append(values, s._Quarter)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Quarter) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForQuarter.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Quarter) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Quarter) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForQuarter.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Quarter) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int32(s._Year))
|
||||
ret = append(ret, s._Quarter)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Quarter) Year() int32 {
|
||||
return s._Year
|
||||
}
|
||||
|
||||
func (s Quarter) SetYear(val int32) Quarter {
|
||||
s._Year = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Quarter) Quarter() QuarterEnum {
|
||||
return s._Quarter
|
||||
}
|
||||
|
||||
func (s Quarter) SetQuarter(val QuarterEnum) Quarter {
|
||||
s._Quarter = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Key
|
||||
|
||||
type Key struct {
|
||||
__unionIndex uint32
|
||||
__unionValue types.Value
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewKey() Key {
|
||||
return Key{
|
||||
__unionIndex: 0,
|
||||
__unionValue: types.NewString(""),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type KeyDef struct {
|
||||
__unionIndex uint32
|
||||
__unionValue types.Value
|
||||
}
|
||||
|
||||
func (def KeyDef) New() Key {
|
||||
return Key{
|
||||
__unionIndex: def.__unionIndex,
|
||||
__unionValue: def.__unionValue,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Key) Def() (d KeyDef) {
|
||||
d.__unionIndex = s.__unionIndex
|
||||
d.__unionValue = s.__unionValue
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForKey types.Type
|
||||
|
||||
func (m Key) Type() types.Type {
|
||||
return __typeForKey
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForKey = types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 2)
|
||||
types.RegisterStruct(__typeForKey, builderForKey, readerForKey)
|
||||
}
|
||||
|
||||
func builderForKey(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Key{ref: &ref.Ref{}}
|
||||
s.__unionIndex = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
s.__unionValue = values[i]
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForKey(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Key)
|
||||
values = append(values, types.Uint32(s.__unionIndex))
|
||||
values = append(values, s.__unionValue)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Key) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForKey.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Key) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Key) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForKey.Chunks()...)
|
||||
chunks = append(chunks, s.__unionValue.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Key) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, s.__unionValue)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Key) Category() (val string, ok bool) {
|
||||
if s.__unionIndex != 0 {
|
||||
return
|
||||
}
|
||||
return s.__unionValue.(types.String).String(), true
|
||||
}
|
||||
|
||||
func (s Key) SetCategory(val string) Key {
|
||||
s.__unionIndex = 0
|
||||
s.__unionValue = types.NewString(val)
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (def KeyDef) Category() (val string, ok bool) {
|
||||
if def.__unionIndex != 0 {
|
||||
return
|
||||
}
|
||||
return def.__unionValue.(types.String).String(), true
|
||||
}
|
||||
|
||||
func (def KeyDef) SetCategory(val string) KeyDef {
|
||||
def.__unionIndex = 0
|
||||
def.__unionValue = types.NewString(val)
|
||||
return def
|
||||
}
|
||||
|
||||
func (s Key) Quarter() (val Quarter, ok bool) {
|
||||
if s.__unionIndex != 1 {
|
||||
return
|
||||
}
|
||||
return s.__unionValue.(Quarter), true
|
||||
}
|
||||
|
||||
func (s Key) SetQuarter(val Quarter) Key {
|
||||
s.__unionIndex = 1
|
||||
s.__unionValue = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (def KeyDef) Quarter() (val QuarterDef, ok bool) {
|
||||
if def.__unionIndex != 1 {
|
||||
return
|
||||
}
|
||||
return def.__unionValue.(Quarter).Def(), true
|
||||
}
|
||||
|
||||
func (def KeyDef) SetQuarter(val QuarterDef) KeyDef {
|
||||
def.__unionIndex = 1
|
||||
def.__unionValue = val.New()
|
||||
return def
|
||||
}
|
||||
|
||||
func (s Key) Region() (val string, ok bool) {
|
||||
if s.__unionIndex != 2 {
|
||||
return
|
||||
}
|
||||
return s.__unionValue.(types.String).String(), true
|
||||
}
|
||||
|
||||
func (s Key) SetRegion(val string) Key {
|
||||
s.__unionIndex = 2
|
||||
s.__unionValue = types.NewString(val)
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (def KeyDef) Region() (val string, ok bool) {
|
||||
if def.__unionIndex != 2 {
|
||||
return
|
||||
}
|
||||
return def.__unionValue.(types.String).String(), true
|
||||
}
|
||||
|
||||
func (def KeyDef) SetRegion(val string) KeyDef {
|
||||
def.__unionIndex = 2
|
||||
def.__unionValue = types.NewString(val)
|
||||
return def
|
||||
}
|
||||
|
||||
func (s Key) RoundType() (val RoundTypeEnum, ok bool) {
|
||||
if s.__unionIndex != 3 {
|
||||
return
|
||||
}
|
||||
return s.__unionValue.(RoundTypeEnum), true
|
||||
}
|
||||
|
||||
func (s Key) SetRoundType(val RoundTypeEnum) Key {
|
||||
s.__unionIndex = 3
|
||||
s.__unionValue = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (def KeyDef) RoundType() (val RoundTypeEnum, ok bool) {
|
||||
if def.__unionIndex != 3 {
|
||||
return
|
||||
}
|
||||
return def.__unionValue.(RoundTypeEnum), true
|
||||
}
|
||||
|
||||
func (def KeyDef) SetRoundType(val RoundTypeEnum) KeyDef {
|
||||
def.__unionIndex = 3
|
||||
def.__unionValue = val
|
||||
return def
|
||||
}
|
||||
|
||||
func (s Key) Year() (val int32, ok bool) {
|
||||
if s.__unionIndex != 4 {
|
||||
return
|
||||
}
|
||||
return int32(s.__unionValue.(types.Int32)), true
|
||||
}
|
||||
|
||||
func (s Key) SetYear(val int32) Key {
|
||||
s.__unionIndex = 4
|
||||
s.__unionValue = types.Int32(val)
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (def KeyDef) Year() (val int32, ok bool) {
|
||||
if def.__unionIndex != 4 {
|
||||
return
|
||||
}
|
||||
return int32(def.__unionValue.(types.Int32)), true
|
||||
}
|
||||
|
||||
func (def KeyDef) SetYear(val int32) KeyDef {
|
||||
def.__unionIndex = 4
|
||||
def.__unionValue = types.Int32(val)
|
||||
return def
|
||||
}
|
||||
|
||||
// RoundTypeEnum
|
||||
|
||||
type RoundTypeEnum uint32
|
||||
|
||||
const (
|
||||
Seed RoundTypeEnum = iota
|
||||
SeriesA
|
||||
SeriesB
|
||||
SeriesC
|
||||
SeriesD
|
||||
SeriesE
|
||||
SeriesF
|
||||
SeriesG
|
||||
SeriesH
|
||||
UnknownRoundType
|
||||
)
|
||||
|
||||
func NewRoundTypeEnum() RoundTypeEnum {
|
||||
return RoundTypeEnum(0)
|
||||
}
|
||||
|
||||
var __typeForRoundTypeEnum types.Type
|
||||
|
||||
func (e RoundTypeEnum) Type() types.Type {
|
||||
return __typeForRoundTypeEnum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRoundTypeEnum = types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 3)
|
||||
types.RegisterEnum(__typeForRoundTypeEnum, builderForRoundTypeEnum, readerForRoundTypeEnum)
|
||||
}
|
||||
|
||||
func builderForRoundTypeEnum(v uint32) types.Value {
|
||||
return RoundTypeEnum(v)
|
||||
}
|
||||
|
||||
func readerForRoundTypeEnum(v types.Value) uint32 {
|
||||
return uint32(v.(RoundTypeEnum))
|
||||
}
|
||||
|
||||
func (e RoundTypeEnum) Equals(other types.Value) bool {
|
||||
return e == other
|
||||
}
|
||||
|
||||
func (e RoundTypeEnum) Ref() ref.Ref {
|
||||
throwaway := ref.Ref{}
|
||||
return types.EnsureRef(&throwaway, e)
|
||||
}
|
||||
|
||||
func (e RoundTypeEnum) Chunks() []types.RefBase {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e RoundTypeEnum) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MapOfRefOfKeyToSetOfRefOfRound
|
||||
|
||||
type MapOfRefOfKeyToSetOfRefOfRound struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfRefOfKeyToSetOfRefOfRound() MapOfRefOfKeyToSetOfRefOfRound {
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{types.NewTypedMap(__typeForMapOfRefOfKeyToSetOfRefOfRound), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfRefOfKeyToSetOfRefOfRoundDef map[ref.Ref]SetOfRefOfRoundDef
|
||||
|
||||
func (def MapOfRefOfKeyToSetOfRefOfRoundDef) New() MapOfRefOfKeyToSetOfRefOfRound {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, NewRefOfKey(k), v.New())
|
||||
}
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{types.NewTypedMap(__typeForMapOfRefOfKeyToSetOfRefOfRound, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Def() MapOfRefOfKeyToSetOfRefOfRoundDef {
|
||||
def := make(map[ref.Ref]SetOfRefOfRoundDef)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(RefOfKey).TargetRef()] = v.(SetOfRefOfRound).Def()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfRefOfKeyToSetOfRefOfRound.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfRefOfKeyToSetOfRefOfRound.
|
||||
var __typeForMapOfRefOfKeyToSetOfRefOfRound types.Type
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Type() types.Type {
|
||||
return __typeForMapOfRefOfKeyToSetOfRefOfRound
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfRefOfKeyToSetOfRefOfRound = types.MakeCompoundType(types.MapKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 2)), types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1))))
|
||||
types.RegisterValue(__typeForMapOfRefOfKeyToSetOfRefOfRound, builderForMapOfRefOfKeyToSetOfRefOfRound, readerForMapOfRefOfKeyToSetOfRefOfRound)
|
||||
}
|
||||
|
||||
func builderForMapOfRefOfKeyToSetOfRefOfRound(v types.Value) types.Value {
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfRefOfKeyToSetOfRefOfRound(v types.Value) types.Value {
|
||||
return v.(MapOfRefOfKeyToSetOfRefOfRound).m
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Has(p RefOfKey) bool {
|
||||
return m.m.Has(p)
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Get(p RefOfKey) SetOfRefOfRound {
|
||||
return m.m.Get(p).(SetOfRefOfRound)
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) MaybeGet(p RefOfKey) (SetOfRefOfRound, bool) {
|
||||
v, ok := m.m.MaybeGet(p)
|
||||
if !ok {
|
||||
return NewSetOfRefOfRound(), false
|
||||
}
|
||||
return v.(SetOfRefOfRound), ok
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Set(k RefOfKey, v SetOfRefOfRound) MapOfRefOfKeyToSetOfRefOfRound {
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{m.m.Set(k, v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Remove(p RefOfKey) MapOfRefOfKeyToSetOfRefOfRound {
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{m.m.Remove(p), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfRefOfKeyToSetOfRefOfRoundIterCallback func(k RefOfKey, v SetOfRefOfRound) (stop bool)
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Iter(cb MapOfRefOfKeyToSetOfRefOfRoundIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(RefOfKey), v.(SetOfRefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfRefOfKeyToSetOfRefOfRoundIterAllCallback func(k RefOfKey, v SetOfRefOfRound)
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) IterAll(cb MapOfRefOfKeyToSetOfRefOfRoundIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(RefOfKey), v.(SetOfRefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) IterAllP(concurrency int, cb MapOfRefOfKeyToSetOfRefOfRoundIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(RefOfKey), v.(SetOfRefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfRefOfKeyToSetOfRefOfRoundFilterCallback func(k RefOfKey, v SetOfRefOfRound) (keep bool)
|
||||
|
||||
func (m MapOfRefOfKeyToSetOfRefOfRound) Filter(cb MapOfRefOfKeyToSetOfRefOfRoundFilterCallback) MapOfRefOfKeyToSetOfRefOfRound {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(RefOfKey), v.(SetOfRefOfRound))
|
||||
})
|
||||
return MapOfRefOfKeyToSetOfRefOfRound{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfKey
|
||||
|
||||
type RefOfKey struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfKey(target ref.Ref) RefOfKey {
|
||||
return RefOfKey{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfKey) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfKey) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfKey) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfKey.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfKey) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfKey) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfKey.
|
||||
var __typeForRefOfKey types.Type
|
||||
|
||||
func (r RefOfKey) Type() types.Type {
|
||||
return __typeForRefOfKey
|
||||
}
|
||||
|
||||
func (r RefOfKey) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfKey = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-1d9b1605b84bc4f043956d96b4abddc9c0c139ba"), 2))
|
||||
types.RegisterRef(__typeForRefOfKey, builderForRefOfKey)
|
||||
}
|
||||
|
||||
func builderForRefOfKey(r ref.Ref) types.RefBase {
|
||||
return NewRefOfKey(r)
|
||||
}
|
||||
|
||||
func (r RefOfKey) TargetValue(vr types.ValueReader) Key {
|
||||
return vr.ReadValue(r.target).(Key)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../../nomdl/codegen/codegen.go -package=main -out-dir=.
|
||||
@@ -1,109 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Date",
|
||||
[]types.Field{
|
||||
types.Field{"MsSinceEpoch", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Date
|
||||
|
||||
type Date struct {
|
||||
_MsSinceEpoch int64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDate() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: int64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type DateDef struct {
|
||||
MsSinceEpoch int64
|
||||
}
|
||||
|
||||
func (def DateDef) New() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: def.MsSinceEpoch,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Date) Def() (d DateDef) {
|
||||
d.MsSinceEpoch = s._MsSinceEpoch
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForDate types.Type
|
||||
|
||||
func (m Date) Type() types.Type {
|
||||
return __typeForDate
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForDate = types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0)
|
||||
types.RegisterStruct(__typeForDate, builderForDate, readerForDate)
|
||||
}
|
||||
|
||||
func builderForDate(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Date{ref: &ref.Ref{}}
|
||||
s._MsSinceEpoch = int64(values[i].(types.Int64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForDate(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Date)
|
||||
values = append(values, types.Int64(s._MsSinceEpoch))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Date) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForDate.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Date) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Date) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForDate.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._MsSinceEpoch))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) MsSinceEpoch() int64 {
|
||||
return s._MsSinceEpoch
|
||||
}
|
||||
|
||||
func (s Date) SetMsSinceEpoch(val int64) Date {
|
||||
s._MsSinceEpoch = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,401 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Import",
|
||||
[]types.Field{
|
||||
types.Field{"FileSHA1", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Companies", types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Import
|
||||
|
||||
type Import struct {
|
||||
_FileSHA1 string
|
||||
_Date Date
|
||||
_Companies RefOfMapOfStringToRefOfCompany
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewImport() Import {
|
||||
return Import{
|
||||
_FileSHA1: "",
|
||||
_Date: NewDate(),
|
||||
_Companies: NewRefOfMapOfStringToRefOfCompany(ref.Ref{}),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type ImportDef struct {
|
||||
FileSHA1 string
|
||||
Date DateDef
|
||||
Companies ref.Ref
|
||||
}
|
||||
|
||||
func (def ImportDef) New() Import {
|
||||
return Import{
|
||||
_FileSHA1: def.FileSHA1,
|
||||
_Date: def.Date.New(),
|
||||
_Companies: NewRefOfMapOfStringToRefOfCompany(def.Companies),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Import) Def() (d ImportDef) {
|
||||
d.FileSHA1 = s._FileSHA1
|
||||
d.Date = s._Date.Def()
|
||||
d.Companies = s._Companies.TargetRef()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForImport types.Type
|
||||
|
||||
func (m Import) Type() types.Type {
|
||||
return __typeForImport
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForImport = types.MakeType(ref.Parse("sha1-6c64b08a509e25f9814dbf036489267c957a6fd8"), 0)
|
||||
types.RegisterStruct(__typeForImport, builderForImport, readerForImport)
|
||||
}
|
||||
|
||||
func builderForImport(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Import{ref: &ref.Ref{}}
|
||||
s._FileSHA1 = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(Date)
|
||||
i++
|
||||
s._Companies = values[i].(RefOfMapOfStringToRefOfCompany)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForImport(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Import)
|
||||
values = append(values, types.NewString(s._FileSHA1))
|
||||
values = append(values, s._Date)
|
||||
values = append(values, s._Companies)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Import) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForImport.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Import) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Import) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForImport.Chunks()...)
|
||||
chunks = append(chunks, s._Date.Chunks()...)
|
||||
chunks = append(chunks, s._Companies.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Import) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._FileSHA1))
|
||||
ret = append(ret, s._Date)
|
||||
ret = append(ret, s._Companies)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Import) FileSHA1() string {
|
||||
return s._FileSHA1
|
||||
}
|
||||
|
||||
func (s Import) SetFileSHA1(val string) Import {
|
||||
s._FileSHA1 = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Import) Date() Date {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s Import) SetDate(val Date) Import {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Import) Companies() RefOfMapOfStringToRefOfCompany {
|
||||
return s._Companies
|
||||
}
|
||||
|
||||
func (s Import) SetCompanies(val RefOfMapOfStringToRefOfCompany) Import {
|
||||
s._Companies = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// RefOfMapOfStringToRefOfCompany
|
||||
|
||||
type RefOfMapOfStringToRefOfCompany struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfMapOfStringToRefOfCompany(target ref.Ref) RefOfMapOfStringToRefOfCompany {
|
||||
return RefOfMapOfStringToRefOfCompany{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfMapOfStringToRefOfCompany.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfMapOfStringToRefOfCompany.
|
||||
var __typeForRefOfMapOfStringToRefOfCompany types.Type
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Type() types.Type {
|
||||
return __typeForRefOfMapOfStringToRefOfCompany
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfMapOfStringToRefOfCompany = types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0))))
|
||||
types.RegisterRef(__typeForRefOfMapOfStringToRefOfCompany, builderForRefOfMapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForRefOfMapOfStringToRefOfCompany(r ref.Ref) types.RefBase {
|
||||
return NewRefOfMapOfStringToRefOfCompany(r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToRefOfCompany) TargetValue(vr types.ValueReader) MapOfStringToRefOfCompany {
|
||||
return vr.ReadValue(r.target).(MapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
// MapOfStringToRefOfCompany
|
||||
|
||||
type MapOfStringToRefOfCompany struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToRefOfCompany() MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{types.NewTypedMap(__typeForMapOfStringToRefOfCompany), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyDef map[string]ref.Ref
|
||||
|
||||
func (def MapOfStringToRefOfCompanyDef) New() MapOfStringToRefOfCompany {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), NewRefOfCompany(v))
|
||||
}
|
||||
return MapOfStringToRefOfCompany{types.NewTypedMap(__typeForMapOfStringToRefOfCompany, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Def() MapOfStringToRefOfCompanyDef {
|
||||
def := make(map[string]ref.Ref)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = v.(RefOfCompany).TargetRef()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfStringToRefOfCompany.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfStringToRefOfCompany.
|
||||
var __typeForMapOfStringToRefOfCompany types.Type
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Type() types.Type {
|
||||
return __typeForMapOfStringToRefOfCompany
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfStringToRefOfCompany = types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)))
|
||||
types.RegisterValue(__typeForMapOfStringToRefOfCompany, builderForMapOfStringToRefOfCompany, readerForMapOfStringToRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForMapOfStringToRefOfCompany(v types.Value) types.Value {
|
||||
return MapOfStringToRefOfCompany{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfStringToRefOfCompany(v types.Value) types.Value {
|
||||
return v.(MapOfStringToRefOfCompany).m
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Has(p string) bool {
|
||||
return m.m.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Get(p string) RefOfCompany {
|
||||
return m.m.Get(types.NewString(p)).(RefOfCompany)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) MaybeGet(p string) (RefOfCompany, bool) {
|
||||
v, ok := m.m.MaybeGet(types.NewString(p))
|
||||
if !ok {
|
||||
return NewRefOfCompany(ref.Ref{}), false
|
||||
}
|
||||
return v.(RefOfCompany), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Set(k string, v RefOfCompany) MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Remove(p string) MapOfStringToRefOfCompany {
|
||||
return MapOfStringToRefOfCompany{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyIterCallback func(k string, v RefOfCompany) (stop bool)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Iter(cb MapOfStringToRefOfCompanyIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyIterAllCallback func(k string, v RefOfCompany)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) IterAll(cb MapOfStringToRefOfCompanyIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfCompany) IterAllP(concurrency int, cb MapOfStringToRefOfCompanyIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfCompanyFilterCallback func(k string, v RefOfCompany) (keep bool)
|
||||
|
||||
func (m MapOfStringToRefOfCompany) Filter(cb MapOfStringToRefOfCompanyFilterCallback) MapOfStringToRefOfCompany {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfCompany))
|
||||
})
|
||||
return MapOfStringToRefOfCompany{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfCompany
|
||||
|
||||
type RefOfCompany struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfCompany(target ref.Ref) RefOfCompany {
|
||||
return RefOfCompany{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfCompany) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfCompany.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfCompany) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfCompany.
|
||||
var __typeForRefOfCompany types.Type
|
||||
|
||||
func (r RefOfCompany) Type() types.Type {
|
||||
return __typeForRefOfCompany
|
||||
}
|
||||
|
||||
func (r RefOfCompany) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfCompany = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0))
|
||||
types.RegisterRef(__typeForRefOfCompany, builderForRefOfCompany)
|
||||
}
|
||||
|
||||
func builderForRefOfCompany(r ref.Ref) types.RefBase {
|
||||
return NewRefOfCompany(r)
|
||||
}
|
||||
|
||||
func (r RefOfCompany) TargetValue(vr types.ValueReader) Company {
|
||||
return vr.ReadValue(r.target).(Company)
|
||||
}
|
||||
@@ -1,956 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Company",
|
||||
[]types.Field{
|
||||
types.Field{"Permalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Name", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"HomepageUrl", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"CategoryList", types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Market", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingTotalUsd", types.MakePrimitiveType(types.Float64Kind), false},
|
||||
types.Field{"Status", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"CountryCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"StateCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Region", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"City", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRounds", types.MakePrimitiveType(types.Uint16Kind), false},
|
||||
types.Field{"FoundedAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"FirstFundingAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"LastFundingAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Rounds", types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Ref{}, 1))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Round",
|
||||
[]types.Field{
|
||||
types.Field{"CompanyPermalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundPermalink", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundType", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundingRoundCode", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"FundedAt", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"RaisedAmountUsd", types.MakePrimitiveType(types.Float64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Company
|
||||
|
||||
type Company struct {
|
||||
_Permalink string
|
||||
_Name string
|
||||
_HomepageUrl string
|
||||
_CategoryList SetOfString
|
||||
_Market string
|
||||
_FundingTotalUsd float64
|
||||
_Status string
|
||||
_CountryCode string
|
||||
_StateCode string
|
||||
_Region string
|
||||
_City string
|
||||
_FundingRounds uint16
|
||||
_FoundedAt Date
|
||||
_FirstFundingAt Date
|
||||
_LastFundingAt Date
|
||||
_Rounds SetOfRefOfRound
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewCompany() Company {
|
||||
return Company{
|
||||
_Permalink: "",
|
||||
_Name: "",
|
||||
_HomepageUrl: "",
|
||||
_CategoryList: NewSetOfString(),
|
||||
_Market: "",
|
||||
_FundingTotalUsd: float64(0),
|
||||
_Status: "",
|
||||
_CountryCode: "",
|
||||
_StateCode: "",
|
||||
_Region: "",
|
||||
_City: "",
|
||||
_FundingRounds: uint16(0),
|
||||
_FoundedAt: NewDate(),
|
||||
_FirstFundingAt: NewDate(),
|
||||
_LastFundingAt: NewDate(),
|
||||
_Rounds: NewSetOfRefOfRound(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type CompanyDef struct {
|
||||
Permalink string
|
||||
Name string
|
||||
HomepageUrl string
|
||||
CategoryList SetOfStringDef
|
||||
Market string
|
||||
FundingTotalUsd float64
|
||||
Status string
|
||||
CountryCode string
|
||||
StateCode string
|
||||
Region string
|
||||
City string
|
||||
FundingRounds uint16
|
||||
FoundedAt DateDef
|
||||
FirstFundingAt DateDef
|
||||
LastFundingAt DateDef
|
||||
Rounds SetOfRefOfRoundDef
|
||||
}
|
||||
|
||||
func (def CompanyDef) New() Company {
|
||||
return Company{
|
||||
_Permalink: def.Permalink,
|
||||
_Name: def.Name,
|
||||
_HomepageUrl: def.HomepageUrl,
|
||||
_CategoryList: def.CategoryList.New(),
|
||||
_Market: def.Market,
|
||||
_FundingTotalUsd: def.FundingTotalUsd,
|
||||
_Status: def.Status,
|
||||
_CountryCode: def.CountryCode,
|
||||
_StateCode: def.StateCode,
|
||||
_Region: def.Region,
|
||||
_City: def.City,
|
||||
_FundingRounds: def.FundingRounds,
|
||||
_FoundedAt: def.FoundedAt.New(),
|
||||
_FirstFundingAt: def.FirstFundingAt.New(),
|
||||
_LastFundingAt: def.LastFundingAt.New(),
|
||||
_Rounds: def.Rounds.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Company) Def() (d CompanyDef) {
|
||||
d.Permalink = s._Permalink
|
||||
d.Name = s._Name
|
||||
d.HomepageUrl = s._HomepageUrl
|
||||
d.CategoryList = s._CategoryList.Def()
|
||||
d.Market = s._Market
|
||||
d.FundingTotalUsd = s._FundingTotalUsd
|
||||
d.Status = s._Status
|
||||
d.CountryCode = s._CountryCode
|
||||
d.StateCode = s._StateCode
|
||||
d.Region = s._Region
|
||||
d.City = s._City
|
||||
d.FundingRounds = s._FundingRounds
|
||||
d.FoundedAt = s._FoundedAt.Def()
|
||||
d.FirstFundingAt = s._FirstFundingAt.Def()
|
||||
d.LastFundingAt = s._LastFundingAt.Def()
|
||||
d.Rounds = s._Rounds.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForCompany types.Type
|
||||
|
||||
func (m Company) Type() types.Type {
|
||||
return __typeForCompany
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForCompany = types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 0)
|
||||
types.RegisterStruct(__typeForCompany, builderForCompany, readerForCompany)
|
||||
}
|
||||
|
||||
func builderForCompany(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Company{ref: &ref.Ref{}}
|
||||
s._Permalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._Name = values[i].(types.String).String()
|
||||
i++
|
||||
s._HomepageUrl = values[i].(types.String).String()
|
||||
i++
|
||||
s._CategoryList = values[i].(SetOfString)
|
||||
i++
|
||||
s._Market = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingTotalUsd = float64(values[i].(types.Float64))
|
||||
i++
|
||||
s._Status = values[i].(types.String).String()
|
||||
i++
|
||||
s._CountryCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._StateCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._Region = values[i].(types.String).String()
|
||||
i++
|
||||
s._City = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRounds = uint16(values[i].(types.Uint16))
|
||||
i++
|
||||
s._FoundedAt = values[i].(Date)
|
||||
i++
|
||||
s._FirstFundingAt = values[i].(Date)
|
||||
i++
|
||||
s._LastFundingAt = values[i].(Date)
|
||||
i++
|
||||
s._Rounds = values[i].(SetOfRefOfRound)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForCompany(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Company)
|
||||
values = append(values, types.NewString(s._Permalink))
|
||||
values = append(values, types.NewString(s._Name))
|
||||
values = append(values, types.NewString(s._HomepageUrl))
|
||||
values = append(values, s._CategoryList)
|
||||
values = append(values, types.NewString(s._Market))
|
||||
values = append(values, types.Float64(s._FundingTotalUsd))
|
||||
values = append(values, types.NewString(s._Status))
|
||||
values = append(values, types.NewString(s._CountryCode))
|
||||
values = append(values, types.NewString(s._StateCode))
|
||||
values = append(values, types.NewString(s._Region))
|
||||
values = append(values, types.NewString(s._City))
|
||||
values = append(values, types.Uint16(s._FundingRounds))
|
||||
values = append(values, s._FoundedAt)
|
||||
values = append(values, s._FirstFundingAt)
|
||||
values = append(values, s._LastFundingAt)
|
||||
values = append(values, s._Rounds)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Company) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForCompany.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Company) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Company) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForCompany.Chunks()...)
|
||||
chunks = append(chunks, s._CategoryList.Chunks()...)
|
||||
chunks = append(chunks, s._FoundedAt.Chunks()...)
|
||||
chunks = append(chunks, s._FirstFundingAt.Chunks()...)
|
||||
chunks = append(chunks, s._LastFundingAt.Chunks()...)
|
||||
chunks = append(chunks, s._Rounds.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Company) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Permalink))
|
||||
ret = append(ret, types.NewString(s._Name))
|
||||
ret = append(ret, types.NewString(s._HomepageUrl))
|
||||
ret = append(ret, s._CategoryList)
|
||||
ret = append(ret, types.NewString(s._Market))
|
||||
ret = append(ret, types.Float64(s._FundingTotalUsd))
|
||||
ret = append(ret, types.NewString(s._Status))
|
||||
ret = append(ret, types.NewString(s._CountryCode))
|
||||
ret = append(ret, types.NewString(s._StateCode))
|
||||
ret = append(ret, types.NewString(s._Region))
|
||||
ret = append(ret, types.NewString(s._City))
|
||||
ret = append(ret, types.Uint16(s._FundingRounds))
|
||||
ret = append(ret, s._FoundedAt)
|
||||
ret = append(ret, s._FirstFundingAt)
|
||||
ret = append(ret, s._LastFundingAt)
|
||||
ret = append(ret, s._Rounds)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Company) Permalink() string {
|
||||
return s._Permalink
|
||||
}
|
||||
|
||||
func (s Company) SetPermalink(val string) Company {
|
||||
s._Permalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Name() string {
|
||||
return s._Name
|
||||
}
|
||||
|
||||
func (s Company) SetName(val string) Company {
|
||||
s._Name = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) HomepageUrl() string {
|
||||
return s._HomepageUrl
|
||||
}
|
||||
|
||||
func (s Company) SetHomepageUrl(val string) Company {
|
||||
s._HomepageUrl = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) CategoryList() SetOfString {
|
||||
return s._CategoryList
|
||||
}
|
||||
|
||||
func (s Company) SetCategoryList(val SetOfString) Company {
|
||||
s._CategoryList = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Market() string {
|
||||
return s._Market
|
||||
}
|
||||
|
||||
func (s Company) SetMarket(val string) Company {
|
||||
s._Market = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FundingTotalUsd() float64 {
|
||||
return s._FundingTotalUsd
|
||||
}
|
||||
|
||||
func (s Company) SetFundingTotalUsd(val float64) Company {
|
||||
s._FundingTotalUsd = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Status() string {
|
||||
return s._Status
|
||||
}
|
||||
|
||||
func (s Company) SetStatus(val string) Company {
|
||||
s._Status = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) CountryCode() string {
|
||||
return s._CountryCode
|
||||
}
|
||||
|
||||
func (s Company) SetCountryCode(val string) Company {
|
||||
s._CountryCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) StateCode() string {
|
||||
return s._StateCode
|
||||
}
|
||||
|
||||
func (s Company) SetStateCode(val string) Company {
|
||||
s._StateCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Region() string {
|
||||
return s._Region
|
||||
}
|
||||
|
||||
func (s Company) SetRegion(val string) Company {
|
||||
s._Region = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) City() string {
|
||||
return s._City
|
||||
}
|
||||
|
||||
func (s Company) SetCity(val string) Company {
|
||||
s._City = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FundingRounds() uint16 {
|
||||
return s._FundingRounds
|
||||
}
|
||||
|
||||
func (s Company) SetFundingRounds(val uint16) Company {
|
||||
s._FundingRounds = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FoundedAt() Date {
|
||||
return s._FoundedAt
|
||||
}
|
||||
|
||||
func (s Company) SetFoundedAt(val Date) Company {
|
||||
s._FoundedAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) FirstFundingAt() Date {
|
||||
return s._FirstFundingAt
|
||||
}
|
||||
|
||||
func (s Company) SetFirstFundingAt(val Date) Company {
|
||||
s._FirstFundingAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) LastFundingAt() Date {
|
||||
return s._LastFundingAt
|
||||
}
|
||||
|
||||
func (s Company) SetLastFundingAt(val Date) Company {
|
||||
s._LastFundingAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Company) Rounds() SetOfRefOfRound {
|
||||
return s._Rounds
|
||||
}
|
||||
|
||||
func (s Company) SetRounds(val SetOfRefOfRound) Company {
|
||||
s._Rounds = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Round
|
||||
|
||||
type Round struct {
|
||||
_CompanyPermalink string
|
||||
_FundingRoundPermalink string
|
||||
_FundingRoundType string
|
||||
_FundingRoundCode string
|
||||
_FundedAt Date
|
||||
_RaisedAmountUsd float64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRound() Round {
|
||||
return Round{
|
||||
_CompanyPermalink: "",
|
||||
_FundingRoundPermalink: "",
|
||||
_FundingRoundType: "",
|
||||
_FundingRoundCode: "",
|
||||
_FundedAt: NewDate(),
|
||||
_RaisedAmountUsd: float64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type RoundDef struct {
|
||||
CompanyPermalink string
|
||||
FundingRoundPermalink string
|
||||
FundingRoundType string
|
||||
FundingRoundCode string
|
||||
FundedAt DateDef
|
||||
RaisedAmountUsd float64
|
||||
}
|
||||
|
||||
func (def RoundDef) New() Round {
|
||||
return Round{
|
||||
_CompanyPermalink: def.CompanyPermalink,
|
||||
_FundingRoundPermalink: def.FundingRoundPermalink,
|
||||
_FundingRoundType: def.FundingRoundType,
|
||||
_FundingRoundCode: def.FundingRoundCode,
|
||||
_FundedAt: def.FundedAt.New(),
|
||||
_RaisedAmountUsd: def.RaisedAmountUsd,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Round) Def() (d RoundDef) {
|
||||
d.CompanyPermalink = s._CompanyPermalink
|
||||
d.FundingRoundPermalink = s._FundingRoundPermalink
|
||||
d.FundingRoundType = s._FundingRoundType
|
||||
d.FundingRoundCode = s._FundingRoundCode
|
||||
d.FundedAt = s._FundedAt.Def()
|
||||
d.RaisedAmountUsd = s._RaisedAmountUsd
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForRound types.Type
|
||||
|
||||
func (m Round) Type() types.Type {
|
||||
return __typeForRound
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRound = types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1)
|
||||
types.RegisterStruct(__typeForRound, builderForRound, readerForRound)
|
||||
}
|
||||
|
||||
func builderForRound(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Round{ref: &ref.Ref{}}
|
||||
s._CompanyPermalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundPermalink = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundType = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundingRoundCode = values[i].(types.String).String()
|
||||
i++
|
||||
s._FundedAt = values[i].(Date)
|
||||
i++
|
||||
s._RaisedAmountUsd = float64(values[i].(types.Float64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForRound(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Round)
|
||||
values = append(values, types.NewString(s._CompanyPermalink))
|
||||
values = append(values, types.NewString(s._FundingRoundPermalink))
|
||||
values = append(values, types.NewString(s._FundingRoundType))
|
||||
values = append(values, types.NewString(s._FundingRoundCode))
|
||||
values = append(values, s._FundedAt)
|
||||
values = append(values, types.Float64(s._RaisedAmountUsd))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Round) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRound.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Round) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Round) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForRound.Chunks()...)
|
||||
chunks = append(chunks, s._FundedAt.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Round) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._CompanyPermalink))
|
||||
ret = append(ret, types.NewString(s._FundingRoundPermalink))
|
||||
ret = append(ret, types.NewString(s._FundingRoundType))
|
||||
ret = append(ret, types.NewString(s._FundingRoundCode))
|
||||
ret = append(ret, s._FundedAt)
|
||||
ret = append(ret, types.Float64(s._RaisedAmountUsd))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Round) CompanyPermalink() string {
|
||||
return s._CompanyPermalink
|
||||
}
|
||||
|
||||
func (s Round) SetCompanyPermalink(val string) Round {
|
||||
s._CompanyPermalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundPermalink() string {
|
||||
return s._FundingRoundPermalink
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundPermalink(val string) Round {
|
||||
s._FundingRoundPermalink = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundType() string {
|
||||
return s._FundingRoundType
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundType(val string) Round {
|
||||
s._FundingRoundType = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundingRoundCode() string {
|
||||
return s._FundingRoundCode
|
||||
}
|
||||
|
||||
func (s Round) SetFundingRoundCode(val string) Round {
|
||||
s._FundingRoundCode = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) FundedAt() Date {
|
||||
return s._FundedAt
|
||||
}
|
||||
|
||||
func (s Round) SetFundedAt(val Date) Round {
|
||||
s._FundedAt = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Round) RaisedAmountUsd() float64 {
|
||||
return s._RaisedAmountUsd
|
||||
}
|
||||
|
||||
func (s Round) SetRaisedAmountUsd(val float64) Round {
|
||||
s._RaisedAmountUsd = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
|
||||
func (def SetOfStringDef) New() SetOfString {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
def := make(map[string]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(types.String).String()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfString.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfString.
|
||||
var __typeForSetOfString types.Type
|
||||
|
||||
func (m SetOfString) Type() types.Type {
|
||||
return __typeForSetOfString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfString = types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForSetOfString, builderForSetOfString, readerForSetOfString)
|
||||
}
|
||||
|
||||
func builderForSetOfString(v types.Value) types.Value {
|
||||
return SetOfString{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfString(v types.Value) types.Value {
|
||||
return v.(SetOfString).s
|
||||
}
|
||||
|
||||
func (s SetOfString) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfString) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfString) Has(p string) bool {
|
||||
return s.s.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
type SetOfStringIterCallback func(p string) (stop bool)
|
||||
|
||||
func (s SetOfString) Iter(cb SetOfStringIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringIterAllCallback func(p string)
|
||||
|
||||
func (s SetOfString) IterAll(cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfString) IterAllP(concurrency int, cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringFilterCallback func(p string) (keep bool)
|
||||
|
||||
func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
return SetOfString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) First() string {
|
||||
return s.s.First().(types.String).String()
|
||||
}
|
||||
|
||||
func (s SetOfString) fromStructSlice(p []SetOfString) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfString) fromElemSlice(p []string) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = types.NewString(v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// SetOfRefOfRound
|
||||
|
||||
type SetOfRefOfRound struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfRefOfRound() SetOfRefOfRound {
|
||||
return SetOfRefOfRound{types.NewTypedSet(__typeForSetOfRefOfRound), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundDef map[ref.Ref]bool
|
||||
|
||||
func (def SetOfRefOfRoundDef) New() SetOfRefOfRound {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = NewRefOfRound(d)
|
||||
i++
|
||||
}
|
||||
return SetOfRefOfRound{types.NewTypedSet(__typeForSetOfRefOfRound, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Def() SetOfRefOfRoundDef {
|
||||
def := make(map[ref.Ref]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(RefOfRound).TargetRef()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfRefOfRound.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfRefOfRound.
|
||||
var __typeForSetOfRefOfRound types.Type
|
||||
|
||||
func (m SetOfRefOfRound) Type() types.Type {
|
||||
return __typeForSetOfRefOfRound
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfRefOfRound = types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1)))
|
||||
types.RegisterValue(__typeForSetOfRefOfRound, builderForSetOfRefOfRound, readerForSetOfRefOfRound)
|
||||
}
|
||||
|
||||
func builderForSetOfRefOfRound(v types.Value) types.Value {
|
||||
return SetOfRefOfRound{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfRefOfRound(v types.Value) types.Value {
|
||||
return v.(SetOfRefOfRound).s
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Has(p RefOfRound) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundIterCallback func(p RefOfRound) (stop bool)
|
||||
|
||||
func (s SetOfRefOfRound) Iter(cb SetOfRefOfRoundIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundIterAllCallback func(p RefOfRound)
|
||||
|
||||
func (s SetOfRefOfRound) IterAll(cb SetOfRefOfRoundIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) IterAllP(concurrency int, cb SetOfRefOfRoundIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(RefOfRound))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRoundFilterCallback func(p RefOfRound) (keep bool)
|
||||
|
||||
func (s SetOfRefOfRound) Filter(cb SetOfRefOfRoundFilterCallback) SetOfRefOfRound {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRound))
|
||||
})
|
||||
return SetOfRefOfRound{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Insert(p ...RefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Remove(p ...RefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) Union(others ...SetOfRefOfRound) SetOfRefOfRound {
|
||||
return SetOfRefOfRound{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) First() RefOfRound {
|
||||
return s.s.First().(RefOfRound)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) fromStructSlice(p []SetOfRefOfRound) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRound) fromElemSlice(p []RefOfRound) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// RefOfRound
|
||||
|
||||
type RefOfRound struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfRound(target ref.Ref) RefOfRound {
|
||||
return RefOfRound{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfRound) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfRound) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfRound) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfRound.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfRound) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfRound) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfRound.
|
||||
var __typeForRefOfRound types.Type
|
||||
|
||||
func (r RefOfRound) Type() types.Type {
|
||||
return __typeForRefOfRound
|
||||
}
|
||||
|
||||
func (r RefOfRound) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfRound = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-91ae65b19b4817fc15d4e2c5c7472c68b4950b77"), 1))
|
||||
types.RegisterRef(__typeForRefOfRound, builderForRefOfRound)
|
||||
}
|
||||
|
||||
func builderForRefOfRound(r ref.Ref) types.RefBase {
|
||||
return NewRefOfRound(r)
|
||||
}
|
||||
|
||||
func (r RefOfRound) TargetValue(vr types.ValueReader) Round {
|
||||
return vr.ReadValue(r.target).(Round)
|
||||
}
|
||||
7
clients/crunchbase/ui/.gitignore
vendored
7
clients/crunchbase/ui/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
.babelrc
|
||||
.flowconfig
|
||||
node_modules
|
||||
out.js
|
||||
nvd3.css
|
||||
nvd3.js
|
||||
d3.js
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os, subprocess, sys, shutil
|
||||
|
||||
SRC = ['babel-regenerator-runtime', 'src/main.js']
|
||||
OUT = 'out.js'
|
||||
|
||||
def main():
|
||||
env = os.environ
|
||||
env['NODE_ENV'] = sys.argv[1]
|
||||
env['BABEL_ENV'] = sys.argv[1]
|
||||
if 'NOMS_SERVER' not in env:
|
||||
env['NOMS_SERVER'] = 'http://localhost:8000'
|
||||
if 'NOMS_DATASET_ID' not in env:
|
||||
env['NOMS_DATASET_ID'] = 'crunchbase/index'
|
||||
|
||||
if sys.argv[1] == 'production':
|
||||
shutil.copyfile('node_modules/nvd3/build/nv.d3.min.css', 'nvd3.css')
|
||||
shutil.copyfile('node_modules/nvd3/build/nv.d3.min.js', 'nvd3.js')
|
||||
shutil.copyfile('node_modules/d3/d3.min.js', 'd3.js')
|
||||
else:
|
||||
shutil.copyfile('node_modules/nvd3/build/nv.d3.css', 'nvd3.css')
|
||||
shutil.copyfile('node_modules/nvd3/build/nv.d3.js', 'nvd3.js')
|
||||
shutil.copyfile('node_modules/d3/d3.js', 'd3.js')
|
||||
|
||||
subprocess.check_call(['node_modules/.bin/webpack'] + SRC + [OUT], env=env, shell=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,39 +0,0 @@
|
||||
# Crunchbase UI
|
||||
|
||||
This is a landing page and visualization for the crunchbase dataset.
|
||||
|
||||
## Setup
|
||||
|
||||
Before you can run the UI, you must import and index the dataset it relies on:
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/crunchbase/importer
|
||||
go build
|
||||
./importer -ldb="/tmp/crunchbasedemo" -ds="crunchbase/raw" "<url-to-crunchbase-spreadsheet>"
|
||||
|
||||
cd ../index
|
||||
go build
|
||||
./index -ldb="/tmp/crunchbasedemo" -in="crunchbase/raw" -out="crunchbase/index"
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/server
|
||||
go build
|
||||
./server -ldb="/tmp/crunchbasedemo"
|
||||
|
||||
cd ../ui
|
||||
./build.py
|
||||
./node_modules/.bin/http-server
|
||||
```
|
||||
|
||||
Then, navigate to [http://localhost:8080](http://localhost:8080).
|
||||
|
||||
|
||||
## Develop
|
||||
|
||||
* `./build.py` # only necessary first time
|
||||
* `NOMS_SERVER="http://localhost:8000" NOMS_DATASET_ID="crunchbase/index" npm run start`
|
||||
|
||||
This will start watchify which is continually building a non-minified (and thus debuggable) build.
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os, os.path, subprocess, sys
|
||||
|
||||
sys.path.append(os.path.abspath('../../../tools'))
|
||||
|
||||
import noms.symlink as symlink
|
||||
|
||||
def main():
|
||||
symlink.Force('../../../js/.babelrc', os.path.abspath('.babelrc'))
|
||||
symlink.Force('../../../js/.flowconfig', os.path.abspath('.flowconfig'))
|
||||
|
||||
subprocess.check_call(['npm', 'install'], shell=False)
|
||||
env = {
|
||||
'NOMS_SERVER': 'http://localhost:8000',
|
||||
'NOMS_DATASET_ID': 'crunchbase/index',
|
||||
}.update(os.environ)
|
||||
subprocess.check_call(['npm', 'run', 'build'], env=env, shell=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,31 +0,0 @@
|
||||
<!doctype html>
|
||||
<title>noms.io ➟ nerdosphere</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600" rel="stylesheet">
|
||||
<link href="nvd3.css" rel="stylesheet">
|
||||
<link href="styles.css" rel="stylesheet">
|
||||
<script src="d3.js"></script>
|
||||
<script src="nvd3.js"></script>
|
||||
<script src="out.js"></script>
|
||||
|
||||
<div id="masthead">
|
||||
<h1><span class="thin">noms.io <span style="position:relative; top:0.05em;">→</span> </span>nerdosphere</h1>
|
||||
</div>
|
||||
|
||||
<div id="app"></div>
|
||||
|
||||
<h2 style="margin-top:0">About this dataset</h2>
|
||||
|
||||
<p>The nerdosphere dataset is imported montly from the <a href="http://data.crunchbase.com/v3/page/crunchbase-data-exports">CrunchBase Excel Data Export</a>, which is in turned based on crowdsourced data from <a href="http://www.crunchbase.com/">CrunchBase</a>.
|
||||
|
||||
<p>This graph shows the distribution of venture capital funding rounds by funding series. The x-axis shows the rounds in increasing order. The y-axis is the amount of USD raised in that round.
|
||||
|
||||
<h2>Get the data</h2>
|
||||
|
||||
<pre>go get https://github.com/attic-labs/noms/...
|
||||
go install $GOROOT/src/github.com/attic-labs/noms/clients/shove
|
||||
./shove -source-h="https://ds.noms.io" -source-ds="nerdosphere" -sink-ldb="/tmp/nerdosphere" -sink-ds="nerdosphere"</pre>
|
||||
|
||||
<h2>Get the analyses</h2>
|
||||
|
||||
<pre>go get https://github.com/attic-labs/noms/...
|
||||
cd $GOROOT/src/github.com/attic-labs/noms/clients/crunchbase/ui</pre>
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "noms-crunchbase-ui",
|
||||
"devDependencies": {
|
||||
"@attic/eslintrc": "^1.0.0",
|
||||
"@attic/noms": "^11.1.0",
|
||||
"@attic/webpack-config": "^1.0.1",
|
||||
"babel-cli": "6.6.5",
|
||||
"babel-core": "6.7.2",
|
||||
"babel-generator": "6.7.2",
|
||||
"babel-plugin-syntax-async-functions": "6.5.0",
|
||||
"babel-plugin-syntax-flow": "6.5.0",
|
||||
"babel-plugin-transform-async-to-generator": "6.7.0",
|
||||
"babel-plugin-transform-class-properties": "6.6.0",
|
||||
"babel-plugin-transform-es2015-destructuring": "6.6.5",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "6.7.0",
|
||||
"babel-plugin-transform-es2015-parameters": "6.7.0",
|
||||
"babel-plugin-transform-runtime": "^6.6.0",
|
||||
"babel-preset-es2015": "6.6.0",
|
||||
"babel-preset-react": "6.5.0",
|
||||
"babel-regenerator-runtime": "6.5.0",
|
||||
"d3": "^3.4.4",
|
||||
"flow-bin": "^0.23.0",
|
||||
"http-server": "^0.8.5",
|
||||
"nvd3": "1.8.2",
|
||||
"react-dom": "^0.14.1",
|
||||
"react": "^0.14.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "python .npm_build_helper.py development",
|
||||
"build": "python .npm_build_helper.py production",
|
||||
"test": "eslint src/ && flow src/"
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import type {DataArray} from './data.js';
|
||||
|
||||
declare var d3;
|
||||
declare var nv;
|
||||
|
||||
type Props = {
|
||||
data: DataArray,
|
||||
color?: Array<string>
|
||||
};
|
||||
|
||||
type State = {
|
||||
chart: ?Object
|
||||
};
|
||||
|
||||
export default class Chart extends React.Component<void, Props, State> {
|
||||
state: State;
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
chart: null,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
nv.addGraph(() => {
|
||||
const chart = nv.models.lineChart();
|
||||
chart.options({
|
||||
clipEdge: true,
|
||||
color: this.props.color,
|
||||
interpolate: 'basis',
|
||||
isArea: true,
|
||||
showControls: false,
|
||||
showLegend: false,
|
||||
useInteractiveGuideline: true,
|
||||
});
|
||||
|
||||
chart.yScale(d3.scale.log());
|
||||
const d3Format = d3.format('.2s');
|
||||
const format = v => '$' + d3Format(v).toUpperCase().replace('G', 'B');
|
||||
chart.yAxis.tickValues([1e4, 1e5, 1e6, 1e7, 1e8, 1e9]);
|
||||
chart.yAxis.tickFormat(format);
|
||||
chart.yDomain([1e3, 1e9]);
|
||||
chart.xAxis.tickFormat(v => (v * 100 | 0) + '%');
|
||||
|
||||
const div = ReactDOM.findDOMNode(this);
|
||||
d3.select(div.firstChild).datum(this.props.data).call(chart);
|
||||
nv.utils.windowResize(() => chart.update());
|
||||
this.setState({chart});
|
||||
});
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const chart = this.state.chart;
|
||||
if (chart) {
|
||||
const svg = ReactDOM.findDOMNode(this);
|
||||
d3.select(svg).datum(this.props.data).call(chart);
|
||||
}
|
||||
}
|
||||
|
||||
render(): React.Element {
|
||||
return <svg/>;
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
// @flow
|
||||
|
||||
import {
|
||||
createStructClass,
|
||||
Dataset,
|
||||
DataStore,
|
||||
invariant,
|
||||
makeRefType,
|
||||
makeSetType,
|
||||
makeType,
|
||||
newSet,
|
||||
NomsMap,
|
||||
NomsSet,
|
||||
notNull,
|
||||
RefValue,
|
||||
registerPackage,
|
||||
Struct,
|
||||
valueType,
|
||||
} from '@attic/noms';
|
||||
import type {Commit, Package} from '@attic/noms';
|
||||
|
||||
type RoundTypeEnum = 0 | 1 | 2;
|
||||
const Seed = 0;
|
||||
const SeriesA = 1;
|
||||
const SeriesB = 2;
|
||||
|
||||
type QuarterEnum = 0 | 1 | 2 | 3;
|
||||
|
||||
type KeyParam = {
|
||||
Year: number,
|
||||
Quarter?: QuarterEnum
|
||||
} | {
|
||||
Category: string
|
||||
} | {
|
||||
RoundType: RoundTypeEnum
|
||||
};
|
||||
|
||||
type TimeOption = {
|
||||
Year: number,
|
||||
Quarter?: QuarterEnum
|
||||
};
|
||||
|
||||
type DataPoint = {x: number, y: number};
|
||||
type DataEntry = {values: Array<DataPoint>, key: string, color?: string};
|
||||
export type DataArray = Array<DataEntry>;
|
||||
|
||||
export default class DataManager {
|
||||
_dataset: Dataset;
|
||||
_keyClass: ?Class<Struct>;
|
||||
_quarterClass: ?Class<Struct>;
|
||||
_indexP: Promise<NomsMap>;
|
||||
_packageP: ?Promise<Package>;
|
||||
|
||||
_categorySetP: ?Promise<NomsSet<RefValue>>;
|
||||
_timeSetP: ?Promise<NomsSet<RefValue>>;
|
||||
_seedSetP: ?Promise<NomsSet<RefValue>>;
|
||||
_seriesASetP: ?Promise<NomsSet<RefValue>>;
|
||||
_seriesBSetP: ?Promise<NomsSet<RefValue>>;
|
||||
|
||||
_data: ?DataArray;
|
||||
_time: ?TimeOption;
|
||||
_category: string;
|
||||
|
||||
constructor(dataset: Dataset) {
|
||||
this._dataset = dataset;
|
||||
this._indexP = this._dataset.head().then((commit: ?Commit) => {
|
||||
const v = notNull(commit).value;
|
||||
invariant(v instanceof NomsMap);
|
||||
return v;
|
||||
});
|
||||
|
||||
this._keyClass = null;
|
||||
this._quarterClass = null;
|
||||
this._packageP = null;
|
||||
|
||||
this._timeSetP = null;
|
||||
this._categorySetP = null;
|
||||
this._seedSetP = null;
|
||||
this._seriesASetP = null;
|
||||
this._seriesBSetP = null;
|
||||
|
||||
this._data = null;
|
||||
this._time = null;
|
||||
this._category = '';
|
||||
}
|
||||
|
||||
async _getPackage(): Promise<Package> {
|
||||
if (this._packageP) {
|
||||
return this._packageP;
|
||||
}
|
||||
|
||||
const index = await this._indexP;
|
||||
this._packageP = getKeyPackage(index, this._dataset.store);
|
||||
return this._packageP;
|
||||
}
|
||||
|
||||
async _getKeyClass(): Promise<any> {
|
||||
if (this._keyClass) return this._keyClass;
|
||||
const pkg = await this._getPackage();
|
||||
return this._keyClass = getStructClass(pkg, 'Key');
|
||||
}
|
||||
|
||||
async _getQuarterClass(): Promise<any> {
|
||||
if (this._quarterClass) return this._quarterClass;
|
||||
const pkg = await this._getPackage();
|
||||
return this._quarterClass = getStructClass(pkg, 'Quarter');
|
||||
}
|
||||
|
||||
_setTime(time: TimeOption) {
|
||||
const t = this._time;
|
||||
if (!t || t.Year !== time.Year || t.Quarter !== time.Quarter) {
|
||||
this._time = time;
|
||||
this._timeSetP = this._getSetOfRounds(time);
|
||||
this._data = null;
|
||||
}
|
||||
}
|
||||
|
||||
_setCategory(category: string) {
|
||||
if (this._category !== category) {
|
||||
this._category = category;
|
||||
this._categorySetP = this._getSetOfRounds({Category: category});
|
||||
this._data = null;
|
||||
}
|
||||
}
|
||||
|
||||
_createRounds() {
|
||||
this._seedSetP = this._getSetOfRounds({RoundType: Seed});
|
||||
this._seriesASetP = this._getSetOfRounds({RoundType: SeriesA});
|
||||
this._seriesBSetP = this._getSetOfRounds({RoundType: SeriesB});
|
||||
}
|
||||
|
||||
async getData(time: TimeOption, category: string): any {
|
||||
if (!this._seedSetP) {
|
||||
this._createRounds();
|
||||
}
|
||||
|
||||
this._setTime(time);
|
||||
this._setCategory(category);
|
||||
|
||||
if (this._data) return this._data;
|
||||
|
||||
invariant(this._seedSetP && this._seriesASetP && this._seriesBSetP &&
|
||||
this._timeSetP && this._categorySetP);
|
||||
const [seedSet, seriesASet, seriesBSet, timeSet, categorySet] =
|
||||
await Promise.all([this._seedSetP, this._seriesASetP, this._seriesBSetP,
|
||||
this._timeSetP, this._categorySetP]);
|
||||
|
||||
const store = this._dataset.store;
|
||||
const getAmountRaised = (r: RefValue): Promise<number> =>
|
||||
store.readValue(r.targetRef).then(round => round.get('RaisedAmountUsd'));
|
||||
|
||||
const [seedData, seriesAData, seriesBData] = await Promise.all([
|
||||
seedSet.intersect(categorySet, timeSet).then(set => set.map(getAmountRaised)),
|
||||
seriesASet.intersect(categorySet, timeSet).then(set => set.map(getAmountRaised)),
|
||||
seriesBSet.intersect(categorySet, timeSet).then(set => set.map(getAmountRaised)),
|
||||
]);
|
||||
|
||||
return this._data = [
|
||||
{
|
||||
values: percentiles(seedData),
|
||||
key: 'Seed',
|
||||
},
|
||||
{
|
||||
values: percentiles(seriesAData),
|
||||
key: 'A',
|
||||
},
|
||||
{
|
||||
values: percentiles(seriesBData),
|
||||
key: 'B',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async _getKeyRef(p: KeyParam): Promise<RefValue> {
|
||||
const Key = await this._getKeyClass();
|
||||
let k;
|
||||
if (p.Quarter !== undefined) {
|
||||
const Quarter = await this._getQuarterClass();
|
||||
k = new Key({Quarter: new Quarter(p)});
|
||||
} else {
|
||||
k = new Key(p);
|
||||
}
|
||||
return new RefValue(k.ref, makeRefType(k.type));
|
||||
}
|
||||
|
||||
async _getSetOfRounds(p: KeyParam): Promise<NomsSet<RefValue>> {
|
||||
const [r, index] = await Promise.all([this._getKeyRef(p), this._indexP]);
|
||||
const set = await index.get(r);
|
||||
if (set === undefined) {
|
||||
return newSet([], setType);
|
||||
}
|
||||
|
||||
invariant(set);
|
||||
// Update the type to something that is correct.
|
||||
// An alternative would be to hardcode the ref/ordinal.
|
||||
setType = set.type;
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This is actually the wrong type. Fix when we have JS codegen.
|
||||
let setType = makeSetType(makeRefType(valueType));
|
||||
|
||||
/**
|
||||
* Loads the first key in the index and gets the package from the type.
|
||||
*/
|
||||
async function getKeyPackage(index: NomsMap<RefValue, NomsSet<RefValue>>, store: DataStore):
|
||||
Promise<Package> {
|
||||
const kv = await index.first();
|
||||
invariant(kv);
|
||||
const ref = kv[0];
|
||||
const key: Struct = await store.readValue(ref.targetRef);
|
||||
invariant(key);
|
||||
const pkg: Package = await store.readValue(key.type.packageRef);
|
||||
invariant(pkg);
|
||||
registerPackage(pkg);
|
||||
return pkg;
|
||||
}
|
||||
|
||||
function getStructClass(pkg, name) {
|
||||
const keyIndex = pkg.types.findIndex(t => t.name === name);
|
||||
const type = makeType(pkg.ref, keyIndex);
|
||||
const typeDef = pkg.types[keyIndex];
|
||||
return createStructClass(type, typeDef);
|
||||
}
|
||||
|
||||
function percentiles(s: Array<number>): Array<{x: number, y: number}> {
|
||||
const arr: Array<number> = [];
|
||||
s.forEach(v => {
|
||||
if (v > 0) {
|
||||
arr.push(v);
|
||||
}
|
||||
});
|
||||
|
||||
arr.sort((a, b) => a - b);
|
||||
const len = arr.length;
|
||||
if (len === 0) {
|
||||
return [];
|
||||
}
|
||||
if (len === 1) {
|
||||
return [{x: 0, y: arr[0]}, {x: 1, y: arr[0]}];
|
||||
}
|
||||
return arr.map((y, i) => {
|
||||
const x = i / (len - 1);
|
||||
return {x, y};
|
||||
});
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
|
||||
type Props<T> = {
|
||||
delegate: ListDelegate<T>,
|
||||
items: Array<T>,
|
||||
title?: string
|
||||
};
|
||||
|
||||
export default function List<T>(props: Props<T>) : React.Element {
|
||||
const delegate = props.delegate;
|
||||
const labels = props.items.map(item =>
|
||||
<Label key={delegate.getLabel(item)} item={item} delegate={delegate}/>);
|
||||
return <div className='selection-list'>
|
||||
{props.title ? <h3>{props.title}</h3> : null}
|
||||
{labels}
|
||||
</div>;
|
||||
}
|
||||
|
||||
type LabelProps<T> = {
|
||||
item: T,
|
||||
delegate: ListDelegate<T>
|
||||
};
|
||||
|
||||
export type ListDelegate<T> = {
|
||||
getLabel: (item: T) => string,
|
||||
isSelected: (item: T) => boolean,
|
||||
getColor?: (item: T) => string,
|
||||
onChange: (item: T) => void
|
||||
};
|
||||
|
||||
function Label(props: LabelProps) : React.Element {
|
||||
const {delegate, item} = props;
|
||||
return <label><input type="checkbox"
|
||||
checked={delegate.isSelected(item)}
|
||||
onChange={() => delegate.onChange(item)}/>
|
||||
<span style={{color: delegate.getColor && delegate.getColor(item)}}/>
|
||||
<span>{delegate.getLabel(item)}</span>
|
||||
</label>;
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
// @flow
|
||||
import {DataStore, Dataset, HttpStore} from '@attic/noms';
|
||||
import Chart from './chart.js';
|
||||
import DataManager from './data.js';
|
||||
import List from './list.js';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import type {DataArray} from './data.js';
|
||||
import type {ListDelegate} from './list.js';
|
||||
|
||||
type LabelAndKey = {
|
||||
label: string,
|
||||
key: Object,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
series: Array<string>,
|
||||
timeItems: Array<LabelAndKey>,
|
||||
categories: Array<string>,
|
||||
color: Array<string>,
|
||||
};
|
||||
|
||||
type State = {
|
||||
selectedSeries: Set<string>,
|
||||
selectedTimeItem: LabelAndKey,
|
||||
selectedCategoryItem: string,
|
||||
data: DataArray,
|
||||
};
|
||||
|
||||
const nomsServer: ?string = process.env.NOMS_SERVER;
|
||||
if (!nomsServer) {
|
||||
throw new Error('NOMS_SERVER not set');
|
||||
}
|
||||
const datasetId: ?string = process.env.NOMS_DATASET_ID;
|
||||
if (!datasetId) {
|
||||
throw new Error('NOMS_DATASET_ID not set');
|
||||
}
|
||||
|
||||
class Main extends React.Component<void, Props, State> {
|
||||
state: State;
|
||||
_dataManager: DataManager;
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
const selectedTimeItem = props.timeItems[0];
|
||||
const selectedCategoryItem = props.categories[0];
|
||||
|
||||
const datastore = new DataStore(new HttpStore(nomsServer), 1e5);
|
||||
const dataset = new Dataset(datastore, datasetId);
|
||||
this._dataManager = new DataManager(dataset);
|
||||
|
||||
this.state = {
|
||||
selectedSeries: new Set(this.props.series),
|
||||
selectedTimeItem,
|
||||
selectedCategoryItem,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State) : boolean {
|
||||
return nextProps !== this.props ||
|
||||
nextState.selectedSeries !== this.state.selectedSeries ||
|
||||
nextState.selectedTimeItem !== this.state.selectedTimeItem ||
|
||||
nextState.selectedCategoryItem !== this.state.selectedCategoryItem ||
|
||||
nextState.data !== this.state.data;
|
||||
}
|
||||
|
||||
_filteredData(): DataArray {
|
||||
return this.state.data.filter(o => this.state.selectedSeries.has(o.key));
|
||||
}
|
||||
|
||||
_selectedSeriesChanged(s: Set<string>) {
|
||||
this.setState({selectedSeries: s});
|
||||
}
|
||||
|
||||
_selectedTimeChanged(item: LabelAndKey) {
|
||||
this.setState({selectedTimeItem: item});
|
||||
}
|
||||
|
||||
_selectedCategoryChanged(s: string) {
|
||||
this.setState({selectedCategoryItem: s});
|
||||
}
|
||||
|
||||
render(): React.Element {
|
||||
const s = this.state;
|
||||
const dm = this._dataManager;
|
||||
dm.getData(s.selectedTimeItem.key, s.selectedCategoryItem).then(data => {
|
||||
this.setState({data});
|
||||
}).catch(ex => {
|
||||
console.error(ex); // eslint-disable-line
|
||||
});
|
||||
|
||||
const seriesDelegate: ListDelegate<string> = {
|
||||
getLabel(item: string): string {
|
||||
return item;
|
||||
},
|
||||
isSelected: (item: string) => this.state.selectedSeries.has(item),
|
||||
getColor: (item: string) => this.props.color[this.props.series.indexOf(item)],
|
||||
onChange: (item: string) => {
|
||||
const selectedSeries = new Set(this.state.selectedSeries);
|
||||
if (selectedSeries.has(item)) {
|
||||
selectedSeries.delete(item);
|
||||
} else {
|
||||
selectedSeries.add(item);
|
||||
}
|
||||
this.setState({selectedSeries});
|
||||
},
|
||||
};
|
||||
|
||||
const timeDelegate: ListDelegate<LabelAndKey> = {
|
||||
getLabel(item: LabelAndKey): string {
|
||||
return item.label;
|
||||
},
|
||||
isSelected: (item: LabelAndKey) => item === this.state.selectedTimeItem,
|
||||
onChange: (item: LabelAndKey) => {
|
||||
this._selectedTimeChanged(item);
|
||||
},
|
||||
};
|
||||
|
||||
const categoryDelegate: ListDelegate<string> = {
|
||||
getLabel(item: string): string {
|
||||
return item;
|
||||
},
|
||||
isSelected: (item: string) => item === this.state.selectedCategoryItem,
|
||||
onChange: (item: string) => {
|
||||
this._selectedCategoryChanged(item);
|
||||
},
|
||||
};
|
||||
|
||||
return <div className='app'>
|
||||
<div>
|
||||
<Chart className='app-chart' data={this._filteredData()}
|
||||
color={this.props.color}/>
|
||||
<div className='app-controls'>
|
||||
<List title='Series' items={this.props.series}
|
||||
delegate={seriesDelegate}/>
|
||||
<List title='Time' items={this.props.timeItems}
|
||||
delegate={timeDelegate}/>
|
||||
<List title='Categories' items={this.props.categories}
|
||||
delegate={categoryDelegate}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const series = ['Seed', 'A', 'B'];
|
||||
|
||||
// Hardcode the time.
|
||||
const year = 2015;
|
||||
const qYear = 2105;
|
||||
const quarter = 2;
|
||||
const timeItems = [
|
||||
{label: '2015', key: {Year: year}},
|
||||
{label: '2015 Q2', key: {Year: qYear, Quarter: quarter}},
|
||||
];
|
||||
|
||||
const categories = [
|
||||
'Biotechnology',
|
||||
'Finance',
|
||||
'Games',
|
||||
'Software',
|
||||
];
|
||||
|
||||
const color = ['#011f4b', '#03396c', '#005b96'];
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
ReactDOM.render(
|
||||
<Main series={series} timeItems={timeItems} categories={categories}
|
||||
color={color}/>,
|
||||
document.querySelector('#app'));
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import noms.staging as staging
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
staging.Main('nerdosphere', staging.GlobCopier('*.js', '*.html', '*.css', '*.png'))
|
||||
@@ -1,126 +0,0 @@
|
||||
body {
|
||||
background: white;
|
||||
color: black;
|
||||
font-family: helvetica, sans-serif;
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
#masthead {
|
||||
margin-left:-0.2em;
|
||||
margin-top: -0.5em;
|
||||
padding: 1em 100px;
|
||||
background-image: url(cookie.png);
|
||||
background-position: center left;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
border-bottom: 1px solid #ccc;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 1.25em;
|
||||
display: inline;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1>.thin {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 1.35em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
pre {
|
||||
border: 1px solid #ccc;
|
||||
padding: 0.5em;
|
||||
line-height: 1.7em;
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #FF4515;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #cc2505;
|
||||
}
|
||||
|
||||
.selection-list {
|
||||
font-size: 12px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.selection-list > h3{
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.selection-list > label {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
margin: 2px 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selection-list > label > input {
|
||||
/* Hide real checkbox */
|
||||
position: absolute;
|
||||
clip: rect(0 0 0 0);
|
||||
}
|
||||
|
||||
.selection-list > label > input + span {
|
||||
border-radius: 6px;
|
||||
border: 2px solid currentColor;
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
height: 12px;
|
||||
margin-right: 2px;
|
||||
padding: 0;
|
||||
transition: .15s border-width;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.selection-list > label > input:focus + span {
|
||||
box-shadow: 0 0 5px #555;
|
||||
}
|
||||
|
||||
.selection-list > label > :checked + span {
|
||||
border: 6px solid currentColor;
|
||||
}
|
||||
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.app > div > svg {
|
||||
flex: 1;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.app-controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 15px;
|
||||
margin-right: 1.5em;
|
||||
}
|
||||
|
||||
.app > div {
|
||||
align-items: stretch;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.app .nvd3 text {
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = require('@attic/webpack-config').configure({
|
||||
requiredEnvVars: ['NOMS_SERVER', 'NOMS_DATASET_ID'],
|
||||
});
|
||||
1
clients/facebook/.gitignore
vendored
1
clients/facebook/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
facebook
|
||||
@@ -1,205 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/util/http/retry"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
const facebookAPI = "https://graph.facebook.com/"
|
||||
|
||||
var (
|
||||
authHTTPClient *http.Client
|
||||
cachingHTTPClient *http.Client
|
||||
clientFlags = util.NewFlags() // TODO: respect Concurrency()
|
||||
ds *dataset.Dataset
|
||||
start time.Time
|
||||
tokenFlag = flag.String("token", "", "Facebook auth token (required) - see usage for instructions")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
cachingHTTPClient = util.CachingHttpClient()
|
||||
|
||||
if *tokenFlag == "" || cachingHTTPClient == nil {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
ds = clientFlags.CreateDataset()
|
||||
if ds == nil {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
if err := clientFlags.CreateProgressFile(); err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
defer clientFlags.CloseProgressFile()
|
||||
}
|
||||
|
||||
token := oauth2.Token{AccessToken: *tokenFlag}
|
||||
authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))
|
||||
|
||||
start = time.Now()
|
||||
var user = getUser()
|
||||
printStats(user)
|
||||
|
||||
userRef := ds.Store().WriteValue(user)
|
||||
fmt.Printf("userRef: %s\n", userRef.TargetRef())
|
||||
_, err := ds.Commit(userRef)
|
||||
d.Exp.NoError(err)
|
||||
}
|
||||
|
||||
func usage() {
|
||||
credentialSteps := `To get an oauth token:
|
||||
1. Browse to: https://developers.facebook.com/tools/explorer/
|
||||
2. Login with your Facebook credentialSteps
|
||||
3. In the 'Get Token' dropdown menu, select 'Get User Access Token'
|
||||
4. Copy the Access Token from the textbox
|
||||
`
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
fmt.Fprintf(os.Stderr, "\n%s\n\n", credentialSteps)
|
||||
}
|
||||
|
||||
func getUser() User {
|
||||
uj := UserJSON{}
|
||||
callFacebookAPI(authHTTPClient, facebookAPI+"v2.5/me", &uj)
|
||||
return NewUser().
|
||||
SetId(uj.ID).
|
||||
SetName(uj.Name).
|
||||
SetPhotos(getPhotos())
|
||||
}
|
||||
|
||||
func getPhotos() SetOfRefOfRemotePhoto {
|
||||
// Get the number of photos via the list of albums, so that we can show progress. This appears to
|
||||
// be the fastest way (photos only let you paginate).
|
||||
alj := AlbumListJSON{}
|
||||
callFacebookAPI(authHTTPClient, facebookAPI+"v2.5/me/albums?limit=1000&fields=count", &alj)
|
||||
numPhotos := 0
|
||||
for _, a := range alj.Data {
|
||||
numPhotos += a.Count
|
||||
}
|
||||
|
||||
photos := NewSetOfRefOfRemotePhoto()
|
||||
url := facebookAPI + "v2.5/me/photos/uploaded?limit=1000&fields=place,name,created_time,images,tags{x,y,name}&date_format=U"
|
||||
|
||||
numFetched := 0
|
||||
for url != "" {
|
||||
plj := PhotoListJSON{}
|
||||
callFacebookAPI(authHTTPClient, url, &plj)
|
||||
for _, entry := range plj.Data {
|
||||
photo := RemotePhotoDef{
|
||||
Id: entry.Id,
|
||||
Title: entry.Name,
|
||||
Date: DateDef{MsSinceEpoch: int64(entry.CreatedTime) * 1000},
|
||||
Geoposition: GeopositionDef{
|
||||
Latitude: entry.Place.Location.Latitude,
|
||||
Longitude: entry.Place.Location.Longitude,
|
||||
},
|
||||
}.New()
|
||||
|
||||
photo = photo.SetSizes(getSizes(entry.Images))
|
||||
photo = photo.SetFaces(getFaces(entry.Tags,
|
||||
float32(entry.Images[0].Width),
|
||||
float32(entry.Images[0].Height)))
|
||||
|
||||
photos = photos.Insert(ds.Store().WriteValue(photo).(RefOfRemotePhoto))
|
||||
|
||||
numFetched++
|
||||
// Be defensive and use Min(1.0) here - the user might have more than 1000 albums, or they
|
||||
// might have uploded more photos since we got the album count.
|
||||
clientFlags.UpdateProgress(float32(math.Min(1.0, float64(numFetched)/float64(numPhotos))))
|
||||
}
|
||||
|
||||
url = plj.Paging.Next
|
||||
}
|
||||
|
||||
return photos
|
||||
}
|
||||
|
||||
func getSizes(images []ImageJSON) (result MapOfSizeToString) {
|
||||
result = NewMapOfSizeToString()
|
||||
for _, img := range images {
|
||||
result = result.Set(
|
||||
SizeDef{Width: img.Width, Height: img.Height}.New(),
|
||||
img.Source)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getFaces(tags TagListJSON, width, height float32) (result SetOfFace) {
|
||||
// Facebook sadly doesn't give us the bounding box, only the center point.
|
||||
// We could fix this by using OpenCV to do face detection, and then matching the found rectangles with the data from FB.
|
||||
// See: https://github.com/lazywei/go-opencv
|
||||
// But for now, we assert that the bounding boxes are always 20% of the longer edge of the image.
|
||||
const faceSize = 0.2
|
||||
var faceW, faceH float32
|
||||
if width > height {
|
||||
faceW = faceSize
|
||||
faceH = height / width * faceSize
|
||||
} else {
|
||||
faceH = faceSize
|
||||
faceW = width / height * faceSize
|
||||
}
|
||||
|
||||
result = NewSetOfFace()
|
||||
for _, tag := range tags.Data {
|
||||
if tag.X == 0 && tag.Y == 0 {
|
||||
continue
|
||||
}
|
||||
result = result.Insert(FaceDef{
|
||||
Top: tag.Y/100 - (faceH / 2),
|
||||
Left: tag.X/100 - (faceW / 2),
|
||||
Width: faceW,
|
||||
Height: faceH,
|
||||
PersonName: tag.Name,
|
||||
}.New())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func printStats(user User) {
|
||||
fmt.Printf("Imported %d photo(s), time: %.2f\n", user.Photos().Len(), time.Now().Sub(start).Seconds())
|
||||
}
|
||||
|
||||
func callFacebookAPI(client *http.Client, url string, response interface{}) {
|
||||
fmt.Printf("Fetching %s...\n", url)
|
||||
resp := retry.Request(url, func() (*http.Response, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
d.Chk.NoError(err)
|
||||
return client.Do(req)
|
||||
})
|
||||
|
||||
msg := func() string {
|
||||
body := &bytes.Buffer{}
|
||||
_, err := io.Copy(body, resp.Body)
|
||||
d.Chk.NoError(err)
|
||||
return fmt.Sprintf("could not load %s: %d: %s", url, resp.StatusCode, body)
|
||||
}
|
||||
|
||||
switch resp.StatusCode / 100 {
|
||||
case 4:
|
||||
d.Exp.Fail(msg())
|
||||
case 5:
|
||||
d.Chk.Fail(msg())
|
||||
}
|
||||
|
||||
err := json.NewDecoder(resp.Body).Decode(response)
|
||||
d.Chk.NoError(err)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
alias Img = import "../common/photo.noms"
|
||||
|
||||
struct User {
|
||||
Id: String
|
||||
Name: String
|
||||
Photos: Set<Ref<Img.RemotePhoto>>
|
||||
}
|
||||
|
||||
using Ref<User>
|
||||
@@ -1,411 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("User",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Name", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Photos", types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// User
|
||||
|
||||
type User struct {
|
||||
_Id string
|
||||
_Name string
|
||||
_Photos SetOfRefOfRemotePhoto
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewUser() User {
|
||||
return User{
|
||||
_Id: "",
|
||||
_Name: "",
|
||||
_Photos: NewSetOfRefOfRemotePhoto(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type UserDef struct {
|
||||
Id string
|
||||
Name string
|
||||
Photos SetOfRefOfRemotePhotoDef
|
||||
}
|
||||
|
||||
func (def UserDef) New() User {
|
||||
return User{
|
||||
_Id: def.Id,
|
||||
_Name: def.Name,
|
||||
_Photos: def.Photos.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s User) Def() (d UserDef) {
|
||||
d.Id = s._Id
|
||||
d.Name = s._Name
|
||||
d.Photos = s._Photos.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForUser types.Type
|
||||
|
||||
func (m User) Type() types.Type {
|
||||
return __typeForUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForUser = types.MakeType(ref.Parse("sha1-39235efebdcbd71e886e3f020fa0e4e683f31a63"), 0)
|
||||
types.RegisterStruct(__typeForUser, builderForUser, readerForUser)
|
||||
}
|
||||
|
||||
func builderForUser(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := User{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Name = values[i].(types.String).String()
|
||||
i++
|
||||
s._Photos = values[i].(SetOfRefOfRemotePhoto)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForUser(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(User)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Name))
|
||||
values = append(values, s._Photos)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s User) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForUser.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s User) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s User) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForUser.Chunks()...)
|
||||
chunks = append(chunks, s._Photos.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Name))
|
||||
ret = append(ret, s._Photos)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s User) SetId(val string) User {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Name() string {
|
||||
return s._Name
|
||||
}
|
||||
|
||||
func (s User) SetName(val string) User {
|
||||
s._Name = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Photos() SetOfRefOfRemotePhoto {
|
||||
return s._Photos
|
||||
}
|
||||
|
||||
func (s User) SetPhotos(val SetOfRefOfRemotePhoto) User {
|
||||
s._Photos = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// RefOfUser
|
||||
|
||||
type RefOfUser struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfUser(target ref.Ref) RefOfUser {
|
||||
return RefOfUser{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfUser) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfUser.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfUser) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfUser) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfUser.
|
||||
var __typeForRefOfUser types.Type
|
||||
|
||||
func (r RefOfUser) Type() types.Type {
|
||||
return __typeForRefOfUser
|
||||
}
|
||||
|
||||
func (r RefOfUser) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfUser = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-39235efebdcbd71e886e3f020fa0e4e683f31a63"), 0))
|
||||
types.RegisterRef(__typeForRefOfUser, builderForRefOfUser)
|
||||
}
|
||||
|
||||
func builderForRefOfUser(r ref.Ref) types.RefBase {
|
||||
return NewRefOfUser(r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetValue(vr types.ValueReader) User {
|
||||
return vr.ReadValue(r.target).(User)
|
||||
}
|
||||
|
||||
// SetOfRefOfRemotePhoto
|
||||
|
||||
type SetOfRefOfRemotePhoto struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfRefOfRemotePhoto() SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoDef map[ref.Ref]bool
|
||||
|
||||
func (def SetOfRefOfRemotePhotoDef) New() SetOfRefOfRemotePhoto {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = NewRefOfRemotePhoto(d)
|
||||
i++
|
||||
}
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Def() SetOfRefOfRemotePhotoDef {
|
||||
def := make(map[ref.Ref]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(RefOfRemotePhoto).TargetRef()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfRefOfRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfRefOfRemotePhoto.
|
||||
var __typeForSetOfRefOfRemotePhoto types.Type
|
||||
|
||||
func (m SetOfRefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForSetOfRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfRefOfRemotePhoto = types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)))
|
||||
types.RegisterValue(__typeForSetOfRefOfRemotePhoto, builderForSetOfRefOfRemotePhoto, readerForSetOfRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return SetOfRefOfRemotePhoto{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return v.(SetOfRefOfRemotePhoto).s
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Has(p RefOfRemotePhoto) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterCallback func(p RefOfRemotePhoto) (stop bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Iter(cb SetOfRefOfRemotePhotoIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterAllCallback func(p RefOfRemotePhoto)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAll(cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAllP(concurrency int, cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoFilterCallback func(p RefOfRemotePhoto) (keep bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Filter(cb SetOfRefOfRemotePhotoFilterCallback) SetOfRefOfRemotePhoto {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
return SetOfRefOfRemotePhoto{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Insert(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Remove(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Union(others ...SetOfRefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) First() RefOfRemotePhoto {
|
||||
return s.s.First().(RefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromStructSlice(p []SetOfRefOfRemotePhoto) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromElemSlice(p []RefOfRemotePhoto) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// RefOfRemotePhoto
|
||||
|
||||
type RefOfRemotePhoto struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfRemotePhoto(target ref.Ref) RefOfRemotePhoto {
|
||||
return RefOfRemotePhoto{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfRemotePhoto.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfRemotePhoto.
|
||||
var __typeForRefOfRemotePhoto types.Type
|
||||
|
||||
func (r RefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfRemotePhoto = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))
|
||||
types.RegisterRef(__typeForRefOfRemotePhoto, builderForRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRefOfRemotePhoto(r ref.Ref) types.RefBase {
|
||||
return NewRefOfRemotePhoto(r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetValue(vr types.ValueReader) RemotePhoto {
|
||||
return vr.ReadValue(r.target).(RemotePhoto)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../nomdl/codegen/codegen.go -package=main -out-dir=.
|
||||
@@ -1,109 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Date",
|
||||
[]types.Field{
|
||||
types.Field{"MsSinceEpoch", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Date
|
||||
|
||||
type Date struct {
|
||||
_MsSinceEpoch int64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDate() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: int64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type DateDef struct {
|
||||
MsSinceEpoch int64
|
||||
}
|
||||
|
||||
func (def DateDef) New() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: def.MsSinceEpoch,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Date) Def() (d DateDef) {
|
||||
d.MsSinceEpoch = s._MsSinceEpoch
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForDate types.Type
|
||||
|
||||
func (m Date) Type() types.Type {
|
||||
return __typeForDate
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForDate = types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0)
|
||||
types.RegisterStruct(__typeForDate, builderForDate, readerForDate)
|
||||
}
|
||||
|
||||
func builderForDate(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Date{ref: &ref.Ref{}}
|
||||
s._MsSinceEpoch = int64(values[i].(types.Int64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForDate(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Date)
|
||||
values = append(values, types.Int64(s._MsSinceEpoch))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Date) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForDate.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Date) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Date) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForDate.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._MsSinceEpoch))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) MsSinceEpoch() int64 {
|
||||
return s._MsSinceEpoch
|
||||
}
|
||||
|
||||
func (s Date) SetMsSinceEpoch(val int64) Date {
|
||||
s._MsSinceEpoch = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Geoposition",
|
||||
[]types.Field{
|
||||
types.Field{"Latitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Longitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Georectangle",
|
||||
[]types.Field{
|
||||
types.Field{"TopLeft", types.MakeType(ref.Ref{}, 0), false},
|
||||
types.Field{"BottomRight", types.MakeType(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Geoposition
|
||||
|
||||
type Geoposition struct {
|
||||
_Latitude float32
|
||||
_Longitude float32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: float32(0),
|
||||
_Longitude: float32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeopositionDef struct {
|
||||
Latitude float32
|
||||
Longitude float32
|
||||
}
|
||||
|
||||
func (def GeopositionDef) New() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: def.Latitude,
|
||||
_Longitude: def.Longitude,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Geoposition) Def() (d GeopositionDef) {
|
||||
d.Latitude = s._Latitude
|
||||
d.Longitude = s._Longitude
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeoposition types.Type
|
||||
|
||||
func (m Geoposition) Type() types.Type {
|
||||
return __typeForGeoposition
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeoposition = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0)
|
||||
types.RegisterStruct(__typeForGeoposition, builderForGeoposition, readerForGeoposition)
|
||||
}
|
||||
|
||||
func builderForGeoposition(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Geoposition{ref: &ref.Ref{}}
|
||||
s._Latitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Longitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeoposition(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Geoposition)
|
||||
values = append(values, types.Float32(s._Latitude))
|
||||
values = append(values, types.Float32(s._Longitude))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Geoposition) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeoposition.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Geoposition) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeoposition.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Latitude))
|
||||
ret = append(ret, types.Float32(s._Longitude))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) Latitude() float32 {
|
||||
return s._Latitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLatitude(val float32) Geoposition {
|
||||
s._Latitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Geoposition) Longitude() float32 {
|
||||
return s._Longitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLongitude(val float32) Geoposition {
|
||||
s._Longitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Georectangle
|
||||
|
||||
type Georectangle struct {
|
||||
_TopLeft Geoposition
|
||||
_BottomRight Geoposition
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeorectangle() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: NewGeoposition(),
|
||||
_BottomRight: NewGeoposition(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeorectangleDef struct {
|
||||
TopLeft GeopositionDef
|
||||
BottomRight GeopositionDef
|
||||
}
|
||||
|
||||
func (def GeorectangleDef) New() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: def.TopLeft.New(),
|
||||
_BottomRight: def.BottomRight.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Georectangle) Def() (d GeorectangleDef) {
|
||||
d.TopLeft = s._TopLeft.Def()
|
||||
d.BottomRight = s._BottomRight.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeorectangle types.Type
|
||||
|
||||
func (m Georectangle) Type() types.Type {
|
||||
return __typeForGeorectangle
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeorectangle = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 1)
|
||||
types.RegisterStruct(__typeForGeorectangle, builderForGeorectangle, readerForGeorectangle)
|
||||
}
|
||||
|
||||
func builderForGeorectangle(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Georectangle{ref: &ref.Ref{}}
|
||||
s._TopLeft = values[i].(Geoposition)
|
||||
i++
|
||||
s._BottomRight = values[i].(Geoposition)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeorectangle(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Georectangle)
|
||||
values = append(values, s._TopLeft)
|
||||
values = append(values, s._BottomRight)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Georectangle) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeorectangle.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Georectangle) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Georectangle) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeorectangle.Chunks()...)
|
||||
chunks = append(chunks, s._TopLeft.Chunks()...)
|
||||
chunks = append(chunks, s._BottomRight.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, s._TopLeft)
|
||||
ret = append(ret, s._BottomRight)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) TopLeft() Geoposition {
|
||||
return s._TopLeft
|
||||
}
|
||||
|
||||
func (s Georectangle) SetTopLeft(val Geoposition) Georectangle {
|
||||
s._TopLeft = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Georectangle) BottomRight() Geoposition {
|
||||
return s._BottomRight
|
||||
}
|
||||
|
||||
func (s Georectangle) SetBottomRight(val Geoposition) Georectangle {
|
||||
s._BottomRight = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,944 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("RemotePhoto",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0), false},
|
||||
types.Field{"Sizes", types.MakeCompoundType(types.MapKind, types.MakeType(ref.Ref{}, 2), types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Tags", types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Faces", types.MakeCompoundType(types.SetKind, types.MakeType(ref.Ref{}, 1)), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Face",
|
||||
[]types.Field{
|
||||
types.Field{"Top", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Left", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"PersonName", types.MakePrimitiveType(types.StringKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Size",
|
||||
[]types.Field{
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// RemotePhoto
|
||||
|
||||
type RemotePhoto struct {
|
||||
_Id string
|
||||
_Title string
|
||||
_Date Date
|
||||
_Geoposition Geoposition
|
||||
_Sizes MapOfSizeToString
|
||||
_Tags SetOfString
|
||||
_Faces SetOfFace
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRemotePhoto() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: "",
|
||||
_Title: "",
|
||||
_Date: NewDate(),
|
||||
_Geoposition: NewGeoposition(),
|
||||
_Sizes: NewMapOfSizeToString(),
|
||||
_Tags: NewSetOfString(),
|
||||
_Faces: NewSetOfFace(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type RemotePhotoDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Date DateDef
|
||||
Geoposition GeopositionDef
|
||||
Sizes MapOfSizeToStringDef
|
||||
Tags SetOfStringDef
|
||||
Faces SetOfFaceDef
|
||||
}
|
||||
|
||||
func (def RemotePhotoDef) New() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: def.Id,
|
||||
_Title: def.Title,
|
||||
_Date: def.Date.New(),
|
||||
_Geoposition: def.Geoposition.New(),
|
||||
_Sizes: def.Sizes.New(),
|
||||
_Tags: def.Tags.New(),
|
||||
_Faces: def.Faces.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Def() (d RemotePhotoDef) {
|
||||
d.Id = s._Id
|
||||
d.Title = s._Title
|
||||
d.Date = s._Date.Def()
|
||||
d.Geoposition = s._Geoposition.Def()
|
||||
d.Sizes = s._Sizes.Def()
|
||||
d.Tags = s._Tags.Def()
|
||||
d.Faces = s._Faces.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForRemotePhoto types.Type
|
||||
|
||||
func (m RemotePhoto) Type() types.Type {
|
||||
return __typeForRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRemotePhoto = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)
|
||||
types.RegisterStruct(__typeForRemotePhoto, builderForRemotePhoto, readerForRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRemotePhoto(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := RemotePhoto{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(Date)
|
||||
i++
|
||||
s._Geoposition = values[i].(Geoposition)
|
||||
i++
|
||||
s._Sizes = values[i].(MapOfSizeToString)
|
||||
i++
|
||||
s._Tags = values[i].(SetOfString)
|
||||
i++
|
||||
s._Faces = values[i].(SetOfFace)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForRemotePhoto(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(RemotePhoto)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, s._Date)
|
||||
values = append(values, s._Geoposition)
|
||||
values = append(values, s._Sizes)
|
||||
values = append(values, s._Tags)
|
||||
values = append(values, s._Faces)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForRemotePhoto.Chunks()...)
|
||||
chunks = append(chunks, s._Date.Chunks()...)
|
||||
chunks = append(chunks, s._Geoposition.Chunks()...)
|
||||
chunks = append(chunks, s._Sizes.Chunks()...)
|
||||
chunks = append(chunks, s._Tags.Chunks()...)
|
||||
chunks = append(chunks, s._Faces.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, s._Date)
|
||||
ret = append(ret, s._Geoposition)
|
||||
ret = append(ret, s._Sizes)
|
||||
ret = append(ret, s._Tags)
|
||||
ret = append(ret, s._Faces)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(val string) RemotePhoto {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(val string) RemotePhoto {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Date() Date {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetDate(val Date) RemotePhoto {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Geoposition() Geoposition {
|
||||
return s._Geoposition
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetGeoposition(val Geoposition) RemotePhoto {
|
||||
s._Geoposition = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return s._Sizes
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(val MapOfSizeToString) RemotePhoto {
|
||||
s._Sizes = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Tags() SetOfString {
|
||||
return s._Tags
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTags(val SetOfString) RemotePhoto {
|
||||
s._Tags = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Faces() SetOfFace {
|
||||
return s._Faces
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetFaces(val SetOfFace) RemotePhoto {
|
||||
s._Faces = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Face
|
||||
|
||||
type Face struct {
|
||||
_Top float32
|
||||
_Left float32
|
||||
_Width float32
|
||||
_Height float32
|
||||
_PersonName string
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewFace() Face {
|
||||
return Face{
|
||||
_Top: float32(0),
|
||||
_Left: float32(0),
|
||||
_Width: float32(0),
|
||||
_Height: float32(0),
|
||||
_PersonName: "",
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type FaceDef struct {
|
||||
Top float32
|
||||
Left float32
|
||||
Width float32
|
||||
Height float32
|
||||
PersonName string
|
||||
}
|
||||
|
||||
func (def FaceDef) New() Face {
|
||||
return Face{
|
||||
_Top: def.Top,
|
||||
_Left: def.Left,
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
_PersonName: def.PersonName,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Face) Def() (d FaceDef) {
|
||||
d.Top = s._Top
|
||||
d.Left = s._Left
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
d.PersonName = s._PersonName
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForFace types.Type
|
||||
|
||||
func (m Face) Type() types.Type {
|
||||
return __typeForFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForFace = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1)
|
||||
types.RegisterStruct(__typeForFace, builderForFace, readerForFace)
|
||||
}
|
||||
|
||||
func builderForFace(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Face{ref: &ref.Ref{}}
|
||||
s._Top = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Left = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Width = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Height = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._PersonName = values[i].(types.String).String()
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForFace(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Face)
|
||||
values = append(values, types.Float32(s._Top))
|
||||
values = append(values, types.Float32(s._Left))
|
||||
values = append(values, types.Float32(s._Width))
|
||||
values = append(values, types.Float32(s._Height))
|
||||
values = append(values, types.NewString(s._PersonName))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Face) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Face) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Face) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForFace.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Top))
|
||||
ret = append(ret, types.Float32(s._Left))
|
||||
ret = append(ret, types.Float32(s._Width))
|
||||
ret = append(ret, types.Float32(s._Height))
|
||||
ret = append(ret, types.NewString(s._PersonName))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) Top() float32 {
|
||||
return s._Top
|
||||
}
|
||||
|
||||
func (s Face) SetTop(val float32) Face {
|
||||
s._Top = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Left() float32 {
|
||||
return s._Left
|
||||
}
|
||||
|
||||
func (s Face) SetLeft(val float32) Face {
|
||||
s._Left = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Width() float32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Face) SetWidth(val float32) Face {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Height() float32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Face) SetHeight(val float32) Face {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) PersonName() string {
|
||||
return s._PersonName
|
||||
}
|
||||
|
||||
func (s Face) SetPersonName(val string) Face {
|
||||
s._PersonName = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Size
|
||||
|
||||
type Size struct {
|
||||
_Width uint32
|
||||
_Height uint32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{
|
||||
_Width: uint32(0),
|
||||
_Height: uint32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type SizeDef struct {
|
||||
Width uint32
|
||||
Height uint32
|
||||
}
|
||||
|
||||
func (def SizeDef) New() Size {
|
||||
return Size{
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Size) Def() (d SizeDef) {
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForSize types.Type
|
||||
|
||||
func (m Size) Type() types.Type {
|
||||
return __typeForSize
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSize = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2)
|
||||
types.RegisterStruct(__typeForSize, builderForSize, readerForSize)
|
||||
}
|
||||
|
||||
func builderForSize(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Size{ref: &ref.Ref{}}
|
||||
s._Width = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
s._Height = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForSize(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Size)
|
||||
values = append(values, types.Uint32(s._Width))
|
||||
values = append(values, types.Uint32(s._Height))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Size) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSize.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Size) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForSize.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Uint32(s._Width))
|
||||
ret = append(ret, types.Uint32(s._Height))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) Width() uint32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(val uint32) Size {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Size) Height() uint32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(val uint32) Size {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringDef map[SizeDef]string
|
||||
|
||||
func (def MapOfSizeToStringDef) New() MapOfSizeToString {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, k.New(), types.NewString(v))
|
||||
}
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Def() MapOfSizeToStringDef {
|
||||
def := make(map[SizeDef]string)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(Size).Def()] = v.(types.String).String()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfSizeToString.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfSizeToString.
|
||||
var __typeForMapOfSizeToString types.Type
|
||||
|
||||
func (m MapOfSizeToString) Type() types.Type {
|
||||
return __typeForMapOfSizeToString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfSizeToString = types.MakeCompoundType(types.MapKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2), types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForMapOfSizeToString, builderForMapOfSizeToString, readerForMapOfSizeToString)
|
||||
}
|
||||
|
||||
func builderForMapOfSizeToString(v types.Value) types.Value {
|
||||
return MapOfSizeToString{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfSizeToString(v types.Value) types.Value {
|
||||
return v.(MapOfSizeToString).m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) string {
|
||||
return m.m.Get(p).(types.String).String()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) MaybeGet(p Size) (string, bool) {
|
||||
v, ok := m.m.MaybeGet(p)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return v.(types.String).String(), ok
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v string) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Set(k, types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Remove(p), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback func(k Size, v string) (stop bool)
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterAllCallback func(k Size, v string)
|
||||
|
||||
func (m MapOfSizeToString) IterAll(cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) IterAllP(concurrency int, cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringFilterCallback func(k Size, v string) (keep bool)
|
||||
|
||||
func (m MapOfSizeToString) Filter(cb MapOfSizeToStringFilterCallback) MapOfSizeToString {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
return MapOfSizeToString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
|
||||
func (def SetOfStringDef) New() SetOfString {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
def := make(map[string]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(types.String).String()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfString.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfString.
|
||||
var __typeForSetOfString types.Type
|
||||
|
||||
func (m SetOfString) Type() types.Type {
|
||||
return __typeForSetOfString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfString = types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForSetOfString, builderForSetOfString, readerForSetOfString)
|
||||
}
|
||||
|
||||
func builderForSetOfString(v types.Value) types.Value {
|
||||
return SetOfString{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfString(v types.Value) types.Value {
|
||||
return v.(SetOfString).s
|
||||
}
|
||||
|
||||
func (s SetOfString) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfString) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfString) Has(p string) bool {
|
||||
return s.s.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
type SetOfStringIterCallback func(p string) (stop bool)
|
||||
|
||||
func (s SetOfString) Iter(cb SetOfStringIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringIterAllCallback func(p string)
|
||||
|
||||
func (s SetOfString) IterAll(cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfString) IterAllP(concurrency int, cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringFilterCallback func(p string) (keep bool)
|
||||
|
||||
func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
return SetOfString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) First() string {
|
||||
return s.s.First().(types.String).String()
|
||||
}
|
||||
|
||||
func (s SetOfString) fromStructSlice(p []SetOfString) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfString) fromElemSlice(p []string) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = types.NewString(v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// SetOfFace
|
||||
|
||||
type SetOfFace struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfFace() SetOfFace {
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfFaceDef map[FaceDef]bool
|
||||
|
||||
func (def SetOfFaceDef) New() SetOfFace {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = d.New()
|
||||
i++
|
||||
}
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Def() SetOfFaceDef {
|
||||
def := make(map[FaceDef]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(Face).Def()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfFace) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfFace) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfFace) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfFace.
|
||||
var __typeForSetOfFace types.Type
|
||||
|
||||
func (m SetOfFace) Type() types.Type {
|
||||
return __typeForSetOfFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfFace = types.MakeCompoundType(types.SetKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1))
|
||||
types.RegisterValue(__typeForSetOfFace, builderForSetOfFace, readerForSetOfFace)
|
||||
}
|
||||
|
||||
func builderForSetOfFace(v types.Value) types.Value {
|
||||
return SetOfFace{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfFace(v types.Value) types.Value {
|
||||
return v.(SetOfFace).s
|
||||
}
|
||||
|
||||
func (s SetOfFace) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Has(p Face) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfFaceIterCallback func(p Face) (stop bool)
|
||||
|
||||
func (s SetOfFace) Iter(cb SetOfFaceIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceIterAllCallback func(p Face)
|
||||
|
||||
func (s SetOfFace) IterAll(cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfFace) IterAllP(concurrency int, cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceFilterCallback func(p Face) (keep bool)
|
||||
|
||||
func (s SetOfFace) Filter(cb SetOfFaceFilterCallback) SetOfFace {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
return SetOfFace{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Insert(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Remove(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Union(others ...SetOfFace) SetOfFace {
|
||||
return SetOfFace{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) First() Face {
|
||||
return s.s.First().(Face)
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromStructSlice(p []SetOfFace) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromElemSlice(p []Face) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package main
|
||||
|
||||
type UserJSON struct {
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type AlbumListJSON struct {
|
||||
Data []struct {
|
||||
Count int `json:"count"`
|
||||
}
|
||||
// Paging, but we only use this to get a good photo count, so whatevs
|
||||
}
|
||||
|
||||
type PhotoListJSON struct {
|
||||
Data []struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedTime int `json:"created_time"`
|
||||
Images []ImageJSON `json:"images"`
|
||||
Tags TagListJSON `json:"tags"`
|
||||
Place PlaceJSON `json:"place"`
|
||||
}
|
||||
Paging struct {
|
||||
Next string `json:"next"`
|
||||
} `json:"paging"`
|
||||
}
|
||||
|
||||
type ImageJSON struct {
|
||||
Height uint32 `json:"height"`
|
||||
Width uint32 `json:"width"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
type TagListJSON struct {
|
||||
Data []TagJSON
|
||||
// Paging, but I doubt any tag lists will be that long
|
||||
}
|
||||
|
||||
type TagJSON struct {
|
||||
Name string `json:"name"`
|
||||
X float32 `json:"x"`
|
||||
Y float32 `json:"y"`
|
||||
}
|
||||
|
||||
type PlaceJSON struct {
|
||||
Location struct {
|
||||
Latitude float32 `json:"latitude"`
|
||||
Longitude float32 `json:"longitude"`
|
||||
} `json:"location"`
|
||||
// The reverse-geocoded information about this place is also included, but we don't care about that now
|
||||
}
|
||||
1
clients/flickr/.gitignore
vendored
1
clients/flickr/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
flickr
|
||||
@@ -1,465 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/util/http/retry"
|
||||
"github.com/bradfitz/latlong"
|
||||
"github.com/garyburd/go-oauth/oauth"
|
||||
)
|
||||
|
||||
var (
|
||||
clientIdFlag = flag.String("client-id", "", "API keys for flickr can be created at https://www.flickr.com/services/apps/create/apply")
|
||||
clientSecretFlag = flag.String("client-secret", "", "API keys for flickr can be created at https://www.flickr.com/services/apps/create/apply")
|
||||
clientFlags = util.NewFlags()
|
||||
ds *dataset.Dataset
|
||||
httpClient *http.Client
|
||||
oauthClient oauth.Client
|
||||
tokenFlag = flag.String("token", "", "OAuth1 token (if ommitted, flickr will attempt web auth)")
|
||||
tokenSecretFlag = flag.String("token-secret", "", "OAuth1 token secret (if ommitted, flickr will attempt web auth)")
|
||||
user User
|
||||
)
|
||||
|
||||
type progressTracker struct {
|
||||
didLogin bool
|
||||
didGetList bool
|
||||
numPhotos, photoProgress int
|
||||
}
|
||||
|
||||
func (pt *progressTracker) Update() {
|
||||
progress := float32(0)
|
||||
if pt.didLogin {
|
||||
progress += 0.1
|
||||
}
|
||||
if pt.didGetList {
|
||||
progress += 0.1
|
||||
}
|
||||
if pt.numPhotos > 0 {
|
||||
remaining := 1.0 - progress
|
||||
progress += remaining * (float32(pt.photoProgress) / float32(pt.numPhotos))
|
||||
}
|
||||
clientFlags.UpdateProgress(progress)
|
||||
}
|
||||
|
||||
type flickrAPI interface {
|
||||
Call(method string, response interface{}, args *map[string]string) error
|
||||
}
|
||||
|
||||
type flickrCall struct {
|
||||
Stat string
|
||||
}
|
||||
|
||||
type idAndRefOfAlbum struct {
|
||||
id string
|
||||
ref RefOfAlbum
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Usage = flickrUsage
|
||||
flag.Parse()
|
||||
|
||||
httpClient = util.CachingHttpClient()
|
||||
|
||||
if *clientIdFlag == "" || *clientSecretFlag == "" || httpClient == nil {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ds = clientFlags.CreateDataset()
|
||||
if ds == nil {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
if err := clientFlags.CreateProgressFile(); err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
defer clientFlags.CloseProgressFile()
|
||||
}
|
||||
|
||||
oauthClient = oauth.Client{
|
||||
TemporaryCredentialRequestURI: "https://www.flickr.com/services/oauth/request_token",
|
||||
ResourceOwnerAuthorizationURI: "https://www.flickr.com/services/oauth/authorize",
|
||||
TokenRequestURI: "https://www.flickr.com/services/oauth/access_token",
|
||||
Credentials: oauth.Credentials{
|
||||
Token: *clientIdFlag,
|
||||
Secret: *clientSecretFlag,
|
||||
},
|
||||
}
|
||||
|
||||
var tokenCred *oauth.Credentials
|
||||
if *tokenFlag != "" && *tokenSecretFlag != "" {
|
||||
tokenCred = &oauth.Credentials{*tokenFlag, *tokenSecretFlag}
|
||||
} else {
|
||||
tokenCred = requestTokenCredentials()
|
||||
}
|
||||
|
||||
api := liveFlickrAPI{tokenCred}
|
||||
if !findUser() {
|
||||
if err := requestUser(api); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
progress := progressTracker{}
|
||||
progress.didLogin = true
|
||||
progress.Update()
|
||||
|
||||
user = user.SetAlbums(getAlbums(api, &progress))
|
||||
commitUser()
|
||||
}
|
||||
|
||||
func flickrUsage() {
|
||||
essay := `The Flickr importer needs 4 items for authentication: a client ID + secret, and a token + secret:
|
||||
* For the client ID + secret, you need to apply for an API key through https://www.flickr.com/services/apps/create/apply. Specify these as -client-id and -client-secret.
|
||||
* For the token + secret, you have 2 options:
|
||||
(a) specify them as -token and -secret, or
|
||||
(b) let the Flickr importer request them for you (don't specify anything).
|
||||
The latter will take you through web auth, which on the last page will show the token and secret to use for -token and -secret from now on (unless they get revoked).`
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
fmt.Fprintf(os.Stderr, "\n%s\n\n", essay)
|
||||
}
|
||||
|
||||
func findUser() bool {
|
||||
if commit, ok := ds.MaybeHead(); ok {
|
||||
if userRef, ok := commit.Value().(RefOfUser); ok {
|
||||
user = userRef.TargetValue(ds.Store())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func requestUser(api flickrAPI) error {
|
||||
response := struct {
|
||||
flickrCall
|
||||
User struct {
|
||||
Id string `json:"id"`
|
||||
Username struct {
|
||||
Content string `json:"_content"`
|
||||
} `json:"username"`
|
||||
} `json:"user"`
|
||||
}{}
|
||||
|
||||
if err := api.Call("flickr.test.login", &response, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user = user.SetId(response.User.Id).SetName(response.User.Username.Content)
|
||||
return nil
|
||||
}
|
||||
|
||||
func requestTokenCredentials() *oauth.Credentials {
|
||||
l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
d.Chk.NoError(err)
|
||||
|
||||
callbackURL := "http://" + l.Addr().String()
|
||||
tempCred, err := oauthClient.RequestTemporaryCredentials(nil, callbackURL, url.Values{
|
||||
"perms": []string{"read"},
|
||||
})
|
||||
// If we ever hear anything from the oauth handshake, it'll be acceptance. The user declining will mean we never get called.
|
||||
d.Chk.NoError(err)
|
||||
|
||||
authUrl := oauthClient.AuthorizationURL(tempCred, nil)
|
||||
fmt.Printf("Visit the following URL to authorize access to your Flickr data: %v\n", authUrl)
|
||||
tokenCred, err := awaitOAuthResponse(l, tempCred)
|
||||
d.Chk.NoError(err)
|
||||
return tokenCred
|
||||
}
|
||||
|
||||
func getAlbum(api flickrAPI, id string, gotPhoto chan struct{}) idAndRefOfAlbum {
|
||||
response := struct {
|
||||
flickrCall
|
||||
Photoset struct {
|
||||
Id string `json:"id"`
|
||||
Title struct {
|
||||
Content string `json:"_content"`
|
||||
} `json:"title"`
|
||||
} `json:"photoset"`
|
||||
}{}
|
||||
|
||||
err := api.Call("flickr.photosets.getInfo", &response, &map[string]string{
|
||||
"photoset_id": id,
|
||||
"user_id": user.Id(),
|
||||
})
|
||||
d.Chk.NoError(err)
|
||||
|
||||
photos := getAlbumPhotos(api, id, gotPhoto)
|
||||
|
||||
fmt.Printf("Photoset: %v\n", response.Photoset.Title.Content)
|
||||
|
||||
album := NewAlbum().
|
||||
SetId(id).
|
||||
SetTitle(response.Photoset.Title.Content).
|
||||
SetPhotos(photos)
|
||||
// TODO: Write albums in batches.
|
||||
ref := ds.Store().WriteValue(album).(RefOfAlbum)
|
||||
return idAndRefOfAlbum{id, ref}
|
||||
}
|
||||
|
||||
func getAlbums(api flickrAPI, progress *progressTracker) MapOfStringToRefOfAlbum {
|
||||
response := struct {
|
||||
flickrCall
|
||||
Photosets struct {
|
||||
Photoset []struct {
|
||||
Id string `json:"id"`
|
||||
Title struct {
|
||||
Content string `json:"_content"`
|
||||
} `json:"title"`
|
||||
Photos int `json:"photos"`
|
||||
} `json:"photoset"`
|
||||
} `json:"photosets"`
|
||||
}{}
|
||||
|
||||
err := api.Call("flickr.photosets.getList", &response, nil)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
progress.didGetList = true
|
||||
progress.Update()
|
||||
|
||||
for _, ps := range response.Photosets.Photoset {
|
||||
progress.numPhotos += ps.Photos
|
||||
}
|
||||
|
||||
gotPhoto := make(chan struct{}, clientFlags.Concurrency())
|
||||
go func() {
|
||||
lastUpdate := time.Now()
|
||||
for range gotPhoto {
|
||||
progress.photoProgress++
|
||||
if now := time.Now(); now.Sub(lastUpdate)/time.Millisecond >= 200 {
|
||||
progress.Update()
|
||||
lastUpdate = now
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
out := make(chan idAndRefOfAlbum, clientFlags.Concurrency())
|
||||
for _, p := range response.Photosets.Photoset {
|
||||
p := p
|
||||
go func() {
|
||||
out <- getAlbum(api, p.Id, gotPhoto)
|
||||
}()
|
||||
}
|
||||
|
||||
albums := NewMapOfStringToRefOfAlbum()
|
||||
for range response.Photosets.Photoset {
|
||||
a := <-out
|
||||
albums = albums.Set(a.id, a.ref)
|
||||
}
|
||||
|
||||
close(gotPhoto)
|
||||
return albums
|
||||
}
|
||||
|
||||
func getAlbumPhotos(api flickrAPI, id string, gotPhoto chan struct{}) SetOfRefOfRemotePhoto {
|
||||
response := struct {
|
||||
flickrCall
|
||||
Photoset struct {
|
||||
Photo []struct {
|
||||
DateTaken string `json:"datetaken"`
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Tags string `json:"tags"`
|
||||
ThumbURL string `json:"url_t"`
|
||||
ThumbWidth interface{} `json:"width_t"`
|
||||
ThumbHeight interface{} `json:"height_t"`
|
||||
SmallURL string `json:"url_s"`
|
||||
SmallWidth interface{} `json:"width_s"`
|
||||
SmallHeight interface{} `json:"height_s"`
|
||||
Latitude interface{} `json:"latitude"`
|
||||
Longitude interface{} `json:"longitude"`
|
||||
MediumURL string `json:"url_m"`
|
||||
MediumWidth interface{} `json:"width_m"`
|
||||
MediumHeight interface{} `json:"height_m"`
|
||||
LargeURL string `json:"url_l"`
|
||||
LargeWidth interface{} `json:"width_l"`
|
||||
LargeHeight interface{} `json:"height_l"`
|
||||
OriginalURL string `json:"url_o"`
|
||||
OriginalWidth interface{} `json:"width_o"`
|
||||
OriginalHeight interface{} `json:"height_o"`
|
||||
} `json:"photo"`
|
||||
} `json:"photoset"`
|
||||
}{}
|
||||
|
||||
// TODO: Implement paging. This call returns a maximum of 500 pictures in each response.
|
||||
err := api.Call("flickr.photosets.getPhotos", &response, &map[string]string{
|
||||
"photoset_id": id,
|
||||
"user_id": user.Id(),
|
||||
"extras": "date_taken,geo,tags,url_t,url_s,url_m,url_l,url_o",
|
||||
})
|
||||
d.Chk.NoError(err)
|
||||
|
||||
store := ds.Store()
|
||||
photos := NewSetOfRefOfRemotePhoto()
|
||||
|
||||
for _, p := range response.Photoset.Photo {
|
||||
photo := RemotePhotoDef{
|
||||
Id: p.Id,
|
||||
Title: p.Title,
|
||||
Tags: getTags(p.Tags),
|
||||
}.New()
|
||||
|
||||
lat, lon := deFlickr(p.Latitude), deFlickr(p.Longitude)
|
||||
|
||||
// Flickr doesn't give timezone information (in fairness, neither does EXIF), so try to figure it out from the geolocation data. This is imperfect because it won't give us daylight savings. If there is no geolocation data then assume the location is PST - it's better than GMT.
|
||||
zone := "America/Los_Angeles"
|
||||
if lat != 0.0 && lon != 0.0 {
|
||||
if z := latlong.LookupZoneName(lat, lon); z != "" {
|
||||
zone = z
|
||||
}
|
||||
}
|
||||
location, err := time.LoadLocation(zone)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
// DateTaken is the MySQL DATETIME format.
|
||||
if t, err := time.ParseInLocation("2006-01-02 15:04:05", p.DateTaken, location); err == nil {
|
||||
photo = photo.SetDate(DateDef{t.Unix() * 1e3}.New())
|
||||
} else {
|
||||
fmt.Printf("Error parsing date \"%s\": %s\n", p.DateTaken, err)
|
||||
}
|
||||
|
||||
sizes := NewMapOfSizeToString()
|
||||
sizes = addSize(sizes, p.ThumbURL, p.ThumbWidth, p.ThumbHeight)
|
||||
sizes = addSize(sizes, p.SmallURL, p.SmallWidth, p.SmallHeight)
|
||||
sizes = addSize(sizes, p.MediumURL, p.MediumWidth, p.MediumHeight)
|
||||
sizes = addSize(sizes, p.LargeURL, p.LargeWidth, p.LargeHeight)
|
||||
sizes = addSize(sizes, p.OriginalURL, p.OriginalWidth, p.OriginalHeight)
|
||||
photo = photo.SetSizes(sizes)
|
||||
|
||||
if lat != 0.0 && lon != 0.0 {
|
||||
photo = photo.SetGeoposition(GeopositionDef{float32(lat), float32(lon)}.New())
|
||||
}
|
||||
|
||||
// TODO: Write photos in batches.
|
||||
photos = photos.Insert(store.WriteValue(photo).(RefOfRemotePhoto))
|
||||
gotPhoto <- struct{}{}
|
||||
}
|
||||
|
||||
return photos
|
||||
}
|
||||
|
||||
func getTags(tagStr string) (tags SetOfStringDef) {
|
||||
tags = SetOfStringDef{}
|
||||
|
||||
if tagStr == "" {
|
||||
return
|
||||
}
|
||||
|
||||
for _, tag := range strings.Split(tagStr, " ") {
|
||||
tags[tag] = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func deFlickr(argh interface{}) float64 {
|
||||
switch argh := argh.(type) {
|
||||
case float64:
|
||||
return argh
|
||||
case string:
|
||||
f64, err := strconv.ParseFloat(argh, 64)
|
||||
d.Chk.NoError(err)
|
||||
return float64(f64)
|
||||
default:
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
|
||||
func addSize(sizes MapOfSizeToString, url string, width interface{}, height interface{}) MapOfSizeToString {
|
||||
getDim := func(v interface{}) uint32 {
|
||||
switch v := v.(type) {
|
||||
case float64:
|
||||
return uint32(v)
|
||||
case string:
|
||||
i, err := strconv.Atoi(v)
|
||||
d.Chk.NoError(err)
|
||||
return uint32(i)
|
||||
default:
|
||||
d.Chk.Fail(fmt.Sprintf("Unexpected value for image width or height: %+v", v))
|
||||
return uint32(0)
|
||||
}
|
||||
}
|
||||
if url == "" {
|
||||
return sizes
|
||||
}
|
||||
|
||||
return sizes.Set(SizeDef{getDim(width), getDim(height)}.New(), url)
|
||||
}
|
||||
|
||||
func awaitOAuthResponse(l net.Listener, tempCred *oauth.Credentials) (tokenCred *oauth.Credentials, err error) {
|
||||
srv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("content-type", "text/plain")
|
||||
tokenCred, _, err = oauthClient.RequestToken(nil, tempCred, r.FormValue("oauth_verifier"))
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "%v", err)
|
||||
} else {
|
||||
d.Chk.NotNil(tokenCred)
|
||||
fmt.Fprintf(w, "Authorized: token %s token-secret %s", tokenCred.Token, tokenCred.Secret)
|
||||
}
|
||||
l.Close()
|
||||
})}
|
||||
srv.Serve(l)
|
||||
return
|
||||
}
|
||||
|
||||
func commitUser() {
|
||||
var err error
|
||||
r := ds.Store().WriteValue(user).(RefOfUser)
|
||||
*ds, err = ds.Commit(r)
|
||||
d.Exp.NoError(err)
|
||||
}
|
||||
|
||||
type liveFlickrAPI struct {
|
||||
tokenCred *oauth.Credentials
|
||||
}
|
||||
|
||||
func (api liveFlickrAPI) Call(method string, response interface{}, args *map[string]string) error {
|
||||
restURL := "https://api.flickr.com/services/rest/"
|
||||
|
||||
values := url.Values{
|
||||
"method": []string{method},
|
||||
"format": []string{"json"},
|
||||
"nojsoncallback": []string{"1"},
|
||||
}
|
||||
|
||||
if args != nil {
|
||||
for k, v := range *args {
|
||||
values[k] = []string{v}
|
||||
}
|
||||
}
|
||||
|
||||
res := retry.Request(restURL, func() (*http.Response, error) {
|
||||
return oauthClient.Get(nil, api.tokenCred, restURL, values)
|
||||
})
|
||||
|
||||
defer res.Body.Close()
|
||||
buff, err := ioutil.ReadAll(res.Body)
|
||||
d.Chk.NoError(err)
|
||||
if err = json.Unmarshal(buff, response); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
status := reflect.ValueOf(response).Elem().FieldByName("Stat").Interface().(string)
|
||||
if status != "ok" {
|
||||
err = errors.New(fmt.Sprintf("Failed flickr API call: %v, status: %v", method, status))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeFlickrAPI struct {
|
||||
methods map[string]string
|
||||
}
|
||||
|
||||
func (api fakeFlickrAPI) Call(method string, response interface{}, args *map[string]string) error {
|
||||
if responseJson, ok := api.methods[method]; ok {
|
||||
return json.Unmarshal([]byte(responseJson), response)
|
||||
} else {
|
||||
return errors.New("unknown method " + method)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAlbums(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
store := datas.NewDataStore(chunks.NewMemoryStore())
|
||||
testDs := dataset.NewDataset(store, "test")
|
||||
ds = &testDs
|
||||
progress := progressTracker{}
|
||||
methods := map[string]string{
|
||||
"flickr.photosets.getList": `{
|
||||
"photosets": {
|
||||
"photoset": [
|
||||
{
|
||||
"id": "42",
|
||||
"photos": 2,
|
||||
"title": {
|
||||
"_content": "My Photoset"
|
||||
},
|
||||
"description": {
|
||||
"_content": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
"flickr.photosets.getInfo": `{
|
||||
"photoset": {
|
||||
"id": "42",
|
||||
"username": "me",
|
||||
"photos": 2,
|
||||
"title": {
|
||||
"_content": "My Photoset"
|
||||
},
|
||||
"description": {
|
||||
"_content": ""
|
||||
}
|
||||
}
|
||||
}`,
|
||||
"flickr.photosets.getPhotos": `{
|
||||
"photoset": {
|
||||
"id": "42",
|
||||
"photo": [
|
||||
{
|
||||
"id": "0",
|
||||
"title": "_0",
|
||||
"datetaken": "2011-08-13 04:54:40",
|
||||
"url_s": "https:\/\/staticflickr.com\/0\/0.jpg",
|
||||
"height_s": "159",
|
||||
"width_s": "240",
|
||||
"url_m": "https:\/\/staticflickr.com\/0\/1.jpg",
|
||||
"height_m": "332",
|
||||
"width_m": "500",
|
||||
"url_l": "https:\/\/staticflickr.com\/0\/2.jpg",
|
||||
"height_l": "679",
|
||||
"width_l": "1024",
|
||||
"url_o": "https:\/\/staticflickr.com\/0\/3.jpg",
|
||||
"height_o": "679",
|
||||
"width_o": "1024",
|
||||
"longitude": 0,
|
||||
"latitude": 0
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"title": "_1",
|
||||
"datetaken": "2011-12-13 04:51:08",
|
||||
"url_s": "https:\/\/staticflickr.com\/1\/0.jpg",
|
||||
"height_s": "159",
|
||||
"width_s": "240",
|
||||
"url_m": "https:\/\/staticflickr.com\/1\/1.jpg",
|
||||
"height_m": "332",
|
||||
"width_m": "500",
|
||||
"url_l": "https:\/\/staticflickr.com\/1\/2.jpg",
|
||||
"height_l": "679",
|
||||
"width_l": "1024",
|
||||
"url_o": "https:\/\/staticflickr.com\/1\/3.jpg",
|
||||
"height_o": "6790",
|
||||
"width_o": "10240",
|
||||
"latitude": 48.8582641,
|
||||
"longitude": 2.2923184
|
||||
}
|
||||
],
|
||||
"title": "My Photoset"
|
||||
}
|
||||
}`,
|
||||
}
|
||||
|
||||
albums := getAlbums(fakeFlickrAPI{methods}, &progress)
|
||||
assert.Equal(uint64(1), albums.Len())
|
||||
|
||||
album := albums.Get("42").TargetValue(store)
|
||||
assert.Equal("42", album.Id())
|
||||
assert.Equal("My Photoset", album.Title())
|
||||
|
||||
photos := album.Photos()
|
||||
assert.Equal(uint64(2), photos.Len())
|
||||
|
||||
var photo0, photo1 RemotePhoto
|
||||
photos.IterAll(func(photo RefOfRemotePhoto) {
|
||||
p := photo.TargetValue(store)
|
||||
switch id := p.Id(); id {
|
||||
case "0":
|
||||
photo0 = p
|
||||
case "1":
|
||||
photo1 = p
|
||||
default:
|
||||
panic("unexpected photo " + id)
|
||||
}
|
||||
})
|
||||
|
||||
assert.Equal("0", photo0.Id())
|
||||
assert.Equal("_0", photo0.Title())
|
||||
assert.Equal(int64(1313236480000), photo0.Date().MsSinceEpoch())
|
||||
assert.Equal(float32(0), photo0.Geoposition().Latitude())
|
||||
assert.Equal(float32(0), photo0.Geoposition().Longitude())
|
||||
assert.Equal(uint64(3), photo0.Sizes().Len()) // two of the images are the same
|
||||
assert.Equal(uint64(0), photo0.Tags().Len())
|
||||
|
||||
assert.Equal("1", photo1.Id())
|
||||
assert.Equal("_1", photo1.Title())
|
||||
// This photo was taken in Paris (by finding the lat/long of the Eiffel Tower), so its date should be interpreted according to that timezone, which is 9 hours ahead of PST (as of this moment).
|
||||
assert.Equal(int64(1323780668000-(9000*3600)), photo1.Date().MsSinceEpoch())
|
||||
assert.Equal(float32(48.8582641), photo1.Geoposition().Latitude())
|
||||
assert.Equal(float32(2.2923184), photo1.Geoposition().Longitude())
|
||||
assert.Equal(uint64(4), photo1.Sizes().Len()) // all images are different sizes
|
||||
assert.Equal(uint64(0), photo1.Tags().Len())
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../nomdl/codegen/codegen.go -package=main -out-dir=.
|
||||
@@ -1,109 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Date",
|
||||
[]types.Field{
|
||||
types.Field{"MsSinceEpoch", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Date
|
||||
|
||||
type Date struct {
|
||||
_MsSinceEpoch int64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDate() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: int64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type DateDef struct {
|
||||
MsSinceEpoch int64
|
||||
}
|
||||
|
||||
func (def DateDef) New() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: def.MsSinceEpoch,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Date) Def() (d DateDef) {
|
||||
d.MsSinceEpoch = s._MsSinceEpoch
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForDate types.Type
|
||||
|
||||
func (m Date) Type() types.Type {
|
||||
return __typeForDate
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForDate = types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0)
|
||||
types.RegisterStruct(__typeForDate, builderForDate, readerForDate)
|
||||
}
|
||||
|
||||
func builderForDate(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Date{ref: &ref.Ref{}}
|
||||
s._MsSinceEpoch = int64(values[i].(types.Int64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForDate(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Date)
|
||||
values = append(values, types.Int64(s._MsSinceEpoch))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Date) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForDate.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Date) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Date) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForDate.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._MsSinceEpoch))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) MsSinceEpoch() int64 {
|
||||
return s._MsSinceEpoch
|
||||
}
|
||||
|
||||
func (s Date) SetMsSinceEpoch(val int64) Date {
|
||||
s._MsSinceEpoch = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Geoposition",
|
||||
[]types.Field{
|
||||
types.Field{"Latitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Longitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Georectangle",
|
||||
[]types.Field{
|
||||
types.Field{"TopLeft", types.MakeType(ref.Ref{}, 0), false},
|
||||
types.Field{"BottomRight", types.MakeType(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Geoposition
|
||||
|
||||
type Geoposition struct {
|
||||
_Latitude float32
|
||||
_Longitude float32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: float32(0),
|
||||
_Longitude: float32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeopositionDef struct {
|
||||
Latitude float32
|
||||
Longitude float32
|
||||
}
|
||||
|
||||
func (def GeopositionDef) New() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: def.Latitude,
|
||||
_Longitude: def.Longitude,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Geoposition) Def() (d GeopositionDef) {
|
||||
d.Latitude = s._Latitude
|
||||
d.Longitude = s._Longitude
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeoposition types.Type
|
||||
|
||||
func (m Geoposition) Type() types.Type {
|
||||
return __typeForGeoposition
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeoposition = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0)
|
||||
types.RegisterStruct(__typeForGeoposition, builderForGeoposition, readerForGeoposition)
|
||||
}
|
||||
|
||||
func builderForGeoposition(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Geoposition{ref: &ref.Ref{}}
|
||||
s._Latitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Longitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeoposition(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Geoposition)
|
||||
values = append(values, types.Float32(s._Latitude))
|
||||
values = append(values, types.Float32(s._Longitude))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Geoposition) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeoposition.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Geoposition) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeoposition.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Latitude))
|
||||
ret = append(ret, types.Float32(s._Longitude))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) Latitude() float32 {
|
||||
return s._Latitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLatitude(val float32) Geoposition {
|
||||
s._Latitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Geoposition) Longitude() float32 {
|
||||
return s._Longitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLongitude(val float32) Geoposition {
|
||||
s._Longitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Georectangle
|
||||
|
||||
type Georectangle struct {
|
||||
_TopLeft Geoposition
|
||||
_BottomRight Geoposition
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeorectangle() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: NewGeoposition(),
|
||||
_BottomRight: NewGeoposition(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeorectangleDef struct {
|
||||
TopLeft GeopositionDef
|
||||
BottomRight GeopositionDef
|
||||
}
|
||||
|
||||
func (def GeorectangleDef) New() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: def.TopLeft.New(),
|
||||
_BottomRight: def.BottomRight.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Georectangle) Def() (d GeorectangleDef) {
|
||||
d.TopLeft = s._TopLeft.Def()
|
||||
d.BottomRight = s._BottomRight.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeorectangle types.Type
|
||||
|
||||
func (m Georectangle) Type() types.Type {
|
||||
return __typeForGeorectangle
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeorectangle = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 1)
|
||||
types.RegisterStruct(__typeForGeorectangle, builderForGeorectangle, readerForGeorectangle)
|
||||
}
|
||||
|
||||
func builderForGeorectangle(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Georectangle{ref: &ref.Ref{}}
|
||||
s._TopLeft = values[i].(Geoposition)
|
||||
i++
|
||||
s._BottomRight = values[i].(Geoposition)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeorectangle(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Georectangle)
|
||||
values = append(values, s._TopLeft)
|
||||
values = append(values, s._BottomRight)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Georectangle) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeorectangle.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Georectangle) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Georectangle) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeorectangle.Chunks()...)
|
||||
chunks = append(chunks, s._TopLeft.Chunks()...)
|
||||
chunks = append(chunks, s._BottomRight.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, s._TopLeft)
|
||||
ret = append(ret, s._BottomRight)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) TopLeft() Geoposition {
|
||||
return s._TopLeft
|
||||
}
|
||||
|
||||
func (s Georectangle) SetTopLeft(val Geoposition) Georectangle {
|
||||
s._TopLeft = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Georectangle) BottomRight() Geoposition {
|
||||
return s._BottomRight
|
||||
}
|
||||
|
||||
func (s Georectangle) SetBottomRight(val Geoposition) Georectangle {
|
||||
s._BottomRight = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,944 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("RemotePhoto",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0), false},
|
||||
types.Field{"Sizes", types.MakeCompoundType(types.MapKind, types.MakeType(ref.Ref{}, 2), types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Tags", types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Faces", types.MakeCompoundType(types.SetKind, types.MakeType(ref.Ref{}, 1)), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Face",
|
||||
[]types.Field{
|
||||
types.Field{"Top", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Left", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"PersonName", types.MakePrimitiveType(types.StringKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Size",
|
||||
[]types.Field{
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// RemotePhoto
|
||||
|
||||
type RemotePhoto struct {
|
||||
_Id string
|
||||
_Title string
|
||||
_Date Date
|
||||
_Geoposition Geoposition
|
||||
_Sizes MapOfSizeToString
|
||||
_Tags SetOfString
|
||||
_Faces SetOfFace
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRemotePhoto() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: "",
|
||||
_Title: "",
|
||||
_Date: NewDate(),
|
||||
_Geoposition: NewGeoposition(),
|
||||
_Sizes: NewMapOfSizeToString(),
|
||||
_Tags: NewSetOfString(),
|
||||
_Faces: NewSetOfFace(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type RemotePhotoDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Date DateDef
|
||||
Geoposition GeopositionDef
|
||||
Sizes MapOfSizeToStringDef
|
||||
Tags SetOfStringDef
|
||||
Faces SetOfFaceDef
|
||||
}
|
||||
|
||||
func (def RemotePhotoDef) New() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: def.Id,
|
||||
_Title: def.Title,
|
||||
_Date: def.Date.New(),
|
||||
_Geoposition: def.Geoposition.New(),
|
||||
_Sizes: def.Sizes.New(),
|
||||
_Tags: def.Tags.New(),
|
||||
_Faces: def.Faces.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Def() (d RemotePhotoDef) {
|
||||
d.Id = s._Id
|
||||
d.Title = s._Title
|
||||
d.Date = s._Date.Def()
|
||||
d.Geoposition = s._Geoposition.Def()
|
||||
d.Sizes = s._Sizes.Def()
|
||||
d.Tags = s._Tags.Def()
|
||||
d.Faces = s._Faces.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForRemotePhoto types.Type
|
||||
|
||||
func (m RemotePhoto) Type() types.Type {
|
||||
return __typeForRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRemotePhoto = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)
|
||||
types.RegisterStruct(__typeForRemotePhoto, builderForRemotePhoto, readerForRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRemotePhoto(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := RemotePhoto{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(Date)
|
||||
i++
|
||||
s._Geoposition = values[i].(Geoposition)
|
||||
i++
|
||||
s._Sizes = values[i].(MapOfSizeToString)
|
||||
i++
|
||||
s._Tags = values[i].(SetOfString)
|
||||
i++
|
||||
s._Faces = values[i].(SetOfFace)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForRemotePhoto(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(RemotePhoto)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, s._Date)
|
||||
values = append(values, s._Geoposition)
|
||||
values = append(values, s._Sizes)
|
||||
values = append(values, s._Tags)
|
||||
values = append(values, s._Faces)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForRemotePhoto.Chunks()...)
|
||||
chunks = append(chunks, s._Date.Chunks()...)
|
||||
chunks = append(chunks, s._Geoposition.Chunks()...)
|
||||
chunks = append(chunks, s._Sizes.Chunks()...)
|
||||
chunks = append(chunks, s._Tags.Chunks()...)
|
||||
chunks = append(chunks, s._Faces.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, s._Date)
|
||||
ret = append(ret, s._Geoposition)
|
||||
ret = append(ret, s._Sizes)
|
||||
ret = append(ret, s._Tags)
|
||||
ret = append(ret, s._Faces)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(val string) RemotePhoto {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(val string) RemotePhoto {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Date() Date {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetDate(val Date) RemotePhoto {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Geoposition() Geoposition {
|
||||
return s._Geoposition
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetGeoposition(val Geoposition) RemotePhoto {
|
||||
s._Geoposition = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return s._Sizes
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(val MapOfSizeToString) RemotePhoto {
|
||||
s._Sizes = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Tags() SetOfString {
|
||||
return s._Tags
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTags(val SetOfString) RemotePhoto {
|
||||
s._Tags = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Faces() SetOfFace {
|
||||
return s._Faces
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetFaces(val SetOfFace) RemotePhoto {
|
||||
s._Faces = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Face
|
||||
|
||||
type Face struct {
|
||||
_Top float32
|
||||
_Left float32
|
||||
_Width float32
|
||||
_Height float32
|
||||
_PersonName string
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewFace() Face {
|
||||
return Face{
|
||||
_Top: float32(0),
|
||||
_Left: float32(0),
|
||||
_Width: float32(0),
|
||||
_Height: float32(0),
|
||||
_PersonName: "",
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type FaceDef struct {
|
||||
Top float32
|
||||
Left float32
|
||||
Width float32
|
||||
Height float32
|
||||
PersonName string
|
||||
}
|
||||
|
||||
func (def FaceDef) New() Face {
|
||||
return Face{
|
||||
_Top: def.Top,
|
||||
_Left: def.Left,
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
_PersonName: def.PersonName,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Face) Def() (d FaceDef) {
|
||||
d.Top = s._Top
|
||||
d.Left = s._Left
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
d.PersonName = s._PersonName
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForFace types.Type
|
||||
|
||||
func (m Face) Type() types.Type {
|
||||
return __typeForFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForFace = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1)
|
||||
types.RegisterStruct(__typeForFace, builderForFace, readerForFace)
|
||||
}
|
||||
|
||||
func builderForFace(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Face{ref: &ref.Ref{}}
|
||||
s._Top = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Left = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Width = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Height = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._PersonName = values[i].(types.String).String()
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForFace(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Face)
|
||||
values = append(values, types.Float32(s._Top))
|
||||
values = append(values, types.Float32(s._Left))
|
||||
values = append(values, types.Float32(s._Width))
|
||||
values = append(values, types.Float32(s._Height))
|
||||
values = append(values, types.NewString(s._PersonName))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Face) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Face) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Face) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForFace.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Top))
|
||||
ret = append(ret, types.Float32(s._Left))
|
||||
ret = append(ret, types.Float32(s._Width))
|
||||
ret = append(ret, types.Float32(s._Height))
|
||||
ret = append(ret, types.NewString(s._PersonName))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) Top() float32 {
|
||||
return s._Top
|
||||
}
|
||||
|
||||
func (s Face) SetTop(val float32) Face {
|
||||
s._Top = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Left() float32 {
|
||||
return s._Left
|
||||
}
|
||||
|
||||
func (s Face) SetLeft(val float32) Face {
|
||||
s._Left = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Width() float32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Face) SetWidth(val float32) Face {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Height() float32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Face) SetHeight(val float32) Face {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) PersonName() string {
|
||||
return s._PersonName
|
||||
}
|
||||
|
||||
func (s Face) SetPersonName(val string) Face {
|
||||
s._PersonName = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Size
|
||||
|
||||
type Size struct {
|
||||
_Width uint32
|
||||
_Height uint32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{
|
||||
_Width: uint32(0),
|
||||
_Height: uint32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type SizeDef struct {
|
||||
Width uint32
|
||||
Height uint32
|
||||
}
|
||||
|
||||
func (def SizeDef) New() Size {
|
||||
return Size{
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Size) Def() (d SizeDef) {
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForSize types.Type
|
||||
|
||||
func (m Size) Type() types.Type {
|
||||
return __typeForSize
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSize = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2)
|
||||
types.RegisterStruct(__typeForSize, builderForSize, readerForSize)
|
||||
}
|
||||
|
||||
func builderForSize(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Size{ref: &ref.Ref{}}
|
||||
s._Width = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
s._Height = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForSize(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Size)
|
||||
values = append(values, types.Uint32(s._Width))
|
||||
values = append(values, types.Uint32(s._Height))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Size) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSize.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Size) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForSize.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Uint32(s._Width))
|
||||
ret = append(ret, types.Uint32(s._Height))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) Width() uint32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(val uint32) Size {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Size) Height() uint32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(val uint32) Size {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringDef map[SizeDef]string
|
||||
|
||||
func (def MapOfSizeToStringDef) New() MapOfSizeToString {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, k.New(), types.NewString(v))
|
||||
}
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Def() MapOfSizeToStringDef {
|
||||
def := make(map[SizeDef]string)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(Size).Def()] = v.(types.String).String()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfSizeToString.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfSizeToString.
|
||||
var __typeForMapOfSizeToString types.Type
|
||||
|
||||
func (m MapOfSizeToString) Type() types.Type {
|
||||
return __typeForMapOfSizeToString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfSizeToString = types.MakeCompoundType(types.MapKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2), types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForMapOfSizeToString, builderForMapOfSizeToString, readerForMapOfSizeToString)
|
||||
}
|
||||
|
||||
func builderForMapOfSizeToString(v types.Value) types.Value {
|
||||
return MapOfSizeToString{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfSizeToString(v types.Value) types.Value {
|
||||
return v.(MapOfSizeToString).m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) string {
|
||||
return m.m.Get(p).(types.String).String()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) MaybeGet(p Size) (string, bool) {
|
||||
v, ok := m.m.MaybeGet(p)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return v.(types.String).String(), ok
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v string) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Set(k, types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Remove(p), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback func(k Size, v string) (stop bool)
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterAllCallback func(k Size, v string)
|
||||
|
||||
func (m MapOfSizeToString) IterAll(cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) IterAllP(concurrency int, cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringFilterCallback func(k Size, v string) (keep bool)
|
||||
|
||||
func (m MapOfSizeToString) Filter(cb MapOfSizeToStringFilterCallback) MapOfSizeToString {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
return MapOfSizeToString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
|
||||
func (def SetOfStringDef) New() SetOfString {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
def := make(map[string]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(types.String).String()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfString.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfString.
|
||||
var __typeForSetOfString types.Type
|
||||
|
||||
func (m SetOfString) Type() types.Type {
|
||||
return __typeForSetOfString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfString = types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForSetOfString, builderForSetOfString, readerForSetOfString)
|
||||
}
|
||||
|
||||
func builderForSetOfString(v types.Value) types.Value {
|
||||
return SetOfString{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfString(v types.Value) types.Value {
|
||||
return v.(SetOfString).s
|
||||
}
|
||||
|
||||
func (s SetOfString) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfString) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfString) Has(p string) bool {
|
||||
return s.s.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
type SetOfStringIterCallback func(p string) (stop bool)
|
||||
|
||||
func (s SetOfString) Iter(cb SetOfStringIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringIterAllCallback func(p string)
|
||||
|
||||
func (s SetOfString) IterAll(cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfString) IterAllP(concurrency int, cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringFilterCallback func(p string) (keep bool)
|
||||
|
||||
func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
return SetOfString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) First() string {
|
||||
return s.s.First().(types.String).String()
|
||||
}
|
||||
|
||||
func (s SetOfString) fromStructSlice(p []SetOfString) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfString) fromElemSlice(p []string) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = types.NewString(v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// SetOfFace
|
||||
|
||||
type SetOfFace struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfFace() SetOfFace {
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfFaceDef map[FaceDef]bool
|
||||
|
||||
func (def SetOfFaceDef) New() SetOfFace {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = d.New()
|
||||
i++
|
||||
}
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Def() SetOfFaceDef {
|
||||
def := make(map[FaceDef]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(Face).Def()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfFace) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfFace) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfFace) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfFace.
|
||||
var __typeForSetOfFace types.Type
|
||||
|
||||
func (m SetOfFace) Type() types.Type {
|
||||
return __typeForSetOfFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfFace = types.MakeCompoundType(types.SetKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1))
|
||||
types.RegisterValue(__typeForSetOfFace, builderForSetOfFace, readerForSetOfFace)
|
||||
}
|
||||
|
||||
func builderForSetOfFace(v types.Value) types.Value {
|
||||
return SetOfFace{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfFace(v types.Value) types.Value {
|
||||
return v.(SetOfFace).s
|
||||
}
|
||||
|
||||
func (s SetOfFace) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Has(p Face) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfFaceIterCallback func(p Face) (stop bool)
|
||||
|
||||
func (s SetOfFace) Iter(cb SetOfFaceIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceIterAllCallback func(p Face)
|
||||
|
||||
func (s SetOfFace) IterAll(cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfFace) IterAllP(concurrency int, cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceFilterCallback func(p Face) (keep bool)
|
||||
|
||||
func (s SetOfFace) Filter(cb SetOfFaceFilterCallback) SetOfFace {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
return SetOfFace{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Insert(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Remove(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Union(others ...SetOfFace) SetOfFace {
|
||||
return SetOfFace{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) First() Face {
|
||||
return s.s.First().(Face)
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromStructSlice(p []SetOfFace) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromElemSlice(p []Face) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
alias Img = import "../common/photo.noms"
|
||||
|
||||
struct User {
|
||||
Id: String
|
||||
Name: String
|
||||
Albums: Map<String, Ref<Album>>
|
||||
}
|
||||
|
||||
struct Album {
|
||||
Id: String
|
||||
Title: String
|
||||
Photos: Set<Ref<Img.RemotePhoto>>
|
||||
}
|
||||
|
||||
using Ref<User>
|
||||
@@ -1,734 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("User",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Name", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Albums", types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Ref{}, 1))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Album",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Photos", types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// User
|
||||
|
||||
type User struct {
|
||||
_Id string
|
||||
_Name string
|
||||
_Albums MapOfStringToRefOfAlbum
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewUser() User {
|
||||
return User{
|
||||
_Id: "",
|
||||
_Name: "",
|
||||
_Albums: NewMapOfStringToRefOfAlbum(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type UserDef struct {
|
||||
Id string
|
||||
Name string
|
||||
Albums MapOfStringToRefOfAlbumDef
|
||||
}
|
||||
|
||||
func (def UserDef) New() User {
|
||||
return User{
|
||||
_Id: def.Id,
|
||||
_Name: def.Name,
|
||||
_Albums: def.Albums.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s User) Def() (d UserDef) {
|
||||
d.Id = s._Id
|
||||
d.Name = s._Name
|
||||
d.Albums = s._Albums.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForUser types.Type
|
||||
|
||||
func (m User) Type() types.Type {
|
||||
return __typeForUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForUser = types.MakeType(ref.Parse("sha1-6ff3435146ddf2b1373084026be32dc5a8e09d4d"), 0)
|
||||
types.RegisterStruct(__typeForUser, builderForUser, readerForUser)
|
||||
}
|
||||
|
||||
func builderForUser(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := User{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Name = values[i].(types.String).String()
|
||||
i++
|
||||
s._Albums = values[i].(MapOfStringToRefOfAlbum)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForUser(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(User)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Name))
|
||||
values = append(values, s._Albums)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s User) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForUser.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s User) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s User) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForUser.Chunks()...)
|
||||
chunks = append(chunks, s._Albums.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Name))
|
||||
ret = append(ret, s._Albums)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s User) SetId(val string) User {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Name() string {
|
||||
return s._Name
|
||||
}
|
||||
|
||||
func (s User) SetName(val string) User {
|
||||
s._Name = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Albums() MapOfStringToRefOfAlbum {
|
||||
return s._Albums
|
||||
}
|
||||
|
||||
func (s User) SetAlbums(val MapOfStringToRefOfAlbum) User {
|
||||
s._Albums = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Album
|
||||
|
||||
type Album struct {
|
||||
_Id string
|
||||
_Title string
|
||||
_Photos SetOfRefOfRemotePhoto
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewAlbum() Album {
|
||||
return Album{
|
||||
_Id: "",
|
||||
_Title: "",
|
||||
_Photos: NewSetOfRefOfRemotePhoto(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type AlbumDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Photos SetOfRefOfRemotePhotoDef
|
||||
}
|
||||
|
||||
func (def AlbumDef) New() Album {
|
||||
return Album{
|
||||
_Id: def.Id,
|
||||
_Title: def.Title,
|
||||
_Photos: def.Photos.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Album) Def() (d AlbumDef) {
|
||||
d.Id = s._Id
|
||||
d.Title = s._Title
|
||||
d.Photos = s._Photos.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForAlbum types.Type
|
||||
|
||||
func (m Album) Type() types.Type {
|
||||
return __typeForAlbum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForAlbum = types.MakeType(ref.Parse("sha1-6ff3435146ddf2b1373084026be32dc5a8e09d4d"), 1)
|
||||
types.RegisterStruct(__typeForAlbum, builderForAlbum, readerForAlbum)
|
||||
}
|
||||
|
||||
func builderForAlbum(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Album{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Photos = values[i].(SetOfRefOfRemotePhoto)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForAlbum(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Album)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, s._Photos)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Album) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForAlbum.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Album) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Album) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForAlbum.Chunks()...)
|
||||
chunks = append(chunks, s._Photos.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Album) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, s._Photos)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Album) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s Album) SetId(val string) Album {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Album) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s Album) SetTitle(val string) Album {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Album) Photos() SetOfRefOfRemotePhoto {
|
||||
return s._Photos
|
||||
}
|
||||
|
||||
func (s Album) SetPhotos(val SetOfRefOfRemotePhoto) Album {
|
||||
s._Photos = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// RefOfUser
|
||||
|
||||
type RefOfUser struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfUser(target ref.Ref) RefOfUser {
|
||||
return RefOfUser{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfUser) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfUser.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfUser) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfUser) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfUser.
|
||||
var __typeForRefOfUser types.Type
|
||||
|
||||
func (r RefOfUser) Type() types.Type {
|
||||
return __typeForRefOfUser
|
||||
}
|
||||
|
||||
func (r RefOfUser) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfUser = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-6ff3435146ddf2b1373084026be32dc5a8e09d4d"), 0))
|
||||
types.RegisterRef(__typeForRefOfUser, builderForRefOfUser)
|
||||
}
|
||||
|
||||
func builderForRefOfUser(r ref.Ref) types.RefBase {
|
||||
return NewRefOfUser(r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetValue(vr types.ValueReader) User {
|
||||
return vr.ReadValue(r.target).(User)
|
||||
}
|
||||
|
||||
// MapOfStringToRefOfAlbum
|
||||
|
||||
type MapOfStringToRefOfAlbum struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToRefOfAlbum() MapOfStringToRefOfAlbum {
|
||||
return MapOfStringToRefOfAlbum{types.NewTypedMap(__typeForMapOfStringToRefOfAlbum), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfAlbumDef map[string]ref.Ref
|
||||
|
||||
func (def MapOfStringToRefOfAlbumDef) New() MapOfStringToRefOfAlbum {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), NewRefOfAlbum(v))
|
||||
}
|
||||
return MapOfStringToRefOfAlbum{types.NewTypedMap(__typeForMapOfStringToRefOfAlbum, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Def() MapOfStringToRefOfAlbumDef {
|
||||
def := make(map[string]ref.Ref)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = v.(RefOfAlbum).TargetRef()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfStringToRefOfAlbum.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfStringToRefOfAlbum.
|
||||
var __typeForMapOfStringToRefOfAlbum types.Type
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Type() types.Type {
|
||||
return __typeForMapOfStringToRefOfAlbum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfStringToRefOfAlbum = types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-6ff3435146ddf2b1373084026be32dc5a8e09d4d"), 1)))
|
||||
types.RegisterValue(__typeForMapOfStringToRefOfAlbum, builderForMapOfStringToRefOfAlbum, readerForMapOfStringToRefOfAlbum)
|
||||
}
|
||||
|
||||
func builderForMapOfStringToRefOfAlbum(v types.Value) types.Value {
|
||||
return MapOfStringToRefOfAlbum{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfStringToRefOfAlbum(v types.Value) types.Value {
|
||||
return v.(MapOfStringToRefOfAlbum).m
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Has(p string) bool {
|
||||
return m.m.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Get(p string) RefOfAlbum {
|
||||
return m.m.Get(types.NewString(p)).(RefOfAlbum)
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) MaybeGet(p string) (RefOfAlbum, bool) {
|
||||
v, ok := m.m.MaybeGet(types.NewString(p))
|
||||
if !ok {
|
||||
return NewRefOfAlbum(ref.Ref{}), false
|
||||
}
|
||||
return v.(RefOfAlbum), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Set(k string, v RefOfAlbum) MapOfStringToRefOfAlbum {
|
||||
return MapOfStringToRefOfAlbum{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Remove(p string) MapOfStringToRefOfAlbum {
|
||||
return MapOfStringToRefOfAlbum{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfAlbumIterCallback func(k string, v RefOfAlbum) (stop bool)
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Iter(cb MapOfStringToRefOfAlbumIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfAlbum))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfAlbumIterAllCallback func(k string, v RefOfAlbum)
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) IterAll(cb MapOfStringToRefOfAlbumIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfAlbum))
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) IterAllP(concurrency int, cb MapOfStringToRefOfAlbumIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v.(RefOfAlbum))
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToRefOfAlbumFilterCallback func(k string, v RefOfAlbum) (keep bool)
|
||||
|
||||
func (m MapOfStringToRefOfAlbum) Filter(cb MapOfStringToRefOfAlbumFilterCallback) MapOfStringToRefOfAlbum {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v.(RefOfAlbum))
|
||||
})
|
||||
return MapOfStringToRefOfAlbum{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfRefOfRemotePhoto
|
||||
|
||||
type SetOfRefOfRemotePhoto struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfRefOfRemotePhoto() SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoDef map[ref.Ref]bool
|
||||
|
||||
func (def SetOfRefOfRemotePhotoDef) New() SetOfRefOfRemotePhoto {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = NewRefOfRemotePhoto(d)
|
||||
i++
|
||||
}
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Def() SetOfRefOfRemotePhotoDef {
|
||||
def := make(map[ref.Ref]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(RefOfRemotePhoto).TargetRef()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfRefOfRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfRefOfRemotePhoto.
|
||||
var __typeForSetOfRefOfRemotePhoto types.Type
|
||||
|
||||
func (m SetOfRefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForSetOfRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfRefOfRemotePhoto = types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)))
|
||||
types.RegisterValue(__typeForSetOfRefOfRemotePhoto, builderForSetOfRefOfRemotePhoto, readerForSetOfRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return SetOfRefOfRemotePhoto{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return v.(SetOfRefOfRemotePhoto).s
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Has(p RefOfRemotePhoto) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterCallback func(p RefOfRemotePhoto) (stop bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Iter(cb SetOfRefOfRemotePhotoIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterAllCallback func(p RefOfRemotePhoto)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAll(cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAllP(concurrency int, cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoFilterCallback func(p RefOfRemotePhoto) (keep bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Filter(cb SetOfRefOfRemotePhotoFilterCallback) SetOfRefOfRemotePhoto {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
return SetOfRefOfRemotePhoto{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Insert(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Remove(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Union(others ...SetOfRefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) First() RefOfRemotePhoto {
|
||||
return s.s.First().(RefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromStructSlice(p []SetOfRefOfRemotePhoto) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromElemSlice(p []RefOfRemotePhoto) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// RefOfAlbum
|
||||
|
||||
type RefOfAlbum struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfAlbum(target ref.Ref) RefOfAlbum {
|
||||
return RefOfAlbum{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfAlbum.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfAlbum.
|
||||
var __typeForRefOfAlbum types.Type
|
||||
|
||||
func (r RefOfAlbum) Type() types.Type {
|
||||
return __typeForRefOfAlbum
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfAlbum = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-6ff3435146ddf2b1373084026be32dc5a8e09d4d"), 1))
|
||||
types.RegisterRef(__typeForRefOfAlbum, builderForRefOfAlbum)
|
||||
}
|
||||
|
||||
func builderForRefOfAlbum(r ref.Ref) types.RefBase {
|
||||
return NewRefOfAlbum(r)
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) TargetValue(vr types.ValueReader) Album {
|
||||
return vr.ReadValue(r.target).(Album)
|
||||
}
|
||||
|
||||
// RefOfRemotePhoto
|
||||
|
||||
type RefOfRemotePhoto struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfRemotePhoto(target ref.Ref) RefOfRemotePhoto {
|
||||
return RefOfRemotePhoto{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfRemotePhoto.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfRemotePhoto.
|
||||
var __typeForRefOfRemotePhoto types.Type
|
||||
|
||||
func (r RefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfRemotePhoto = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))
|
||||
types.RegisterRef(__typeForRefOfRemotePhoto, builderForRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRefOfRemotePhoto(r ref.Ref) types.RefBase {
|
||||
return NewRefOfRemotePhoto(r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetValue(vr types.ValueReader) RemotePhoto {
|
||||
return vr.ReadValue(r.target).(RemotePhoto)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
Slurps mp3 files into a noms db.
|
||||
|
||||
Depends on [id3-go](https://github.com/mikkyang/id3-go). To install:
|
||||
```
|
||||
cd "$GOPATH/src/github.com"
|
||||
git clone https://github.com/mikkyang/id3-go.git
|
||||
```
|
||||
|
||||
Possible usage, if you have mp3 files in your Music directory:
|
||||
```
|
||||
find ~/Music -name '*.mp3' -exec ./mp3_importer -ldb /tmp/mp3_importer -ds main -add {} \;
|
||||
./mp3_importer -ldb /tmp/mp3_importer -ds main -list
|
||||
```
|
||||
@@ -1,99 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/types"
|
||||
id3go "github.com/mikkyang/id3-go"
|
||||
)
|
||||
|
||||
var (
|
||||
addFlag = flag.String("add", "", "Add a file to the music database")
|
||||
// TODO: Pull listing into a separate binary. There isn't anything in the music database specific to mp3.
|
||||
listFlag = flag.Bool("ls", false, "List music files")
|
||||
)
|
||||
|
||||
func addMp3(ds *dataset.Dataset, filename string) {
|
||||
id3, err := id3go.Open(filename)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read id3 data from %s: %s\n", filename, err)
|
||||
}
|
||||
defer id3.Close()
|
||||
|
||||
mp3_file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open %s: %s\n", filename, err)
|
||||
}
|
||||
defer mp3_file.Close()
|
||||
|
||||
new_song := SongDef{
|
||||
Title: id3.Title(),
|
||||
Artist: id3.Artist(),
|
||||
Album: id3.Album(),
|
||||
Year: id3.Year(),
|
||||
Mp3: types.NewBlob(bufio.NewReader(mp3_file)),
|
||||
}.New()
|
||||
songs := readSongsFromDataset(ds).Append(new_song)
|
||||
if _, err := ds.Commit(songs); err == nil {
|
||||
fmt.Println("Successfully committed", filename)
|
||||
printSong(new_song)
|
||||
} else {
|
||||
log.Fatalf("Failed to commit: %s, error: %s\n", filename, err)
|
||||
}
|
||||
}
|
||||
|
||||
func listSongs(ds *dataset.Dataset) {
|
||||
songs := readSongsFromDataset(ds)
|
||||
switch num_songs := songs.Len(); num_songs {
|
||||
case 0:
|
||||
fmt.Println("No songs yet")
|
||||
case 1:
|
||||
fmt.Println("Found 1 song")
|
||||
default:
|
||||
fmt.Println("Found", num_songs, "songs")
|
||||
}
|
||||
songs.IterAll(func(song Song, i uint64) {
|
||||
fmt.Printf("(%d)\n", i)
|
||||
printSong(song)
|
||||
})
|
||||
}
|
||||
|
||||
func readSongsFromDataset(ds *dataset.Dataset) ListOfSong {
|
||||
songs := NewListOfSong()
|
||||
if commit, ok := ds.MaybeHead(); ok {
|
||||
songs = commit.Value().(ListOfSong)
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
func printSong(song Song) {
|
||||
fmt.Println(" Title:", song.Title())
|
||||
fmt.Println(" Artist:", song.Artist())
|
||||
fmt.Println(" Album:", song.Album())
|
||||
fmt.Println(" Year:", song.Year())
|
||||
fmt.Println(" Size:", song.Mp3().Len())
|
||||
}
|
||||
|
||||
func main() {
|
||||
dsFlags := dataset.NewFlags()
|
||||
flag.Parse()
|
||||
|
||||
ds := dsFlags.CreateDataset()
|
||||
if ds == nil {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
if *addFlag != "" {
|
||||
addMp3(ds, *addFlag)
|
||||
}
|
||||
if *listFlag {
|
||||
listSongs(ds)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../../nomdl/codegen/codegen.go
|
||||
@@ -1,9 +0,0 @@
|
||||
struct Song {
|
||||
Title: String
|
||||
Artist: String
|
||||
Album: String
|
||||
Year: String
|
||||
Mp3: Blob
|
||||
}
|
||||
|
||||
using List<Song>
|
||||
@@ -1,332 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Song",
|
||||
[]types.Field{
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Artist", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Album", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Year", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Mp3", types.MakePrimitiveType(types.BlobKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Song
|
||||
|
||||
type Song struct {
|
||||
_Title string
|
||||
_Artist string
|
||||
_Album string
|
||||
_Year string
|
||||
_Mp3 types.Blob
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSong() Song {
|
||||
return Song{
|
||||
_Title: "",
|
||||
_Artist: "",
|
||||
_Album: "",
|
||||
_Year: "",
|
||||
_Mp3: types.NewEmptyBlob(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type SongDef struct {
|
||||
Title string
|
||||
Artist string
|
||||
Album string
|
||||
Year string
|
||||
Mp3 types.Blob
|
||||
}
|
||||
|
||||
func (def SongDef) New() Song {
|
||||
return Song{
|
||||
_Title: def.Title,
|
||||
_Artist: def.Artist,
|
||||
_Album: def.Album,
|
||||
_Year: def.Year,
|
||||
_Mp3: def.Mp3,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Song) Def() (d SongDef) {
|
||||
d.Title = s._Title
|
||||
d.Artist = s._Artist
|
||||
d.Album = s._Album
|
||||
d.Year = s._Year
|
||||
d.Mp3 = s._Mp3
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForSong types.Type
|
||||
|
||||
func (m Song) Type() types.Type {
|
||||
return __typeForSong
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSong = types.MakeType(ref.Parse("sha1-e8d7435377905892095ccb721a3b4e88f504589b"), 0)
|
||||
types.RegisterStruct(__typeForSong, builderForSong, readerForSong)
|
||||
}
|
||||
|
||||
func builderForSong(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Song{ref: &ref.Ref{}}
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Artist = values[i].(types.String).String()
|
||||
i++
|
||||
s._Album = values[i].(types.String).String()
|
||||
i++
|
||||
s._Year = values[i].(types.String).String()
|
||||
i++
|
||||
s._Mp3 = values[i].(types.Blob)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForSong(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Song)
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, types.NewString(s._Artist))
|
||||
values = append(values, types.NewString(s._Album))
|
||||
values = append(values, types.NewString(s._Year))
|
||||
values = append(values, s._Mp3)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Song) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSong.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Song) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Song) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForSong.Chunks()...)
|
||||
chunks = append(chunks, s._Mp3.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Song) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, types.NewString(s._Artist))
|
||||
ret = append(ret, types.NewString(s._Album))
|
||||
ret = append(ret, types.NewString(s._Year))
|
||||
ret = append(ret, s._Mp3)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Song) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s Song) SetTitle(val string) Song {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Song) Artist() string {
|
||||
return s._Artist
|
||||
}
|
||||
|
||||
func (s Song) SetArtist(val string) Song {
|
||||
s._Artist = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Song) Album() string {
|
||||
return s._Album
|
||||
}
|
||||
|
||||
func (s Song) SetAlbum(val string) Song {
|
||||
s._Album = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Song) Year() string {
|
||||
return s._Year
|
||||
}
|
||||
|
||||
func (s Song) SetYear(val string) Song {
|
||||
s._Year = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Song) Mp3() types.Blob {
|
||||
return s._Mp3
|
||||
}
|
||||
|
||||
func (s Song) SetMp3(val types.Blob) Song {
|
||||
s._Mp3 = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// ListOfSong
|
||||
|
||||
type ListOfSong struct {
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfSong() ListOfSong {
|
||||
return ListOfSong{types.NewTypedList(__typeForListOfSong), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfSongDef []SongDef
|
||||
|
||||
func (def ListOfSongDef) New() ListOfSong {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfSong{types.NewTypedList(__typeForListOfSong, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Def() ListOfSongDef {
|
||||
d := make([]SongDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = l.l.Get(i).(Song).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (l ListOfSong) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForListOfSong.Equals(other.Type()) && l.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (l ListOfSong) Ref() ref.Ref {
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfSong) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, l.Type().Chunks()...)
|
||||
chunks = append(chunks, l.l.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (l ListOfSong) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, l.l.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes ListOfSong.
|
||||
var __typeForListOfSong types.Type
|
||||
|
||||
func (m ListOfSong) Type() types.Type {
|
||||
return __typeForListOfSong
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForListOfSong = types.MakeCompoundType(types.ListKind, types.MakeType(ref.Parse("sha1-e8d7435377905892095ccb721a3b4e88f504589b"), 0))
|
||||
types.RegisterValue(__typeForListOfSong, builderForListOfSong, readerForListOfSong)
|
||||
}
|
||||
|
||||
func builderForListOfSong(v types.Value) types.Value {
|
||||
return ListOfSong{v.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForListOfSong(v types.Value) types.Value {
|
||||
return v.(ListOfSong).l
|
||||
}
|
||||
|
||||
func (l ListOfSong) Len() uint64 {
|
||||
return l.l.Len()
|
||||
}
|
||||
|
||||
func (l ListOfSong) Empty() bool {
|
||||
return l.Len() == uint64(0)
|
||||
}
|
||||
|
||||
func (l ListOfSong) Get(i uint64) Song {
|
||||
return l.l.Get(i).(Song)
|
||||
}
|
||||
|
||||
func (l ListOfSong) Slice(idx uint64, end uint64) ListOfSong {
|
||||
return ListOfSong{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Set(i uint64, val Song) ListOfSong {
|
||||
return ListOfSong{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Append(v ...Song) ListOfSong {
|
||||
return ListOfSong{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Insert(idx uint64, v ...Song) ListOfSong {
|
||||
return ListOfSong{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Remove(idx uint64, end uint64) ListOfSong {
|
||||
return ListOfSong{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) RemoveAt(idx uint64) ListOfSong {
|
||||
return ListOfSong{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) fromElemSlice(p []Song) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ListOfSongIterCallback func(v Song, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfSong) Iter(cb ListOfSongIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(Song), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfSongIterAllCallback func(v Song, i uint64)
|
||||
|
||||
func (l ListOfSong) IterAll(cb ListOfSongIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(v.(Song), i)
|
||||
})
|
||||
}
|
||||
|
||||
func (l ListOfSong) IterAllP(concurrency int, cb ListOfSongIterAllCallback) {
|
||||
l.l.IterAllP(concurrency, func(v types.Value, i uint64) {
|
||||
cb(v.(Song), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfSongFilterCallback func(v Song, i uint64) (keep bool)
|
||||
|
||||
func (l ListOfSong) Filter(cb ListOfSongFilterCallback) ListOfSong {
|
||||
out := l.l.Filter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(Song), i)
|
||||
})
|
||||
return ListOfSong{out, &ref.Ref{}}
|
||||
}
|
||||
1
clients/picasa/.gitignore
vendored
1
clients/picasa/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
picasa
|
||||
@@ -1,356 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/util/http/retry"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
var (
|
||||
authHTTPClient *http.Client
|
||||
cachingHTTPClient *http.Client
|
||||
clientFlags = util.NewFlags()
|
||||
ds *dataset.Dataset
|
||||
tokenFlag = flag.String("token", "", "OAuth2 bearer token to authenticate with (required)")
|
||||
start time.Time
|
||||
)
|
||||
|
||||
type shapeMap map[string][]Shape
|
||||
|
||||
func main() {
|
||||
flag.Usage = picasaUsage
|
||||
flag.Parse()
|
||||
cachingHTTPClient = util.CachingHttpClient()
|
||||
|
||||
if *tokenFlag == "" || cachingHTTPClient == nil {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
util.MaybeStartCPUProfile()
|
||||
defer util.StopCPUProfile()
|
||||
|
||||
ds = clientFlags.CreateDataset()
|
||||
if ds == nil {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
if err := clientFlags.CreateProgressFile(); err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
defer clientFlags.CloseProgressFile()
|
||||
}
|
||||
|
||||
token := oauth2.Token{AccessToken: *tokenFlag}
|
||||
authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))
|
||||
|
||||
start = time.Now()
|
||||
user := getUser()
|
||||
|
||||
userRef := ds.Store().WriteValue(user)
|
||||
fmt.Printf("userRef: %s\n", userRef)
|
||||
_, err := ds.Commit(userRef)
|
||||
d.Exp.NoError(err)
|
||||
}
|
||||
|
||||
func picasaUsage() {
|
||||
essay := `You must provide -token, an OAuth2 bearer token. It will look like ab12.adsDshDsjkkdljkddhASDhjksdSAs-asjASDhADSs-asdhjdAs-SDSADhlDSAhlsjsAs. To get one:
|
||||
1) Go to https://developers.google.com/oauthplayground.
|
||||
2) Enter https://picasaweb.google.com/data in the "Input your own scopes" box, click "Authorize APIs".
|
||||
3) Click "Allow".
|
||||
4) Click "Exchange authorization code for tokens".
|
||||
5) Copy the "Access token" field (e.g. ab12.adsDshDsjkkdljkddhASDhjksdSAs-asjASDhADSs-asdhjdAs-SDSADhlDSAhlsjsAs).`
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
fmt.Fprintf(os.Stderr, "\n%s\n\n", essay)
|
||||
}
|
||||
|
||||
func getUser() User {
|
||||
alj := AlbumListJSON{}
|
||||
callPicasaAPI(authHTTPClient, "user/default?alt=json", &alj)
|
||||
|
||||
numPhotos := 0
|
||||
for _, entry := range alj.Feed.Entry {
|
||||
numPhotos += entry.NumPhotos.V
|
||||
}
|
||||
fmt.Printf("Found %d albums with %d photos\n", len(alj.Feed.Entry), numPhotos)
|
||||
|
||||
progress := make(chan interface{}, clientFlags.Concurrency()*100)
|
||||
go func() {
|
||||
lastUpdate := time.Now()
|
||||
added := 0
|
||||
for range progress {
|
||||
added++
|
||||
if now := time.Now(); now.Sub(lastUpdate)/time.Millisecond >= 200 {
|
||||
clientFlags.UpdateProgress(float32(added) / float32(numPhotos))
|
||||
lastUpdate = now
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
albums := ListOfRefOfAlbumDef{}
|
||||
user := NewUser().
|
||||
SetId(alj.Feed.UserID.V).
|
||||
SetName(alj.Feed.UserName.V)
|
||||
|
||||
ch := make(chan Album, len(alj.Feed.Entry))
|
||||
lim := make(chan struct{}, clientFlags.Concurrency())
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(alj.Feed.Entry))
|
||||
for i, entry := range alj.Feed.Entry {
|
||||
i := i
|
||||
entry := entry
|
||||
lim <- struct{}{}
|
||||
go func() {
|
||||
ch <- getAlbum(i, entry.ID.V, entry.Title.V, entry.NumPhotos.V, progress)
|
||||
<-lim
|
||||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
album := <-ch
|
||||
// TODO: batch write albums.
|
||||
r := ds.Store().WriteValue(album).TargetRef()
|
||||
albums = append(albums, r)
|
||||
wg.Done()
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
close(progress)
|
||||
|
||||
clientFlags.UpdateProgress(1.0)
|
||||
return user.SetAlbums(albums.New())
|
||||
}
|
||||
|
||||
func getShapes(albumId string) shapeMap {
|
||||
rc := callPicasaURL(authHTTPClient, fmt.Sprintf("https://picasaweb.google.com/data/feed/back_compat/user/default/albumid/%s?alt=rss&kind=photo&v=4&fd=shapes2", albumId))
|
||||
defer rc.Close()
|
||||
|
||||
var shapes ShapesJSON
|
||||
err := xml.NewDecoder(rc).Decode(&shapes)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
res := shapeMap{}
|
||||
for _, item := range shapes.Channel.Item {
|
||||
for _, shape := range item.Shapes.Shape {
|
||||
res[item.ID] = append(res[item.ID], shape)
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func getAlbum(albumIndex int, albumId, albumTitle string, numPhotos int, progress chan interface{}) Album {
|
||||
shapes := getShapes(albumId)
|
||||
a := NewAlbum().
|
||||
SetId(albumId).
|
||||
SetTitle(albumTitle)
|
||||
if numPhotos != 0 {
|
||||
fmt.Printf("Album #%d: %q contains %d photos...\n", albumIndex, a.Title(), numPhotos)
|
||||
remotePhotos := getRemotePhotos(albumId, numPhotos, shapes, progress)
|
||||
a = a.SetPhotos(remotePhotos)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func getRemotePhotos(albumId string, numPhotos int, shapes shapeMap, progress chan interface{}) SetOfRefOfRemotePhoto {
|
||||
mu := sync.Mutex{}
|
||||
remotePhotos := SetOfRefOfRemotePhotoDef{}
|
||||
|
||||
batchSize := 1000
|
||||
batches := int(math.Ceil(float64(numPhotos) / float64(batchSize)))
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(batches)
|
||||
|
||||
for i := 0; i < batches; i++ {
|
||||
i := i
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
startIndex := i * batchSize
|
||||
aj := AlbumJSON{}
|
||||
path := fmt.Sprintf("user/default/albumid/%s?alt=json&max-results=1000", albumId)
|
||||
if startIndex > 0 {
|
||||
path = fmt.Sprintf("%s%s%d", path, "&start-index=", startIndex)
|
||||
}
|
||||
callPicasaAPI(authHTTPClient, path, &aj)
|
||||
for _, e := range aj.Feed.Entry {
|
||||
p := RemotePhotoDef{
|
||||
Id: e.ID.V,
|
||||
Title: e.Title.V,
|
||||
Geoposition: toGeopos(e.Geo.Point.Pos.V),
|
||||
Sizes: getSizes(e),
|
||||
Tags: splitTags(e.MediaGroup.Tags.V),
|
||||
Faces: getFaces(e, shapes),
|
||||
}.New()
|
||||
|
||||
// Timestamp is ms since the epoch.
|
||||
if ts, err := strconv.ParseInt(e.Timestamp.V, 10, 64); err == nil {
|
||||
p = p.SetDate(NewDate().SetMsSinceEpoch(ts))
|
||||
} else {
|
||||
fmt.Printf("Error parsing date \"%s\": %s\n", e.Timestamp.V, err)
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
// TODO: batch write photos.
|
||||
remotePhotos[ds.Store().WriteValue(p).TargetRef()] = true
|
||||
mu.Unlock()
|
||||
progress <- struct{}{}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
return remotePhotos.New()
|
||||
}
|
||||
|
||||
func parsePoint(s string) (x, y float32) {
|
||||
pair := strings.Split(s, " ")
|
||||
return float32(atoi(pair[0])), float32(atoi(pair[1]))
|
||||
}
|
||||
|
||||
func callPicasaAPI(client *http.Client, path string, response interface{}) {
|
||||
rc := callPicasaURL(client, "https://picasaweb.google.com/data/feed/api/"+path)
|
||||
defer rc.Close()
|
||||
err := json.NewDecoder(rc).Decode(response)
|
||||
d.Chk.NoError(err)
|
||||
}
|
||||
|
||||
func callPicasaURL(client *http.Client, url string) io.ReadCloser {
|
||||
return retry.Request(url, func() (*http.Response, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
d.Chk.NoError(err)
|
||||
req.Header.Add("GData-Version", "2")
|
||||
return client.Do(req)
|
||||
}).Body
|
||||
}
|
||||
|
||||
// General utility functions
|
||||
func toGeopos(s string) GeopositionDef {
|
||||
s1 := strings.TrimSpace(s)
|
||||
geoPos := GeopositionDef{Latitude: 0.0, Longitude: 0.0}
|
||||
if s1 != "" {
|
||||
slice := strings.Split(s1, " ")
|
||||
lat, err := strconv.ParseFloat(slice[0], 32)
|
||||
if err == nil {
|
||||
geoPos.Latitude = float32(lat)
|
||||
}
|
||||
lon, err := strconv.ParseFloat(slice[1], 32)
|
||||
if err == nil {
|
||||
geoPos.Longitude = float32(lon)
|
||||
}
|
||||
}
|
||||
return geoPos
|
||||
}
|
||||
|
||||
func toJSON(str interface{}) string {
|
||||
v, err := json.Marshal(str)
|
||||
d.Chk.NoError(err)
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func splitTags(s string) map[string]bool {
|
||||
tags := map[string]bool{}
|
||||
for _, s := range strings.Split(s, ",") {
|
||||
s1 := strings.Trim(s, " ")
|
||||
if s1 != "" {
|
||||
tags[s1] = true
|
||||
}
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func getSizes(e EntryJSON) MapOfSizeToStringDef {
|
||||
sizes := MapOfSizeToStringDef{}
|
||||
addSize := func(height, width int, url string) {
|
||||
sizes[SizeDef{Height: uint32(height), Width: uint32(width)}] = url
|
||||
}
|
||||
|
||||
sizePath := func(size int) string {
|
||||
return fmt.Sprintf("/s%d/", size)
|
||||
}
|
||||
|
||||
scale := func(x, a, b int) int {
|
||||
return int(math.Ceil(float64(x) * (float64(a) / float64(b))))
|
||||
}
|
||||
|
||||
// Don't use the URL to the full image, because Picasa sometimes incorrectly serves a smaller
|
||||
// image. E.g. e.Width.V might be 1000 and e.Height.V 500, but e.Content only 200x100.
|
||||
//
|
||||
// To work around this, use the URL for thumbnails with the full image size.
|
||||
height, width := atoi(e.Height.V), atoi(e.Width.V)
|
||||
|
||||
var thumbURLParts []string
|
||||
if t := e.MediaGroup.Thumbnails[0]; t.Height > t.Width {
|
||||
thumbURLParts = strings.SplitN(t.URL, sizePath(t.Height), 2)
|
||||
} else {
|
||||
thumbURLParts = strings.SplitN(t.URL, sizePath(t.Width), 2)
|
||||
}
|
||||
|
||||
// Add thumbnails.
|
||||
for _, px := range []int{128, 320, 640, 1024, 1600} {
|
||||
if px > height && px > width {
|
||||
break
|
||||
}
|
||||
|
||||
thumbURL := strings.Join(thumbURLParts, sizePath(px))
|
||||
if height > width {
|
||||
addSize(px, scale(px, width, height), thumbURL)
|
||||
} else {
|
||||
addSize(scale(px, height, width), px, thumbURL)
|
||||
}
|
||||
}
|
||||
|
||||
// Add the full image.
|
||||
if height > width {
|
||||
addSize(height, width, strings.Join(thumbURLParts, sizePath(height)))
|
||||
} else {
|
||||
addSize(height, width, strings.Join(thumbURLParts, sizePath(width)))
|
||||
}
|
||||
|
||||
return sizes
|
||||
}
|
||||
|
||||
func getFaces(e EntryJSON, shapes shapeMap) SetOfFaceDef {
|
||||
faces := SetOfFaceDef{}
|
||||
height, width := atoi(e.Height.V), atoi(e.Width.V)
|
||||
|
||||
for _, f := range shapes[e.ID.V] {
|
||||
l, t := parsePoint(f.UpperLeft)
|
||||
r, b := parsePoint(f.LowerRight)
|
||||
faces[FaceDef{
|
||||
Top: t / float32(height),
|
||||
Left: l / float32(width),
|
||||
Width: (r - l) / float32(width),
|
||||
Height: (b - t) / float32(height),
|
||||
PersonName: f.Name,
|
||||
}] = true
|
||||
}
|
||||
|
||||
return faces
|
||||
}
|
||||
|
||||
func atoi(a string) int {
|
||||
i, err := strconv.Atoi(a)
|
||||
d.Chk.NoError(err)
|
||||
return i
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
alias Img = import "../common/photo.noms"
|
||||
|
||||
struct User {
|
||||
Id: String
|
||||
Name: String
|
||||
Albums: List<Ref<Album>>
|
||||
}
|
||||
|
||||
struct Album {
|
||||
Id: String
|
||||
Title: String
|
||||
Photos: Set<Ref<Img.RemotePhoto>>
|
||||
}
|
||||
|
||||
using Ref<User>
|
||||
@@ -1,743 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("User",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Name", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Albums", types.MakeCompoundType(types.ListKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Ref{}, 1))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Album",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Photos", types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// User
|
||||
|
||||
type User struct {
|
||||
_Id string
|
||||
_Name string
|
||||
_Albums ListOfRefOfAlbum
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewUser() User {
|
||||
return User{
|
||||
_Id: "",
|
||||
_Name: "",
|
||||
_Albums: NewListOfRefOfAlbum(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type UserDef struct {
|
||||
Id string
|
||||
Name string
|
||||
Albums ListOfRefOfAlbumDef
|
||||
}
|
||||
|
||||
func (def UserDef) New() User {
|
||||
return User{
|
||||
_Id: def.Id,
|
||||
_Name: def.Name,
|
||||
_Albums: def.Albums.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s User) Def() (d UserDef) {
|
||||
d.Id = s._Id
|
||||
d.Name = s._Name
|
||||
d.Albums = s._Albums.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForUser types.Type
|
||||
|
||||
func (m User) Type() types.Type {
|
||||
return __typeForUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForUser = types.MakeType(ref.Parse("sha1-988f3a092d1b2cfe21f48d517b28b27a3fed4e95"), 0)
|
||||
types.RegisterStruct(__typeForUser, builderForUser, readerForUser)
|
||||
}
|
||||
|
||||
func builderForUser(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := User{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Name = values[i].(types.String).String()
|
||||
i++
|
||||
s._Albums = values[i].(ListOfRefOfAlbum)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForUser(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(User)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Name))
|
||||
values = append(values, s._Albums)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s User) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForUser.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s User) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s User) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForUser.Chunks()...)
|
||||
chunks = append(chunks, s._Albums.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Name))
|
||||
ret = append(ret, s._Albums)
|
||||
return
|
||||
}
|
||||
|
||||
func (s User) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s User) SetId(val string) User {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Name() string {
|
||||
return s._Name
|
||||
}
|
||||
|
||||
func (s User) SetName(val string) User {
|
||||
s._Name = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) Albums() ListOfRefOfAlbum {
|
||||
return s._Albums
|
||||
}
|
||||
|
||||
func (s User) SetAlbums(val ListOfRefOfAlbum) User {
|
||||
s._Albums = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Album
|
||||
|
||||
type Album struct {
|
||||
_Id string
|
||||
_Title string
|
||||
_Photos SetOfRefOfRemotePhoto
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewAlbum() Album {
|
||||
return Album{
|
||||
_Id: "",
|
||||
_Title: "",
|
||||
_Photos: NewSetOfRefOfRemotePhoto(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type AlbumDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Photos SetOfRefOfRemotePhotoDef
|
||||
}
|
||||
|
||||
func (def AlbumDef) New() Album {
|
||||
return Album{
|
||||
_Id: def.Id,
|
||||
_Title: def.Title,
|
||||
_Photos: def.Photos.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Album) Def() (d AlbumDef) {
|
||||
d.Id = s._Id
|
||||
d.Title = s._Title
|
||||
d.Photos = s._Photos.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForAlbum types.Type
|
||||
|
||||
func (m Album) Type() types.Type {
|
||||
return __typeForAlbum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForAlbum = types.MakeType(ref.Parse("sha1-988f3a092d1b2cfe21f48d517b28b27a3fed4e95"), 1)
|
||||
types.RegisterStruct(__typeForAlbum, builderForAlbum, readerForAlbum)
|
||||
}
|
||||
|
||||
func builderForAlbum(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Album{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Photos = values[i].(SetOfRefOfRemotePhoto)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForAlbum(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Album)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, s._Photos)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Album) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForAlbum.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Album) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Album) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForAlbum.Chunks()...)
|
||||
chunks = append(chunks, s._Photos.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Album) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, s._Photos)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Album) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s Album) SetId(val string) Album {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Album) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s Album) SetTitle(val string) Album {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Album) Photos() SetOfRefOfRemotePhoto {
|
||||
return s._Photos
|
||||
}
|
||||
|
||||
func (s Album) SetPhotos(val SetOfRefOfRemotePhoto) Album {
|
||||
s._Photos = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// RefOfUser
|
||||
|
||||
type RefOfUser struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfUser(target ref.Ref) RefOfUser {
|
||||
return RefOfUser{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfUser) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfUser.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfUser) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfUser) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfUser.
|
||||
var __typeForRefOfUser types.Type
|
||||
|
||||
func (r RefOfUser) Type() types.Type {
|
||||
return __typeForRefOfUser
|
||||
}
|
||||
|
||||
func (r RefOfUser) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfUser = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-988f3a092d1b2cfe21f48d517b28b27a3fed4e95"), 0))
|
||||
types.RegisterRef(__typeForRefOfUser, builderForRefOfUser)
|
||||
}
|
||||
|
||||
func builderForRefOfUser(r ref.Ref) types.RefBase {
|
||||
return NewRefOfUser(r)
|
||||
}
|
||||
|
||||
func (r RefOfUser) TargetValue(vr types.ValueReader) User {
|
||||
return vr.ReadValue(r.target).(User)
|
||||
}
|
||||
|
||||
// ListOfRefOfAlbum
|
||||
|
||||
type ListOfRefOfAlbum struct {
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfRefOfAlbum() ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{types.NewTypedList(__typeForListOfRefOfAlbum), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfRefOfAlbumDef []ref.Ref
|
||||
|
||||
func (def ListOfRefOfAlbumDef) New() ListOfRefOfAlbum {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = NewRefOfAlbum(d)
|
||||
}
|
||||
return ListOfRefOfAlbum{types.NewTypedList(__typeForListOfRefOfAlbum, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Def() ListOfRefOfAlbumDef {
|
||||
d := make([]ref.Ref, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = l.l.Get(i).(RefOfAlbum).TargetRef()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForListOfRefOfAlbum.Equals(other.Type()) && l.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Ref() ref.Ref {
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, l.Type().Chunks()...)
|
||||
chunks = append(chunks, l.l.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, l.l.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes ListOfRefOfAlbum.
|
||||
var __typeForListOfRefOfAlbum types.Type
|
||||
|
||||
func (m ListOfRefOfAlbum) Type() types.Type {
|
||||
return __typeForListOfRefOfAlbum
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForListOfRefOfAlbum = types.MakeCompoundType(types.ListKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-988f3a092d1b2cfe21f48d517b28b27a3fed4e95"), 1)))
|
||||
types.RegisterValue(__typeForListOfRefOfAlbum, builderForListOfRefOfAlbum, readerForListOfRefOfAlbum)
|
||||
}
|
||||
|
||||
func builderForListOfRefOfAlbum(v types.Value) types.Value {
|
||||
return ListOfRefOfAlbum{v.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForListOfRefOfAlbum(v types.Value) types.Value {
|
||||
return v.(ListOfRefOfAlbum).l
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Len() uint64 {
|
||||
return l.l.Len()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Empty() bool {
|
||||
return l.Len() == uint64(0)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Get(i uint64) RefOfAlbum {
|
||||
return l.l.Get(i).(RefOfAlbum)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Slice(idx uint64, end uint64) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Set(i uint64, val RefOfAlbum) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Append(v ...RefOfAlbum) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Insert(idx uint64, v ...RefOfAlbum) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) Remove(idx uint64, end uint64) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) RemoveAt(idx uint64) ListOfRefOfAlbum {
|
||||
return ListOfRefOfAlbum{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) fromElemSlice(p []RefOfAlbum) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ListOfRefOfAlbumIterCallback func(v RefOfAlbum, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfRefOfAlbum) Iter(cb ListOfRefOfAlbumIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfAlbum), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfAlbumIterAllCallback func(v RefOfAlbum, i uint64)
|
||||
|
||||
func (l ListOfRefOfAlbum) IterAll(cb ListOfRefOfAlbumIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfAlbum), i)
|
||||
})
|
||||
}
|
||||
|
||||
func (l ListOfRefOfAlbum) IterAllP(concurrency int, cb ListOfRefOfAlbumIterAllCallback) {
|
||||
l.l.IterAllP(concurrency, func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfAlbum), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfAlbumFilterCallback func(v RefOfAlbum, i uint64) (keep bool)
|
||||
|
||||
func (l ListOfRefOfAlbum) Filter(cb ListOfRefOfAlbumFilterCallback) ListOfRefOfAlbum {
|
||||
out := l.l.Filter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfAlbum), i)
|
||||
})
|
||||
return ListOfRefOfAlbum{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfRefOfRemotePhoto
|
||||
|
||||
type SetOfRefOfRemotePhoto struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfRefOfRemotePhoto() SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoDef map[ref.Ref]bool
|
||||
|
||||
func (def SetOfRefOfRemotePhotoDef) New() SetOfRefOfRemotePhoto {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = NewRefOfRemotePhoto(d)
|
||||
i++
|
||||
}
|
||||
return SetOfRefOfRemotePhoto{types.NewTypedSet(__typeForSetOfRefOfRemotePhoto, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Def() SetOfRefOfRemotePhotoDef {
|
||||
def := make(map[ref.Ref]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(RefOfRemotePhoto).TargetRef()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfRefOfRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfRefOfRemotePhoto.
|
||||
var __typeForSetOfRefOfRemotePhoto types.Type
|
||||
|
||||
func (m SetOfRefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForSetOfRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfRefOfRemotePhoto = types.MakeCompoundType(types.SetKind, types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)))
|
||||
types.RegisterValue(__typeForSetOfRefOfRemotePhoto, builderForSetOfRefOfRemotePhoto, readerForSetOfRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return SetOfRefOfRemotePhoto{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfRefOfRemotePhoto(v types.Value) types.Value {
|
||||
return v.(SetOfRefOfRemotePhoto).s
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Has(p RefOfRemotePhoto) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterCallback func(p RefOfRemotePhoto) (stop bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Iter(cb SetOfRefOfRemotePhotoIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoIterAllCallback func(p RefOfRemotePhoto)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAll(cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) IterAllP(concurrency int, cb SetOfRefOfRemotePhotoIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfRefOfRemotePhotoFilterCallback func(p RefOfRemotePhoto) (keep bool)
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Filter(cb SetOfRefOfRemotePhotoFilterCallback) SetOfRefOfRemotePhoto {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(RefOfRemotePhoto))
|
||||
})
|
||||
return SetOfRefOfRemotePhoto{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Insert(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Remove(p ...RefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) Union(others ...SetOfRefOfRemotePhoto) SetOfRefOfRemotePhoto {
|
||||
return SetOfRefOfRemotePhoto{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) First() RefOfRemotePhoto {
|
||||
return s.s.First().(RefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromStructSlice(p []SetOfRefOfRemotePhoto) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfRefOfRemotePhoto) fromElemSlice(p []RefOfRemotePhoto) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// RefOfAlbum
|
||||
|
||||
type RefOfAlbum struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfAlbum(target ref.Ref) RefOfAlbum {
|
||||
return RefOfAlbum{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfAlbum.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfAlbum.
|
||||
var __typeForRefOfAlbum types.Type
|
||||
|
||||
func (r RefOfAlbum) Type() types.Type {
|
||||
return __typeForRefOfAlbum
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfAlbum = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-988f3a092d1b2cfe21f48d517b28b27a3fed4e95"), 1))
|
||||
types.RegisterRef(__typeForRefOfAlbum, builderForRefOfAlbum)
|
||||
}
|
||||
|
||||
func builderForRefOfAlbum(r ref.Ref) types.RefBase {
|
||||
return NewRefOfAlbum(r)
|
||||
}
|
||||
|
||||
func (r RefOfAlbum) TargetValue(vr types.ValueReader) Album {
|
||||
return vr.ReadValue(r.target).(Album)
|
||||
}
|
||||
|
||||
// RefOfRemotePhoto
|
||||
|
||||
type RefOfRemotePhoto struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfRemotePhoto(target ref.Ref) RefOfRemotePhoto {
|
||||
return RefOfRemotePhoto{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfRemotePhoto.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfRemotePhoto.
|
||||
var __typeForRefOfRemotePhoto types.Type
|
||||
|
||||
func (r RefOfRemotePhoto) Type() types.Type {
|
||||
return __typeForRefOfRemotePhoto
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfRemotePhoto = types.MakeCompoundType(types.RefKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0))
|
||||
types.RegisterRef(__typeForRefOfRemotePhoto, builderForRefOfRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRefOfRemotePhoto(r ref.Ref) types.RefBase {
|
||||
return NewRefOfRemotePhoto(r)
|
||||
}
|
||||
|
||||
func (r RefOfRemotePhoto) TargetValue(vr types.ValueReader) RemotePhoto {
|
||||
return vr.ReadValue(r.target).(RemotePhoto)
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetSizes(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
getSizesFromJSON := func(j string) MapOfSizeToStringDef {
|
||||
e := EntryJSON{}
|
||||
assert.NoError(json.Unmarshal([]byte(j), &e))
|
||||
return getSizes(e)
|
||||
}
|
||||
|
||||
assert.Equal(MapOfSizeToStringDef{
|
||||
SizeDef{Height: 128, Width: 103}: "picasa.com/s128/photo.jpg",
|
||||
SizeDef{Height: 320, Width: 256}: "picasa.com/s320/photo.jpg",
|
||||
SizeDef{Height: 640, Width: 512}: "picasa.com/s640/photo.jpg",
|
||||
SizeDef{Height: 1024, Width: 820}: "picasa.com/s1024/photo.jpg",
|
||||
SizeDef{Height: 1600, Width: 1280}: "picasa.com/s1600/photo.jpg",
|
||||
SizeDef{Height: 8000, Width: 6400}: "picasa.com/s8000/photo.jpg",
|
||||
}, getSizesFromJSON(`{
|
||||
"content": {"src": "picasa.com/bigphoto.jpg"},
|
||||
"gphoto$height": {"$t": "8000"},
|
||||
"gphoto$width": {"$t": "6400"},
|
||||
"media$group": {
|
||||
"media$thumbnail": [{
|
||||
"height": 80,
|
||||
"url": "picasa.com/s80/photo.jpg",
|
||||
"width": 64
|
||||
}]
|
||||
}
|
||||
}`))
|
||||
|
||||
assert.Equal(MapOfSizeToStringDef{
|
||||
SizeDef{Height: 128, Width: 103}: "picasa.com/s128/photo.jpg",
|
||||
SizeDef{Height: 320, Width: 256}: "picasa.com/s320/photo.jpg",
|
||||
SizeDef{Height: 640, Width: 512}: "picasa.com/s640/photo.jpg",
|
||||
SizeDef{Height: 800, Width: 640}: "picasa.com/s800/photo.jpg",
|
||||
}, getSizesFromJSON(`{
|
||||
"content": {"src": "picasa.com/bigphoto.jpg"},
|
||||
"gphoto$height": {"$t": "800"},
|
||||
"gphoto$width": {"$t": "640"},
|
||||
"media$group": {
|
||||
"media$thumbnail": [{
|
||||
"height": 80,
|
||||
"url": "picasa.com/s80/photo.jpg",
|
||||
"width": 64
|
||||
}]
|
||||
}
|
||||
}`))
|
||||
|
||||
assert.Equal(MapOfSizeToStringDef{
|
||||
SizeDef{Height: 103, Width: 128}: "picasa.com/s128/photo.jpg",
|
||||
SizeDef{Height: 256, Width: 320}: "picasa.com/s320/photo.jpg",
|
||||
SizeDef{Height: 512, Width: 640}: "picasa.com/s640/photo.jpg",
|
||||
SizeDef{Height: 820, Width: 1024}: "picasa.com/s1024/photo.jpg",
|
||||
SizeDef{Height: 1280, Width: 1600}: "picasa.com/s1600/photo.jpg",
|
||||
SizeDef{Height: 6400, Width: 8000}: "picasa.com/s8000/photo.jpg",
|
||||
}, getSizesFromJSON(`{
|
||||
"content": {"src": "picasa.com/bigphoto.jpg"},
|
||||
"gphoto$height": {"$t": "6400"},
|
||||
"gphoto$width": {"$t": "8000"},
|
||||
"media$group": {
|
||||
"media$thumbnail": [{
|
||||
"height": 64,
|
||||
"url": "picasa.com/s80/photo.jpg",
|
||||
"width": 80
|
||||
}]
|
||||
}
|
||||
}`))
|
||||
|
||||
assert.Equal(MapOfSizeToStringDef{
|
||||
SizeDef{Height: 103, Width: 128}: "picasa.com/s128/photo.jpg",
|
||||
SizeDef{Height: 256, Width: 320}: "picasa.com/s320/photo.jpg",
|
||||
SizeDef{Height: 512, Width: 640}: "picasa.com/s640/photo.jpg",
|
||||
SizeDef{Height: 640, Width: 800}: "picasa.com/s800/photo.jpg",
|
||||
}, getSizesFromJSON(`{
|
||||
"content": {"src": "picasa.com/bigphoto.jpg"},
|
||||
"gphoto$height": {"$t": "640"},
|
||||
"gphoto$width": {"$t": "800"},
|
||||
"media$group": {
|
||||
"media$thumbnail": [{
|
||||
"height": 64,
|
||||
"url": "picasa.com/s80/photo.jpg",
|
||||
"width": 80
|
||||
}]
|
||||
}
|
||||
}`))
|
||||
|
||||
assert.Equal(MapOfSizeToStringDef{
|
||||
SizeDef{Height: 128, Width: 128}: "picasa.com/s128/photo.jpg",
|
||||
SizeDef{Height: 320, Width: 320}: "picasa.com/s320/photo.jpg",
|
||||
SizeDef{Height: 640, Width: 640}: "picasa.com/s640/photo.jpg",
|
||||
SizeDef{Height: 1000, Width: 1000}: "picasa.com/s1000/photo.jpg",
|
||||
}, getSizesFromJSON(`{
|
||||
"content": {"src": "picasa.com/bigphoto.jpg"},
|
||||
"gphoto$height": {"$t": "1000"},
|
||||
"gphoto$width": {"$t": "1000"},
|
||||
"media$group": {
|
||||
"media$thumbnail": [{
|
||||
"height": 80,
|
||||
"url": "picasa.com/s80/photo.jpg",
|
||||
"width": 80
|
||||
}]
|
||||
}
|
||||
}`))
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate go run ../../nomdl/codegen/codegen.go -package=main -out-dir=.
|
||||
@@ -1,109 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Date",
|
||||
[]types.Field{
|
||||
types.Field{"MsSinceEpoch", types.MakePrimitiveType(types.Int64Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Date
|
||||
|
||||
type Date struct {
|
||||
_MsSinceEpoch int64
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDate() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: int64(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type DateDef struct {
|
||||
MsSinceEpoch int64
|
||||
}
|
||||
|
||||
func (def DateDef) New() Date {
|
||||
return Date{
|
||||
_MsSinceEpoch: def.MsSinceEpoch,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Date) Def() (d DateDef) {
|
||||
d.MsSinceEpoch = s._MsSinceEpoch
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForDate types.Type
|
||||
|
||||
func (m Date) Type() types.Type {
|
||||
return __typeForDate
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForDate = types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0)
|
||||
types.RegisterStruct(__typeForDate, builderForDate, readerForDate)
|
||||
}
|
||||
|
||||
func builderForDate(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Date{ref: &ref.Ref{}}
|
||||
s._MsSinceEpoch = int64(values[i].(types.Int64))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForDate(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Date)
|
||||
values = append(values, types.Int64(s._MsSinceEpoch))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Date) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForDate.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Date) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Date) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForDate.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Int64(s._MsSinceEpoch))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Date) MsSinceEpoch() int64 {
|
||||
return s._MsSinceEpoch
|
||||
}
|
||||
|
||||
func (s Date) SetMsSinceEpoch(val int64) Date {
|
||||
s._MsSinceEpoch = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("Geoposition",
|
||||
[]types.Field{
|
||||
types.Field{"Latitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Longitude", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Georectangle",
|
||||
[]types.Field{
|
||||
types.Field{"TopLeft", types.MakeType(ref.Ref{}, 0), false},
|
||||
types.Field{"BottomRight", types.MakeType(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// Geoposition
|
||||
|
||||
type Geoposition struct {
|
||||
_Latitude float32
|
||||
_Longitude float32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: float32(0),
|
||||
_Longitude: float32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeopositionDef struct {
|
||||
Latitude float32
|
||||
Longitude float32
|
||||
}
|
||||
|
||||
func (def GeopositionDef) New() Geoposition {
|
||||
return Geoposition{
|
||||
_Latitude: def.Latitude,
|
||||
_Longitude: def.Longitude,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Geoposition) Def() (d GeopositionDef) {
|
||||
d.Latitude = s._Latitude
|
||||
d.Longitude = s._Longitude
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeoposition types.Type
|
||||
|
||||
func (m Geoposition) Type() types.Type {
|
||||
return __typeForGeoposition
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeoposition = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0)
|
||||
types.RegisterStruct(__typeForGeoposition, builderForGeoposition, readerForGeoposition)
|
||||
}
|
||||
|
||||
func builderForGeoposition(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Geoposition{ref: &ref.Ref{}}
|
||||
s._Latitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Longitude = float32(values[i].(types.Float32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeoposition(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Geoposition)
|
||||
values = append(values, types.Float32(s._Latitude))
|
||||
values = append(values, types.Float32(s._Longitude))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Geoposition) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeoposition.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Geoposition) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeoposition.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Latitude))
|
||||
ret = append(ret, types.Float32(s._Longitude))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Geoposition) Latitude() float32 {
|
||||
return s._Latitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLatitude(val float32) Geoposition {
|
||||
s._Latitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Geoposition) Longitude() float32 {
|
||||
return s._Longitude
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLongitude(val float32) Geoposition {
|
||||
s._Longitude = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Georectangle
|
||||
|
||||
type Georectangle struct {
|
||||
_TopLeft Geoposition
|
||||
_BottomRight Geoposition
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeorectangle() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: NewGeoposition(),
|
||||
_BottomRight: NewGeoposition(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type GeorectangleDef struct {
|
||||
TopLeft GeopositionDef
|
||||
BottomRight GeopositionDef
|
||||
}
|
||||
|
||||
func (def GeorectangleDef) New() Georectangle {
|
||||
return Georectangle{
|
||||
_TopLeft: def.TopLeft.New(),
|
||||
_BottomRight: def.BottomRight.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Georectangle) Def() (d GeorectangleDef) {
|
||||
d.TopLeft = s._TopLeft.Def()
|
||||
d.BottomRight = s._BottomRight.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForGeorectangle types.Type
|
||||
|
||||
func (m Georectangle) Type() types.Type {
|
||||
return __typeForGeorectangle
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForGeorectangle = types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 1)
|
||||
types.RegisterStruct(__typeForGeorectangle, builderForGeorectangle, readerForGeorectangle)
|
||||
}
|
||||
|
||||
func builderForGeorectangle(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Georectangle{ref: &ref.Ref{}}
|
||||
s._TopLeft = values[i].(Geoposition)
|
||||
i++
|
||||
s._BottomRight = values[i].(Geoposition)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForGeorectangle(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Georectangle)
|
||||
values = append(values, s._TopLeft)
|
||||
values = append(values, s._BottomRight)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Georectangle) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForGeorectangle.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Georectangle) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Georectangle) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForGeorectangle.Chunks()...)
|
||||
chunks = append(chunks, s._TopLeft.Chunks()...)
|
||||
chunks = append(chunks, s._BottomRight.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, s._TopLeft)
|
||||
ret = append(ret, s._BottomRight)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Georectangle) TopLeft() Geoposition {
|
||||
return s._TopLeft
|
||||
}
|
||||
|
||||
func (s Georectangle) SetTopLeft(val Geoposition) Georectangle {
|
||||
s._TopLeft = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Georectangle) BottomRight() Geoposition {
|
||||
return s._BottomRight
|
||||
}
|
||||
|
||||
func (s Georectangle) SetBottomRight(val Geoposition) Georectangle {
|
||||
s._BottomRight = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
@@ -1,944 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func init() {
|
||||
p := types.NewPackage([]types.Type{
|
||||
types.MakeStructType("RemotePhoto",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveType(types.StringKind), false},
|
||||
types.Field{"Date", types.MakeType(ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeType(ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"), 0), false},
|
||||
types.Field{"Sizes", types.MakeCompoundType(types.MapKind, types.MakeType(ref.Ref{}, 2), types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Tags", types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind)), false},
|
||||
types.Field{"Faces", types.MakeCompoundType(types.SetKind, types.MakeType(ref.Ref{}, 1)), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Face",
|
||||
[]types.Field{
|
||||
types.Field{"Top", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Left", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Float32Kind), false},
|
||||
types.Field{"PersonName", types.MakePrimitiveType(types.StringKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructType("Size",
|
||||
[]types.Field{
|
||||
types.Field{"Width", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
types.Field{"Height", types.MakePrimitiveType(types.Uint32Kind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-0b4ac7cb0583d7fecd71a1584a3f846e5d8b08eb"),
|
||||
ref.Parse("sha1-0cac0f1ed4777b6965548b0dfe6965a9f23af76c"),
|
||||
})
|
||||
types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// RemotePhoto
|
||||
|
||||
type RemotePhoto struct {
|
||||
_Id string
|
||||
_Title string
|
||||
_Date Date
|
||||
_Geoposition Geoposition
|
||||
_Sizes MapOfSizeToString
|
||||
_Tags SetOfString
|
||||
_Faces SetOfFace
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRemotePhoto() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: "",
|
||||
_Title: "",
|
||||
_Date: NewDate(),
|
||||
_Geoposition: NewGeoposition(),
|
||||
_Sizes: NewMapOfSizeToString(),
|
||||
_Tags: NewSetOfString(),
|
||||
_Faces: NewSetOfFace(),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type RemotePhotoDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Date DateDef
|
||||
Geoposition GeopositionDef
|
||||
Sizes MapOfSizeToStringDef
|
||||
Tags SetOfStringDef
|
||||
Faces SetOfFaceDef
|
||||
}
|
||||
|
||||
func (def RemotePhotoDef) New() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
_Id: def.Id,
|
||||
_Title: def.Title,
|
||||
_Date: def.Date.New(),
|
||||
_Geoposition: def.Geoposition.New(),
|
||||
_Sizes: def.Sizes.New(),
|
||||
_Tags: def.Tags.New(),
|
||||
_Faces: def.Faces.New(),
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Def() (d RemotePhotoDef) {
|
||||
d.Id = s._Id
|
||||
d.Title = s._Title
|
||||
d.Date = s._Date.Def()
|
||||
d.Geoposition = s._Geoposition.Def()
|
||||
d.Sizes = s._Sizes.Def()
|
||||
d.Tags = s._Tags.Def()
|
||||
d.Faces = s._Faces.Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForRemotePhoto types.Type
|
||||
|
||||
func (m RemotePhoto) Type() types.Type {
|
||||
return __typeForRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRemotePhoto = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 0)
|
||||
types.RegisterStruct(__typeForRemotePhoto, builderForRemotePhoto, readerForRemotePhoto)
|
||||
}
|
||||
|
||||
func builderForRemotePhoto(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := RemotePhoto{ref: &ref.Ref{}}
|
||||
s._Id = values[i].(types.String).String()
|
||||
i++
|
||||
s._Title = values[i].(types.String).String()
|
||||
i++
|
||||
s._Date = values[i].(Date)
|
||||
i++
|
||||
s._Geoposition = values[i].(Geoposition)
|
||||
i++
|
||||
s._Sizes = values[i].(MapOfSizeToString)
|
||||
i++
|
||||
s._Tags = values[i].(SetOfString)
|
||||
i++
|
||||
s._Faces = values[i].(SetOfFace)
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForRemotePhoto(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(RemotePhoto)
|
||||
values = append(values, types.NewString(s._Id))
|
||||
values = append(values, types.NewString(s._Title))
|
||||
values = append(values, s._Date)
|
||||
values = append(values, s._Geoposition)
|
||||
values = append(values, s._Sizes)
|
||||
values = append(values, s._Tags)
|
||||
values = append(values, s._Faces)
|
||||
return values
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRemotePhoto.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForRemotePhoto.Chunks()...)
|
||||
chunks = append(chunks, s._Date.Chunks()...)
|
||||
chunks = append(chunks, s._Geoposition.Chunks()...)
|
||||
chunks = append(chunks, s._Sizes.Chunks()...)
|
||||
chunks = append(chunks, s._Tags.Chunks()...)
|
||||
chunks = append(chunks, s._Faces.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.NewString(s._Id))
|
||||
ret = append(ret, types.NewString(s._Title))
|
||||
ret = append(ret, s._Date)
|
||||
ret = append(ret, s._Geoposition)
|
||||
ret = append(ret, s._Sizes)
|
||||
ret = append(ret, s._Tags)
|
||||
ret = append(ret, s._Faces)
|
||||
return
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Id() string {
|
||||
return s._Id
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(val string) RemotePhoto {
|
||||
s._Id = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() string {
|
||||
return s._Title
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(val string) RemotePhoto {
|
||||
s._Title = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Date() Date {
|
||||
return s._Date
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetDate(val Date) RemotePhoto {
|
||||
s._Date = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Geoposition() Geoposition {
|
||||
return s._Geoposition
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetGeoposition(val Geoposition) RemotePhoto {
|
||||
s._Geoposition = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return s._Sizes
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(val MapOfSizeToString) RemotePhoto {
|
||||
s._Sizes = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Tags() SetOfString {
|
||||
return s._Tags
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTags(val SetOfString) RemotePhoto {
|
||||
s._Tags = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Faces() SetOfFace {
|
||||
return s._Faces
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetFaces(val SetOfFace) RemotePhoto {
|
||||
s._Faces = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Face
|
||||
|
||||
type Face struct {
|
||||
_Top float32
|
||||
_Left float32
|
||||
_Width float32
|
||||
_Height float32
|
||||
_PersonName string
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewFace() Face {
|
||||
return Face{
|
||||
_Top: float32(0),
|
||||
_Left: float32(0),
|
||||
_Width: float32(0),
|
||||
_Height: float32(0),
|
||||
_PersonName: "",
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type FaceDef struct {
|
||||
Top float32
|
||||
Left float32
|
||||
Width float32
|
||||
Height float32
|
||||
PersonName string
|
||||
}
|
||||
|
||||
func (def FaceDef) New() Face {
|
||||
return Face{
|
||||
_Top: def.Top,
|
||||
_Left: def.Left,
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
_PersonName: def.PersonName,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Face) Def() (d FaceDef) {
|
||||
d.Top = s._Top
|
||||
d.Left = s._Left
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
d.PersonName = s._PersonName
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForFace types.Type
|
||||
|
||||
func (m Face) Type() types.Type {
|
||||
return __typeForFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForFace = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1)
|
||||
types.RegisterStruct(__typeForFace, builderForFace, readerForFace)
|
||||
}
|
||||
|
||||
func builderForFace(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Face{ref: &ref.Ref{}}
|
||||
s._Top = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Left = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Width = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._Height = float32(values[i].(types.Float32))
|
||||
i++
|
||||
s._PersonName = values[i].(types.String).String()
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForFace(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Face)
|
||||
values = append(values, types.Float32(s._Top))
|
||||
values = append(values, types.Float32(s._Left))
|
||||
values = append(values, types.Float32(s._Width))
|
||||
values = append(values, types.Float32(s._Height))
|
||||
values = append(values, types.NewString(s._PersonName))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Face) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Face) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Face) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForFace.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Float32(s._Top))
|
||||
ret = append(ret, types.Float32(s._Left))
|
||||
ret = append(ret, types.Float32(s._Width))
|
||||
ret = append(ret, types.Float32(s._Height))
|
||||
ret = append(ret, types.NewString(s._PersonName))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Face) Top() float32 {
|
||||
return s._Top
|
||||
}
|
||||
|
||||
func (s Face) SetTop(val float32) Face {
|
||||
s._Top = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Left() float32 {
|
||||
return s._Left
|
||||
}
|
||||
|
||||
func (s Face) SetLeft(val float32) Face {
|
||||
s._Left = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Width() float32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Face) SetWidth(val float32) Face {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) Height() float32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Face) SetHeight(val float32) Face {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Face) PersonName() string {
|
||||
return s._PersonName
|
||||
}
|
||||
|
||||
func (s Face) SetPersonName(val string) Face {
|
||||
s._PersonName = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// Size
|
||||
|
||||
type Size struct {
|
||||
_Width uint32
|
||||
_Height uint32
|
||||
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{
|
||||
_Width: uint32(0),
|
||||
_Height: uint32(0),
|
||||
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
type SizeDef struct {
|
||||
Width uint32
|
||||
Height uint32
|
||||
}
|
||||
|
||||
func (def SizeDef) New() Size {
|
||||
return Size{
|
||||
_Width: def.Width,
|
||||
_Height: def.Height,
|
||||
ref: &ref.Ref{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s Size) Def() (d SizeDef) {
|
||||
d.Width = s._Width
|
||||
d.Height = s._Height
|
||||
return
|
||||
}
|
||||
|
||||
var __typeForSize types.Type
|
||||
|
||||
func (m Size) Type() types.Type {
|
||||
return __typeForSize
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSize = types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2)
|
||||
types.RegisterStruct(__typeForSize, builderForSize, readerForSize)
|
||||
}
|
||||
|
||||
func builderForSize(values []types.Value) types.Value {
|
||||
i := 0
|
||||
s := Size{ref: &ref.Ref{}}
|
||||
s._Width = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
s._Height = uint32(values[i].(types.Uint32))
|
||||
i++
|
||||
return s
|
||||
}
|
||||
|
||||
func readerForSize(v types.Value) []types.Value {
|
||||
values := []types.Value{}
|
||||
s := v.(Size)
|
||||
values = append(values, types.Uint32(s._Width))
|
||||
values = append(values, types.Uint32(s._Height))
|
||||
return values
|
||||
}
|
||||
|
||||
func (s Size) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSize.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Size) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, __typeForSize.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) ChildValues() (ret []types.Value) {
|
||||
ret = append(ret, types.Uint32(s._Width))
|
||||
ret = append(ret, types.Uint32(s._Height))
|
||||
return
|
||||
}
|
||||
|
||||
func (s Size) Width() uint32 {
|
||||
return s._Width
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(val uint32) Size {
|
||||
s._Width = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Size) Height() uint32 {
|
||||
return s._Height
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(val uint32) Size {
|
||||
s._Height = val
|
||||
s.ref = &ref.Ref{}
|
||||
return s
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringDef map[SizeDef]string
|
||||
|
||||
func (def MapOfSizeToStringDef) New() MapOfSizeToString {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, k.New(), types.NewString(v))
|
||||
}
|
||||
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Def() MapOfSizeToStringDef {
|
||||
def := make(map[SizeDef]string)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(Size).Def()] = v.(types.String).String()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfSizeToString.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfSizeToString.
|
||||
var __typeForMapOfSizeToString types.Type
|
||||
|
||||
func (m MapOfSizeToString) Type() types.Type {
|
||||
return __typeForMapOfSizeToString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfSizeToString = types.MakeCompoundType(types.MapKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 2), types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForMapOfSizeToString, builderForMapOfSizeToString, readerForMapOfSizeToString)
|
||||
}
|
||||
|
||||
func builderForMapOfSizeToString(v types.Value) types.Value {
|
||||
return MapOfSizeToString{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfSizeToString(v types.Value) types.Value {
|
||||
return v.(MapOfSizeToString).m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) string {
|
||||
return m.m.Get(p).(types.String).String()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) MaybeGet(p Size) (string, bool) {
|
||||
v, ok := m.m.MaybeGet(p)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return v.(types.String).String(), ok
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v string) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Set(k, types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Remove(p), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback func(k Size, v string) (stop bool)
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterAllCallback func(k Size, v string)
|
||||
|
||||
func (m MapOfSizeToString) IterAll(cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) IterAllP(concurrency int, cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfSizeToStringFilterCallback func(k Size, v string) (keep bool)
|
||||
|
||||
func (m MapOfSizeToString) Filter(cb MapOfSizeToStringFilterCallback) MapOfSizeToString {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
return MapOfSizeToString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
|
||||
func (def SetOfStringDef) New() SetOfString {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewTypedSet(__typeForSetOfString, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
def := make(map[string]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(types.String).String()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfString.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfString) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfString.
|
||||
var __typeForSetOfString types.Type
|
||||
|
||||
func (m SetOfString) Type() types.Type {
|
||||
return __typeForSetOfString
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfString = types.MakeCompoundType(types.SetKind, types.MakePrimitiveType(types.StringKind))
|
||||
types.RegisterValue(__typeForSetOfString, builderForSetOfString, readerForSetOfString)
|
||||
}
|
||||
|
||||
func builderForSetOfString(v types.Value) types.Value {
|
||||
return SetOfString{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfString(v types.Value) types.Value {
|
||||
return v.(SetOfString).s
|
||||
}
|
||||
|
||||
func (s SetOfString) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfString) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfString) Has(p string) bool {
|
||||
return s.s.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
type SetOfStringIterCallback func(p string) (stop bool)
|
||||
|
||||
func (s SetOfString) Iter(cb SetOfStringIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringIterAllCallback func(p string)
|
||||
|
||||
func (s SetOfString) IterAll(cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfString) IterAllP(concurrency int, cb SetOfStringIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfStringFilterCallback func(p string) (keep bool)
|
||||
|
||||
func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(types.String).String())
|
||||
})
|
||||
return SetOfString{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) First() string {
|
||||
return s.s.First().(types.String).String()
|
||||
}
|
||||
|
||||
func (s SetOfString) fromStructSlice(p []SetOfString) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfString) fromElemSlice(p []string) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = types.NewString(v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// SetOfFace
|
||||
|
||||
type SetOfFace struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfFace() SetOfFace {
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfFaceDef map[FaceDef]bool
|
||||
|
||||
func (def SetOfFaceDef) New() SetOfFace {
|
||||
l := make([]types.Value, len(def))
|
||||
i := 0
|
||||
for d, _ := range def {
|
||||
l[i] = d.New()
|
||||
i++
|
||||
}
|
||||
return SetOfFace{types.NewTypedSet(__typeForSetOfFace, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Def() SetOfFaceDef {
|
||||
def := make(map[FaceDef]bool, s.Len())
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
def[v.(Face).Def()] = true
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (s SetOfFace) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForSetOfFace.Equals(other.Type()) && s.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfFace) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, s.Type().Chunks()...)
|
||||
chunks = append(chunks, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s SetOfFace) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, s.s.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfFace.
|
||||
var __typeForSetOfFace types.Type
|
||||
|
||||
func (m SetOfFace) Type() types.Type {
|
||||
return __typeForSetOfFace
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForSetOfFace = types.MakeCompoundType(types.SetKind, types.MakeType(ref.Parse("sha1-10004087fdbc623873c649d28aa59f4e066d374e"), 1))
|
||||
types.RegisterValue(__typeForSetOfFace, builderForSetOfFace, readerForSetOfFace)
|
||||
}
|
||||
|
||||
func builderForSetOfFace(v types.Value) types.Value {
|
||||
return SetOfFace{v.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForSetOfFace(v types.Value) types.Value {
|
||||
return v.(SetOfFace).s
|
||||
}
|
||||
|
||||
func (s SetOfFace) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfFace) Has(p Face) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfFaceIterCallback func(p Face) (stop bool)
|
||||
|
||||
func (s SetOfFace) Iter(cb SetOfFaceIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceIterAllCallback func(p Face)
|
||||
|
||||
func (s SetOfFace) IterAll(cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfFace) IterAllP(concurrency int, cb SetOfFaceIterAllCallback) {
|
||||
s.s.IterAllP(concurrency, func(v types.Value) {
|
||||
cb(v.(Face))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfFaceFilterCallback func(p Face) (keep bool)
|
||||
|
||||
func (s SetOfFace) Filter(cb SetOfFaceFilterCallback) SetOfFace {
|
||||
out := s.s.Filter(func(v types.Value) bool {
|
||||
return cb(v.(Face))
|
||||
})
|
||||
return SetOfFace{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Insert(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Remove(p ...Face) SetOfFace {
|
||||
return SetOfFace{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) Union(others ...SetOfFace) SetOfFace {
|
||||
return SetOfFace{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFace) First() Face {
|
||||
return s.s.First().(Face)
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromStructSlice(p []SetOfFace) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfFace) fromElemSlice(p []Face) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package main
|
||||
|
||||
type ShapesJSON struct {
|
||||
Version string `xml:"version,attr"`
|
||||
Channel struct {
|
||||
Item []struct {
|
||||
ID string `xml:"http://schemas.google.com/photos/2007 id"`
|
||||
Shapes struct {
|
||||
Shape []Shape `xml:"http://schemas.google.com/photos/2007 shape"`
|
||||
} `xml:"http://schemas.google.com/photos/2007 shapes"`
|
||||
} `xml:"item"`
|
||||
} `xml:"channel"`
|
||||
}
|
||||
|
||||
type Shape struct {
|
||||
Type string `xml:"type,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
UpperLeft string `xml:"upperLeft,attr"`
|
||||
LowerRight string `xml:"lowerRight,attr"`
|
||||
}
|
||||
|
||||
type AlbumJSON struct {
|
||||
Feed struct {
|
||||
UserName struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$nickname"`
|
||||
ID struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$ID"`
|
||||
NumPhotos struct {
|
||||
V int `json:"$t"`
|
||||
} `json:"gphoto$numphotos"`
|
||||
Title struct {
|
||||
V string `json:"$t"`
|
||||
}
|
||||
UserID struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$user"`
|
||||
Entry []EntryJSON
|
||||
}
|
||||
}
|
||||
|
||||
type EntryJSON struct {
|
||||
Content struct {
|
||||
Src string
|
||||
}
|
||||
Height struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$height"`
|
||||
ID struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$ID"`
|
||||
Size struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$size"`
|
||||
MediaGroup struct {
|
||||
Tags struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"media$keywords"`
|
||||
Thumbnails []struct {
|
||||
Height int
|
||||
URL string
|
||||
Width int
|
||||
} `json:"media$thumbnail"`
|
||||
} `json:"media$group"`
|
||||
Timestamp struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$timestamp"`
|
||||
Title struct {
|
||||
V string `json:"$t"`
|
||||
}
|
||||
Width struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$width"`
|
||||
Geo struct {
|
||||
Point struct {
|
||||
Pos struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gml$pos"`
|
||||
} `json:"gml$Point"`
|
||||
} `json:"georss$where"`
|
||||
}
|
||||
|
||||
// AlbumListJSON is used for unmarshalling results from picasa 'list albums' api
|
||||
type AlbumListJSON struct {
|
||||
Feed struct {
|
||||
UserName struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$nickname"`
|
||||
Entry []struct {
|
||||
ID struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$ID"`
|
||||
NumPhotos struct {
|
||||
V int `json:"$t"`
|
||||
} `json:"gphoto$numphotos"`
|
||||
Title struct {
|
||||
V string `json:"$t"`
|
||||
}
|
||||
}
|
||||
UserID struct {
|
||||
V string `json:"$t"`
|
||||
} `json:"gphoto$user"`
|
||||
}
|
||||
}
|
||||
|
||||
// RefreshTokenJSON is used for fetching the refreshToken that gets stored
|
||||
// in the nomsUser object
|
||||
type RefreshTokenJSON struct {
|
||||
ID string
|
||||
RefreshToken string
|
||||
}
|
||||
1
clients/quad_tree/.gitignore
vendored
1
clients/quad_tree/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
quad_tree
|
||||
@@ -1,144 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/common"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/attic-labs/noms/walk"
|
||||
)
|
||||
|
||||
var (
|
||||
datasFlags = datas.NewFlags()
|
||||
inputRefStr = flag.String("input-ref", "", "ref to list containing nodes")
|
||||
outputDs = flag.String("output-ds", "", "dataset to store data in.")
|
||||
quietFlag = flag.Bool("quiet", false, "suppress printing of progress statements")
|
||||
)
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("Usage: %s -ldb=/path/to/db -input-ref=sha1-xyz -output-ds=quadtree\n\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
start := time.Now()
|
||||
|
||||
datastore, ok := datasFlags.CreateDataStore()
|
||||
if !ok || *inputRefStr == "" || *outputDs == "" {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer datastore.Close()
|
||||
dataset := dataset.NewDataset(datastore, *outputDs)
|
||||
|
||||
var inputRef ref.Ref
|
||||
err := d.Try(func() {
|
||||
inputRef = ref.Parse(*inputRefStr)
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid inputRef: %v", *inputRefStr)
|
||||
}
|
||||
|
||||
gr := common.GeorectangleDef{
|
||||
TopLeft: common.GeopositionDef{Latitude: 37.83, Longitude: -122.52},
|
||||
BottomRight: common.GeopositionDef{Latitude: 37.70, Longitude: -122.36},
|
||||
}
|
||||
qtRoot := common.QuadTreeDef{
|
||||
Nodes: common.ListOfNodeDef{},
|
||||
Tiles: common.MapOfStringToQuadTreeDef{},
|
||||
Depth: 0,
|
||||
NumDescendents: 0,
|
||||
Path: "",
|
||||
Georectangle: gr,
|
||||
}
|
||||
if !*quietFlag {
|
||||
fmt.Printf("quadTreeRoot: %+v\n", qtRoot.Georectangle)
|
||||
}
|
||||
|
||||
nChan := make(chan *common.NodeDef, 1024)
|
||||
nodesConverted := uint32(0)
|
||||
|
||||
type hasGeoposition interface {
|
||||
Geoposition() common.Geoposition
|
||||
}
|
||||
|
||||
go func() {
|
||||
ds := dataset.Store()
|
||||
walk.SomeP(ds.ReadValue(inputRef), ds, func(v types.Value, r types.RefBase) (stop bool) {
|
||||
var g common.Geoposition
|
||||
|
||||
// Only consider RefOfStruct
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
switch v := v.(type) {
|
||||
case hasGeoposition:
|
||||
g = v.Geoposition()
|
||||
case types.Struct:
|
||||
if mg, ok := v.MaybeGet("geo"); ok {
|
||||
if mg, ok := mg.(common.Geoposition); ok {
|
||||
g = mg
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
stop = true
|
||||
|
||||
nodeDef := &common.NodeDef{Geoposition: g.Def(), Reference: v.Ref()}
|
||||
nChan <- nodeDef
|
||||
nConverted := atomic.AddUint32(&nodesConverted, 1)
|
||||
if !*quietFlag && nConverted%1e5 == 0 {
|
||||
fmt.Printf("Nodes Converted: %d, elapsed time: %.2f secs\n", nodesConverted, SecsSince(start))
|
||||
}
|
||||
return
|
||||
}, 64)
|
||||
close(nChan)
|
||||
}()
|
||||
|
||||
nodesAppended := uint32(0)
|
||||
for nodeDef := range nChan {
|
||||
qtRoot.Append(nodeDef)
|
||||
nodesAppended++
|
||||
if !*quietFlag && nodesAppended%1e5 == 0 {
|
||||
fmt.Printf("Nodes Appended: %d, elapsed time: %.2f secs\n", nodesAppended, SecsSince(start))
|
||||
qtRoot.Analyze()
|
||||
}
|
||||
}
|
||||
|
||||
if !*quietFlag {
|
||||
fmt.Printf("Nodes Appended: %d, elapsed time: %.2f secs\n", nodesAppended, SecsSince(start))
|
||||
qtRoot.Analyze()
|
||||
fmt.Printf("Calling SaveToNoms(), elapsed time: %.2f secs\n", SecsSince(start))
|
||||
}
|
||||
|
||||
nomsQtRoot := qtRoot.SaveToNoms(dataset.Store(), start, *quietFlag)
|
||||
if !*quietFlag {
|
||||
fmt.Printf("Calling Commit(), elapsed time: %.2f secs\n", SecsSince(start))
|
||||
}
|
||||
_, err = dataset.Commit(types.NewRef(nomsQtRoot.Ref()))
|
||||
d.Exp.NoError(err)
|
||||
if !*quietFlag {
|
||||
fmt.Printf("Commit completed, elapsed time: %.2f secs\n", time.Now().Sub(start).Seconds())
|
||||
}
|
||||
fmt.Println("QuadTree ref:", nomsQtRoot.Ref())
|
||||
}
|
||||
|
||||
func SecsSince(start time.Time) float64 {
|
||||
return time.Now().Sub(start).Seconds()
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# SF Crime
|
||||
|
||||
Import SF public crime data into noms, and search by georectangle.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/sfcrime/importer
|
||||
|
||||
# Fetch the data from: http://www.opendatacache.com/data.sfgov.org/api/views/tmnf-yvry/rows.csv
|
||||
|
||||
go build
|
||||
./importer -ldb="/tmp/sfcrime" -ds="sfcrime/raw" -input-file="rows.csv"
|
||||
|
||||
# quad_tree is a general purpose tool to index geocoded data
|
||||
cd ../../quad_tree
|
||||
go build
|
||||
./quad_tree -ldb="/tmp/sfcrime" -input-ref="<ref-from-importer-output>" -output-ds="sfcrime/bygeo"
|
||||
|
||||
cd ../sfcrime/search
|
||||
go build
|
||||
./search -ldb="/tmp/sfcrime" -quadtree-ref="<ref-from-quadtree-output>" -lat="37.7806521" -lon="-122.4070723"
|
||||
```
|
||||
1
clients/sfcrime/importer/.gitignore
vendored
1
clients/sfcrime/importer/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
importer
|
||||
@@ -1,222 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/common"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// data can be obtained using:
|
||||
// wget --output-document=sfcrime.csv https://data.sfgov.org/api/views/tmnf-yvry/rows.csv?accessType=DOWNLOAD
|
||||
var (
|
||||
limitFlag = flag.Int("limit", math.MaxInt32, "limit number of rows that are imported")
|
||||
inputFlag = flag.String("input-file", "", "path to .csv file containing sfcrime data")
|
||||
quietFlag = flag.Bool("quiet", false, "suppress printing of messages")
|
||||
numIncidents = 0
|
||||
rowsRead = 0
|
||||
start = time.Now()
|
||||
)
|
||||
|
||||
const maxListSize = 1e5
|
||||
|
||||
type incidentWithIndex struct {
|
||||
incident *common.IncidentDef
|
||||
index int
|
||||
}
|
||||
|
||||
type refIndex struct {
|
||||
ref types.RefBase
|
||||
index int
|
||||
}
|
||||
|
||||
type refIndexList []refIndex
|
||||
|
||||
func (a refIndexList) Len() int { return len(a) }
|
||||
func (a refIndexList) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a refIndexList) Less(i, j int) bool { return a[i].index < a[j].index }
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("Usage: %s -ldb=/path/to/db -ds=sfcrime -input-file=/path/to/data.csv\n\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
dsFlags := dataset.NewFlags()
|
||||
flag.Parse()
|
||||
ds := dsFlags.CreateDataset()
|
||||
if ds == nil || *inputFlag == "" {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer ds.Store().Close()
|
||||
|
||||
csvfile, err := os.Open(*inputFlag)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer csvfile.Close()
|
||||
|
||||
if util.MaybeStartCPUProfile() {
|
||||
defer util.StopCPUProfile()
|
||||
}
|
||||
|
||||
reader := csv.NewReader(csvfile)
|
||||
|
||||
minLon := float32(180)
|
||||
minLat := float32(90)
|
||||
maxLat := float32(-90)
|
||||
maxLon := float32(-180)
|
||||
|
||||
// read the header row and discard it
|
||||
_, err = reader.Read()
|
||||
outLiers := 0
|
||||
limitExceeded := false
|
||||
iChan, rChan := getNomsWriter(ds.Store())
|
||||
refList := refIndexList{}
|
||||
refs := []types.Value{}
|
||||
|
||||
// Start a go routine to add incident refs to the list as they are ready
|
||||
var refWg sync.WaitGroup
|
||||
refWg.Add(1)
|
||||
go func() {
|
||||
for ref := range rChan {
|
||||
refList = append(refList, ref)
|
||||
}
|
||||
sort.Sort(refList)
|
||||
for _, r := range refList {
|
||||
refs = append(refs, r.ref)
|
||||
}
|
||||
refWg.Done()
|
||||
}()
|
||||
|
||||
index := 0
|
||||
|
||||
for r, err := reader.Read(); !limitExceeded && err == nil; r, err = reader.Read() {
|
||||
rowsRead++
|
||||
id, _ := strconv.ParseInt(r[0], 10, 64)
|
||||
lon64, _ := strconv.ParseFloat(r[9], 32)
|
||||
lat64, _ := strconv.ParseFloat(r[10], 32)
|
||||
geopos := common.GeopositionDef{Latitude: float32(lat64), Longitude: float32(lon64)}
|
||||
incident := common.IncidentDef{
|
||||
ID: id,
|
||||
Category: r[1],
|
||||
Description: r[2],
|
||||
DayOfWeek: r[3],
|
||||
Date: r[4],
|
||||
Time: r[5],
|
||||
PdDistrict: r[6],
|
||||
Resolution: r[7],
|
||||
Address: r[8],
|
||||
Geoposition: geopos,
|
||||
PdID: r[12],
|
||||
}
|
||||
|
||||
if geopos.Latitude > 35 && geopos.Latitude < 40 && geopos.Longitude > -125 && geopos.Longitude < 120 {
|
||||
minLat = min(minLat, geopos.Latitude)
|
||||
maxLat = max(maxLat, geopos.Latitude)
|
||||
minLon = min(minLon, geopos.Longitude)
|
||||
maxLon = max(maxLon, geopos.Longitude)
|
||||
iChan <- incidentWithIndex{&incident, index}
|
||||
index++
|
||||
} else {
|
||||
outLiers++
|
||||
}
|
||||
if !*quietFlag && rowsRead%maxListSize == 0 {
|
||||
fmt.Printf("Processed %d rows, %d incidents, elapsed time: %.2f secs\n", rowsRead, numIncidents, time.Now().Sub(start).Seconds())
|
||||
}
|
||||
if rowsRead >= *limitFlag {
|
||||
limitExceeded = true
|
||||
}
|
||||
}
|
||||
|
||||
close(iChan)
|
||||
refWg.Wait()
|
||||
|
||||
incidentRefs := types.NewList(refs...)
|
||||
if !*quietFlag {
|
||||
fmt.Printf("Converting refs list to noms list: %.2f secs\n", time.Now().Sub(start).Seconds())
|
||||
}
|
||||
|
||||
_, err = ds.Commit(ds.Store().WriteValue(incidentRefs))
|
||||
d.Exp.NoError(err)
|
||||
|
||||
if !*quietFlag {
|
||||
fmt.Printf("Commit completed, elaspsed time: %.2f secs\n", time.Now().Sub(start).Seconds())
|
||||
printDataStats(rowsRead, numIncidents, outLiers, minLat, minLon, maxLat, maxLon)
|
||||
}
|
||||
|
||||
fmt.Printf("Ref of list containing Incidents: %s, , elaspsed time: %.2f secs\n", incidentRefs.Ref(), time.Now().Sub(start).Seconds())
|
||||
}
|
||||
|
||||
func getNomsWriter(vw types.ValueWriter) (iChan chan incidentWithIndex, rChan chan refIndex) {
|
||||
iChan = make(chan incidentWithIndex, 3000)
|
||||
rChan = make(chan refIndex, 3000)
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 32; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
for incidentRecord := range iChan {
|
||||
v := incidentRecord.incident.New()
|
||||
rChan <- refIndex{vw.WriteValue(v), incidentRecord.index}
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(rChan)
|
||||
}()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func printDataStats(rows, rowsInserted, badRows int, minLat, minLon, maxLat, maxLon float32) {
|
||||
template := `Dataset Info:
|
||||
Number of rows: %d
|
||||
Incidents inserted: %d
|
||||
Incidents not inserted due to outlying coordinates: %d
|
||||
Minimum latitude: %f,
|
||||
Minimum longitude: %f
|
||||
Maximum latitude: %f
|
||||
Maximum longitude: %f
|
||||
`
|
||||
fmt.Printf(template, rows, rowsInserted, badRows, minLat, minLon, maxLat, maxLon)
|
||||
fmt.Printf("Minimum Georectangle(%.2f, %.2f, %.2f, %.2f)\n",
|
||||
toFixedCeil(float32(maxLat), 2), toFixedFloor(float32(minLon), 2), toFixedFloor(float32(minLat), 2), toFixedCeil(float32(maxLon), 2))
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
func min(x, y float32) float32 {
|
||||
return float32(math.Min(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func max(x, y float32) float32 {
|
||||
return float32(math.Max(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func toFixedFloor(num float32, precision int) float32 {
|
||||
output := math.Pow(10, float64(precision))
|
||||
return float32(math.Floor(float64(num)*output) / output)
|
||||
}
|
||||
|
||||
func toFixedCeil(num float32, precision int) float32 {
|
||||
output := math.Pow(10, float64(precision))
|
||||
return float32(math.Ceil(float64(num)*output) / output)
|
||||
}
|
||||
1
clients/sfcrime/search/.gitignore
vendored
1
clients/sfcrime/search/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
search
|
||||
@@ -1,145 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/common"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var (
|
||||
datasFlags = datas.NewFlags()
|
||||
quadTreeRefFlag = flag.String("quadtree-ref", "", "ref to root of quadtree")
|
||||
incidentListRefFlag = flag.String("incident-list-ref", "", "ref to list of incidents")
|
||||
latFlag = flag.Float64("lat", 0.0, "latitude of point to search for crime instances")
|
||||
lonFlag = flag.Float64("lon", 0.0, "longitude of point to search for crime instances")
|
||||
distanceFlag = flag.Float64("distance", 0.5, "distince in kilometers from point to search for crime instances")
|
||||
sqtRoot common.SQuadTree
|
||||
)
|
||||
|
||||
const (
|
||||
maxRequests = 8
|
||||
searchPath = "/s/"
|
||||
)
|
||||
|
||||
type httpServer struct {
|
||||
port int
|
||||
l *net.Listener
|
||||
conns map[net.Conn]http.ConnState
|
||||
writeLimit chan struct{}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
start := time.Now()
|
||||
|
||||
datastore, ok := datasFlags.CreateDataStore()
|
||||
if !ok {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
defer datastore.Close()
|
||||
|
||||
if *latFlag == 0.0 || *lonFlag == 0.0 {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
gp := common.GeopositionDef{Latitude: float32(*latFlag), Longitude: float32(*lonFlag)}
|
||||
var incidents []common.Incident
|
||||
if *quadTreeRefFlag != "" {
|
||||
incidents = searchWithQuadTree(gp, datastore)
|
||||
} else if *incidentListRefFlag != "" {
|
||||
incidents = searchWithList(gp, datastore)
|
||||
} else {
|
||||
fmt.Println("You must supply either the 'quadtree-ref' or the 'incident-list-ref' argumements")
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
var resDefs []common.IncidentDef
|
||||
for _, incident := range incidents {
|
||||
resDefs = append(resDefs, incident.Def())
|
||||
}
|
||||
sort.Sort(sort.Reverse(ByDate(resDefs)))
|
||||
|
||||
for _, n := range resDefs {
|
||||
fmt.Printf("Incident, date: %s, category: %s, desc: %s, address: %s\n", n.Date, n.Category, n.Description, n.Address)
|
||||
}
|
||||
fmt.Printf("Done, elapsed time: %.2f secs\n", time.Now().Sub(start).Seconds())
|
||||
}
|
||||
|
||||
func searchWithQuadTree(gp common.GeopositionDef, vr types.ValueReader) []common.Incident {
|
||||
argName := "quadtree-ref"
|
||||
r := readRef(*quadTreeRefFlag, argName)
|
||||
sqtRoot := vr.ReadValue(r).(common.SQuadTree)
|
||||
if !common.ContainsPoint(sqtRoot.Georectangle().Def(), gp) {
|
||||
log.Fatalf("lat/lon: %+v is not within sf area: %+v\n", gp, sqtRoot.Georectangle().Def())
|
||||
}
|
||||
gr, results := sqtRoot.Query(gp, *distanceFlag, vr)
|
||||
fmt.Printf("bounding Rectangle: %+v, numIncidents: %d\n", gr, len(results))
|
||||
return results
|
||||
}
|
||||
|
||||
func searchWithList(gp common.GeopositionDef, vr types.ValueReader) []common.Incident {
|
||||
argName := "incident-list-ref"
|
||||
r := readRef(*incidentListRefFlag, argName)
|
||||
val := vr.ReadValue(r)
|
||||
l, ok := val.(types.List)
|
||||
if !ok {
|
||||
log.Fatalf("Value for %s argument is not a list object\n", argName)
|
||||
}
|
||||
if l.Len() == 0 {
|
||||
log.Fatalf("Value for %s argument is an empty list\n", argName)
|
||||
}
|
||||
results := []common.Incident{}
|
||||
incidentList := val.(common.ListOfRefOfValue)
|
||||
t0 := time.Now()
|
||||
for i := uint64(0); i < incidentList.Len(); i++ {
|
||||
if i%uint64(10000) == 0 {
|
||||
fmt.Printf("%.2f%%: %v\n", float64(i)/float64(incidentList.Len())*float64(100), time.Now().Sub(t0))
|
||||
}
|
||||
incident := incidentList.Get(i).TargetValue(vr).(common.Incident)
|
||||
if common.DistanceTo(incident.Geoposition().Def(), gp) <= float32(*distanceFlag) {
|
||||
results = append(results, incident)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
func readRef(rs string, argName string) ref.Ref {
|
||||
var r ref.Ref
|
||||
err := d.Try(func() {
|
||||
r = ref.Parse(rs)
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid ref for %s arg: %v", argName, *quadTreeRefFlag)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ByDate []common.IncidentDef
|
||||
|
||||
func (s ByDate) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
func (s ByDate) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
func (s ByDate) Less(i, j int) bool {
|
||||
i1 := strings.Split(s[i].Date, "/")
|
||||
idate := fmt.Sprintf("%s/%s/%s", i1[2], i1[0], i1[1])
|
||||
j1 := strings.Split(s[j].Date, "/")
|
||||
jdate := fmt.Sprintf("%s/%s/%s", j1[2], j1[0], j1[1])
|
||||
return idate < jdate
|
||||
}
|
||||
11
clients/util/string_value_map.go
Normal file
11
clients/util/string_value_map.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
func NewMapOfStringToValue(kv ...types.Value) types.Map {
|
||||
return types.NewTypedMap(
|
||||
types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakePrimitiveType(types.ValueKind)),
|
||||
kv...)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
using List<Ref<Map<String, Value>>>
|
||||
@@ -1,340 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
// ListOfRefOfMapOfStringToValue
|
||||
|
||||
type ListOfRefOfMapOfStringToValue struct {
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfRefOfMapOfStringToValue() ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{types.NewTypedList(__typeForListOfRefOfMapOfStringToValue), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfRefOfMapOfStringToValueDef []ref.Ref
|
||||
|
||||
func (def ListOfRefOfMapOfStringToValueDef) New() ListOfRefOfMapOfStringToValue {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = NewRefOfMapOfStringToValue(d)
|
||||
}
|
||||
return ListOfRefOfMapOfStringToValue{types.NewTypedList(__typeForListOfRefOfMapOfStringToValue, l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Def() ListOfRefOfMapOfStringToValueDef {
|
||||
d := make([]ref.Ref, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = l.l.Get(i).(RefOfMapOfStringToValue).TargetRef()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForListOfRefOfMapOfStringToValue.Equals(other.Type()) && l.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Ref() ref.Ref {
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, l.Type().Chunks()...)
|
||||
chunks = append(chunks, l.l.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, l.l.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes ListOfRefOfMapOfStringToValue.
|
||||
var __typeForListOfRefOfMapOfStringToValue types.Type
|
||||
|
||||
func (m ListOfRefOfMapOfStringToValue) Type() types.Type {
|
||||
return __typeForListOfRefOfMapOfStringToValue
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForListOfRefOfMapOfStringToValue = types.MakeCompoundType(types.ListKind, types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakePrimitiveType(types.ValueKind))))
|
||||
types.RegisterValue(__typeForListOfRefOfMapOfStringToValue, builderForListOfRefOfMapOfStringToValue, readerForListOfRefOfMapOfStringToValue)
|
||||
}
|
||||
|
||||
func builderForListOfRefOfMapOfStringToValue(v types.Value) types.Value {
|
||||
return ListOfRefOfMapOfStringToValue{v.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForListOfRefOfMapOfStringToValue(v types.Value) types.Value {
|
||||
return v.(ListOfRefOfMapOfStringToValue).l
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Len() uint64 {
|
||||
return l.l.Len()
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Empty() bool {
|
||||
return l.Len() == uint64(0)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Get(i uint64) RefOfMapOfStringToValue {
|
||||
return l.l.Get(i).(RefOfMapOfStringToValue)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Slice(idx uint64, end uint64) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Set(i uint64, val RefOfMapOfStringToValue) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Append(v ...RefOfMapOfStringToValue) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Insert(idx uint64, v ...RefOfMapOfStringToValue) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Remove(idx uint64, end uint64) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) RemoveAt(idx uint64) ListOfRefOfMapOfStringToValue {
|
||||
return ListOfRefOfMapOfStringToValue{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) fromElemSlice(p []RefOfMapOfStringToValue) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ListOfRefOfMapOfStringToValueIterCallback func(v RefOfMapOfStringToValue, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Iter(cb ListOfRefOfMapOfStringToValueIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfMapOfStringToValue), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfMapOfStringToValueIterAllCallback func(v RefOfMapOfStringToValue, i uint64)
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) IterAll(cb ListOfRefOfMapOfStringToValueIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfMapOfStringToValue), i)
|
||||
})
|
||||
}
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) IterAllP(concurrency int, cb ListOfRefOfMapOfStringToValueIterAllCallback) {
|
||||
l.l.IterAllP(concurrency, func(v types.Value, i uint64) {
|
||||
cb(v.(RefOfMapOfStringToValue), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfRefOfMapOfStringToValueFilterCallback func(v RefOfMapOfStringToValue, i uint64) (keep bool)
|
||||
|
||||
func (l ListOfRefOfMapOfStringToValue) Filter(cb ListOfRefOfMapOfStringToValueFilterCallback) ListOfRefOfMapOfStringToValue {
|
||||
out := l.l.Filter(func(v types.Value, i uint64) bool {
|
||||
return cb(v.(RefOfMapOfStringToValue), i)
|
||||
})
|
||||
return ListOfRefOfMapOfStringToValue{out, &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfMapOfStringToValue
|
||||
|
||||
type RefOfMapOfStringToValue struct {
|
||||
target ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfMapOfStringToValue(target ref.Ref) RefOfMapOfStringToValue {
|
||||
return RefOfMapOfStringToValue{target, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) TargetRef() ref.Ref {
|
||||
return r.target
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) Ref() ref.Ref {
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForRefOfMapOfStringToValue.Equals(other.Type()) && r.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, r.Type().Chunks()...)
|
||||
chunks = append(chunks, r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) ChildValues() []types.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfMapOfStringToValue.
|
||||
var __typeForRefOfMapOfStringToValue types.Type
|
||||
|
||||
func (r RefOfMapOfStringToValue) Type() types.Type {
|
||||
return __typeForRefOfMapOfStringToValue
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) Less(other types.OrderedValue) bool {
|
||||
return r.TargetRef().Less(other.(types.RefBase).TargetRef())
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForRefOfMapOfStringToValue = types.MakeCompoundType(types.RefKind, types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakePrimitiveType(types.ValueKind)))
|
||||
types.RegisterRef(__typeForRefOfMapOfStringToValue, builderForRefOfMapOfStringToValue)
|
||||
}
|
||||
|
||||
func builderForRefOfMapOfStringToValue(r ref.Ref) types.RefBase {
|
||||
return NewRefOfMapOfStringToValue(r)
|
||||
}
|
||||
|
||||
func (r RefOfMapOfStringToValue) TargetValue(vr types.ValueReader) MapOfStringToValue {
|
||||
return vr.ReadValue(r.target).(MapOfStringToValue)
|
||||
}
|
||||
|
||||
// MapOfStringToValue
|
||||
|
||||
type MapOfStringToValue struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToValue() MapOfStringToValue {
|
||||
return MapOfStringToValue{types.NewTypedMap(__typeForMapOfStringToValue), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueDef map[string]types.Value
|
||||
|
||||
func (def MapOfStringToValueDef) New() MapOfStringToValue {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), v)
|
||||
}
|
||||
return MapOfStringToValue{types.NewTypedMap(__typeForMapOfStringToValue, kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Def() MapOfStringToValueDef {
|
||||
def := make(map[string]types.Value)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = v
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Equals(other types.Value) bool {
|
||||
return other != nil && __typeForMapOfStringToValue.Equals(other.Type()) && m.Ref() == other.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Ref() ref.Ref {
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Chunks() (chunks []types.RefBase) {
|
||||
chunks = append(chunks, m.Type().Chunks()...)
|
||||
chunks = append(chunks, m.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) ChildValues() []types.Value {
|
||||
return append([]types.Value{}, m.m.ChildValues()...)
|
||||
}
|
||||
|
||||
// A Noms Value that describes MapOfStringToValue.
|
||||
var __typeForMapOfStringToValue types.Type
|
||||
|
||||
func (m MapOfStringToValue) Type() types.Type {
|
||||
return __typeForMapOfStringToValue
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeForMapOfStringToValue = types.MakeCompoundType(types.MapKind, types.MakePrimitiveType(types.StringKind), types.MakePrimitiveType(types.ValueKind))
|
||||
types.RegisterValue(__typeForMapOfStringToValue, builderForMapOfStringToValue, readerForMapOfStringToValue)
|
||||
}
|
||||
|
||||
func builderForMapOfStringToValue(v types.Value) types.Value {
|
||||
return MapOfStringToValue{v.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func readerForMapOfStringToValue(v types.Value) types.Value {
|
||||
return v.(MapOfStringToValue).m
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Has(p string) bool {
|
||||
return m.m.Has(types.NewString(p))
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Get(p string) types.Value {
|
||||
return m.m.Get(types.NewString(p))
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) MaybeGet(p string) (types.Value, bool) {
|
||||
v, ok := m.m.MaybeGet(types.NewString(p))
|
||||
if !ok {
|
||||
return types.Bool(false), false
|
||||
}
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Set(k string, v types.Value) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToValue) Remove(p string) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueIterCallback func(k string, v types.Value) (stop bool)
|
||||
|
||||
func (m MapOfStringToValue) Iter(cb MapOfStringToValueIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v)
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToValueIterAllCallback func(k string, v types.Value)
|
||||
|
||||
func (m MapOfStringToValue) IterAll(cb MapOfStringToValueIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v)
|
||||
})
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) IterAllP(concurrency int, cb MapOfStringToValueIterAllCallback) {
|
||||
m.m.IterAllP(concurrency, func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), v)
|
||||
})
|
||||
}
|
||||
|
||||
type MapOfStringToValueFilterCallback func(k string, v types.Value) (keep bool)
|
||||
|
||||
func (m MapOfStringToValue) Filter(cb MapOfStringToValueFilterCallback) MapOfStringToValue {
|
||||
out := m.m.Filter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), v)
|
||||
})
|
||||
return MapOfStringToValue{out, &ref.Ref{}}
|
||||
}
|
||||
@@ -41,15 +41,17 @@ func NomsValueFromDecodedJSON(o interface{}) types.Value {
|
||||
}
|
||||
return types.NewList(items...)
|
||||
case map[string]interface{}:
|
||||
outDef := MapOfStringToValueDef{}
|
||||
kv := make([]types.Value, 0, len(o)*2)
|
||||
|
||||
for k, v := range o {
|
||||
nv := NomsValueFromDecodedJSON(v)
|
||||
if nv != nil {
|
||||
outDef[k] = nv
|
||||
kv = append(kv, types.NewString(k), nv)
|
||||
}
|
||||
}
|
||||
return outDef.New()
|
||||
|
||||
return NewMapOfStringToValue(kv...)
|
||||
|
||||
default:
|
||||
d.Chk.Fail("Nomsification failed.", "I don't understand %+v, which is of type %s!\n", o, reflect.TypeOf(o).String())
|
||||
}
|
||||
|
||||
@@ -38,11 +38,15 @@ func (suite *LibTestSuite) TestCompositeTypes() {
|
||||
// "list": [false true],
|
||||
// "map": {"nested": "string"}
|
||||
// }
|
||||
m := MapOfStringToValueDef{
|
||||
"string": types.NewString("string"),
|
||||
"list": types.NewList().Append(types.Bool(false)).Append(types.Bool(true)),
|
||||
"map": MapOfStringToValueDef{"nested": types.NewString("string")}.New(),
|
||||
}.New()
|
||||
m := NewMapOfStringToValue(
|
||||
types.NewString("string"),
|
||||
types.NewString("string"),
|
||||
types.NewString("list"),
|
||||
types.NewList().Append(types.Bool(false)).Append(types.Bool(true)),
|
||||
types.NewString("map"),
|
||||
NewMapOfStringToValue(
|
||||
types.NewString("nested"),
|
||||
types.NewString("string")))
|
||||
o := NomsValueFromDecodedJSON(map[string]interface{}{
|
||||
"string": "string",
|
||||
"list": []interface{}{false, true},
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/clbanning/mxj"
|
||||
)
|
||||
|
||||
@@ -123,13 +124,20 @@ func main() {
|
||||
}
|
||||
sort.Sort(refList)
|
||||
|
||||
refs := make(util.ListOfRefOfMapOfStringToValueDef, len(refList))
|
||||
refs := make([]types.Value, len(refList))
|
||||
for idx, r := range refList {
|
||||
refs[idx] = r.ref
|
||||
refs[idx] = types.NewRef(r.ref)
|
||||
}
|
||||
|
||||
rl := types.NewTypedList(
|
||||
types.MakeCompoundType(types.ListKind,
|
||||
types.MakeCompoundType(types.RefKind,
|
||||
types.MakeCompoundType(types.MapKind,
|
||||
types.MakePrimitiveType(types.StringKind),
|
||||
types.MakePrimitiveType(types.ValueKind)))), refs...)
|
||||
|
||||
if !*noIO {
|
||||
_, err := ds.Commit(refs.New())
|
||||
_, err := ds.Commit(rl)
|
||||
d.Exp.NoError(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user