Beispiel #1
0
func indexFn(p kvl.Pair) []kvl.Pair {
	if p.IsZero() {
		return nil
	}

	var typ string
	_, err := tuple.UnpackIntoPartial(p.Key, &typ)
	if err != nil {
		return nil
	}

	switch typ {
	case "file":
		var f File
		err := f.fromPair(p)
		if err != nil {
			return nil
		}
		return f.indexPairs()

	case "location":
		var l Location
		err := l.fromPair(p)
		if err != nil {
			return nil
		}
		return l.indexPairs()

	default:
		return nil
	}
}
Beispiel #2
0
func (l *Location) toPair() kvl.Pair {
	var p kvl.Pair

	p.Key = tuple.MustAppend(nil, "location", l.UUID)

	p.Value = tuple.MustAppend(nil, 0, l.URL, l.Name, l.Dead, l.LastSeen)
	for _, split := range l.AllocSplit {
		p.Value = tuple.MustAppend(p.Value, split)
	}

	return p
}
Beispiel #3
0
func (f *File) toPair() kvl.Pair {
	var p kvl.Pair

	p.Key = fileKey(f.Path)

	p.Value = tuple.MustAppend(nil,
		0, f.Size, f.SHA256, f.WriteTime, f.PrefixID, f.DataChunks,
		f.MappingValue)
	for _, loc := range f.Locations {
		p.Value = tuple.MustAppend(p.Value, loc)
	}

	return p
}