MCPcopy Create free account
hub / github.com/AdRoll/baker / Process

Method Process

filter/slice.go:63–82  ·  view source on GitHub ↗

Process records, slicing src field and saving the result to the dest field

(r baker.Record, next func(baker.Record))

Source from the content-addressed store, hash-verified

61
62// Process records, slicing src field and saving the result to the dest field
63func (f *Slice) Process(r baker.Record, next func(baker.Record)) {
64 src := r.Get(f.src)
65
66 // if end is 0 or greater than the field => end = len(field)
67 end := f.endIdx
68 if end > len(src) || end == 0 {
69 end = len(src)
70 }
71
72 // if start is greater or equal the length of the field, then we write an empty result
73 start := f.startIdx
74 if start >= len(src) {
75 start = len(src)
76 }
77
78 var empty []byte
79 r.Set(f.dst, append(empty, src[start:end]...))
80
81 next(r)
82}
83
84// Stats implements baker.Filter.
85func (f *Slice) Stats() baker.FilterStats {

Callers 1

TestSliceFunction · 0.95

Calls 2

GetMethod · 0.65
SetMethod · 0.65

Tested by 1

TestSliceFunction · 0.76