本文整理匯總了Golang中github.com/sburnett/transformer/store.SliceStore.ReadRecord方法的典型用法代碼示例。如果您正苦於以下問題:Golang SliceStore.ReadRecord方法的具體用法?Golang SliceStore.ReadRecord怎麽用?Golang SliceStore.ReadRecord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sburnett/transformer/store.SliceStore
的用法示例。
在下文中一共展示了SliceStore.ReadRecord方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: runCalculateTraceKeyRanges
func runCalculateTraceKeyRanges(records []*store.Record) {
traces := store.SliceStore{}
traces.BeginWriting()
for _, record := range records {
traces.WriteRecord(record)
}
traces.EndWriting()
rangesStore := store.SliceStore{}
consolidatedStore := store.SliceStore{}
transformer.RunPipeline(TraceKeyRangesPipeline(&traces, &rangesStore, &consolidatedStore))
rangesStore.BeginReading()
for {
record, err := rangesStore.ReadRecord()
if err != nil {
panic(err)
}
if record == nil {
break
}
fmt.Printf("%s %s\n", formatTraceKey(record.Key), formatTraceKey(record.Value))
}
rangesStore.EndReading()
}
示例2: ExampleJoin_inner
func ExampleJoin_inner() {
left := store.SliceStore{}
left.BeginWriting()
left.WriteRecord(store.NewRecord("1", "news", 0))
left.WriteRecord(store.NewRecord("2", "book", 0))
left.EndWriting()
right := store.SliceStore{}
right.BeginWriting()
right.WriteRecord(store.NewRecord("1", "paper", 0))
right.WriteRecord(store.NewRecord("3", "brush", 0))
right.EndWriting()
output := store.SliceStore{}
joiner := Join(nil, nil)
transformer.RunTransformer(transformer.MakeGroupDoFunc(joiner), store.NewDemuxingReader(&left, &right), &output)
output.BeginReading()
for {
record, err := output.ReadRecord()
if err != nil {
panic(err)
}
if record == nil {
break
}
fmt.Printf("%s: %s\n", record.Key, record.Value)
}
output.EndReading()
// Output:
//
// 1: newspaper
}
示例3: runSessions
func runSessions(records []*store.Record) {
traces := store.SliceStore{}
traces.BeginWriting()
for _, record := range records {
traces.WriteRecord(record)
}
traces.EndWriting()
sessionsStore := store.SliceStore{}
transformer.RunPipeline([]transformer.PipelineStage{
SessionPipelineStage(&traces, &sessionsStore),
})
sessionsStore.BeginReading()
for {
record, err := sessionsStore.ReadRecord()
if err != nil {
panic(err)
}
if record == nil {
break
}
fmt.Printf("%s\n", formatSessionKey(record.Key))
}
sessionsStore.EndReading()
}
示例4: ExampleJoin_multiple
func ExampleJoin_multiple() {
left := store.SliceStore{}
left.BeginWriting()
left.WriteRecord(store.NewRecord("1", "what", 0))
left.WriteRecord(store.NewRecord("2", "news", 0))
left.EndWriting()
middle := store.SliceStore{}
middle.BeginWriting()
middle.WriteRecord(store.NewRecord("1", "so", 0))
middle.WriteRecord(store.NewRecord("3", "the", 0))
middle.EndWriting()
right := store.SliceStore{}
right.BeginWriting()
right.WriteRecord(store.NewRecord("1", "ever", 0))
right.WriteRecord(store.NewRecord("3", "less", 0))
right.EndWriting()
output := store.SliceStore{}
joiner := Join([]byte("never"), []byte("paper"), []byte("man"))
transformer.RunTransformer(transformer.MakeGroupDoFunc(joiner), store.NewDemuxingReader(&left, &middle, &right), &output)
output.BeginReading()
for {
record, err := output.ReadRecord()
if err != nil {
panic(err)
}
if record == nil {
break
}
fmt.Printf("%s: %s\n", record.Key, record.Value)
}
output.EndReading()
// Output:
//
// 1: whatsoever
// 2: newspaperman
// 3: nevertheless
}