當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SliceStore.EndWriting方法代碼示例

本文整理匯總了Golang中github.com/sburnett/transformer/store.SliceStore.EndWriting方法的典型用法代碼示例。如果您正苦於以下問題:Golang SliceStore.EndWriting方法的具體用法?Golang SliceStore.EndWriting怎麽用?Golang SliceStore.EndWriting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/sburnett/transformer/store.SliceStore的用法示例。


在下文中一共展示了SliceStore.EndWriting方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ExampleIncludeNodes_multipleNodes

func ExampleIncludeNodes_multipleNodes() {
	inputRecords := store.SliceStore{}
	inputRecords.BeginWriting()
	inputRecords.WriteRecord(makeRecordToInclude("node1", 1))
	inputRecords.WriteRecord(makeRecordToInclude("node1", 2))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 3))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 4))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 5))
	inputRecords.WriteRecord(makeRecordToInclude("node3", 6))
	inputRecords.WriteRecord(makeRecordToInclude("node3", 7))
	inputRecords.WriteRecord(makeRecordToInclude("node4", 8))
	inputRecords.WriteRecord(makeRecordToInclude("node4", 9))
	inputRecords.WriteRecord(makeRecordToInclude("node5", 10))
	inputRecords.WriteRecord(makeRecordToInclude("node6", 11))
	inputRecords.WriteRecord(makeRecordToInclude("node7", 12))
	inputRecords.EndWriting()

	outputRecords := FilterNodes(&inputRecords, "node2", "node4", "node5", "node7")
	runIncludeNodes(outputRecords)

	// Output:
	// node2 3
	// node2 4
	// node2 5
	// node4 8
	// node4 9
	// node5 10
	// node7 12
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:29,代碼來源:filtertraces_test.go

示例2: 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()
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:25,代碼來源:transformers_test.go

示例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()
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:26,代碼來源:transformers_test.go

示例4: 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
}
開發者ID:sburnett,項目名稱:transformer,代碼行數:35,代碼來源:join_test.go

示例5: FilterNodes

func FilterNodes(reader store.Seeker, nodes ...string) store.Seeker {
	nodesStore := store.SliceStore{}
	nodesStore.BeginWriting()
	for _, node := range nodes {
		nodesStore.WriteRecord(&store.Record{
			Key: lex.EncodeOrDie(node),
		})
	}
	nodesStore.EndWriting()
	return store.NewPrefixIncludingReader(reader, &nodesStore)
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:11,代碼來源:filtertraces.go

示例6: ReadOnlySomeLogs

func ReadOnlySomeLogs(stor store.Seeker, logTypes ...string) store.Seeker {
	prefixStore := store.SliceStore{}
	prefixStore.BeginWriting()
	for _, logType := range logTypes {
		record := store.Record{
			Key: lex.EncodeOrDie(logType),
		}
		prefixStore.WriteRecord(&record)
	}
	prefixStore.EndWriting()
	return store.NewPrefixIncludingReader(stor, &prefixStore)
}
開發者ID:sburnett,項目名稱:bismark-tools,代碼行數:12,代碼來源:common.go

示例7: ExampleIncludeNodes

func ExampleIncludeNodes() {
	inputRecords := store.SliceStore{}
	inputRecords.BeginWriting()
	inputRecords.WriteRecord(makeRecordToInclude("node1", 1))
	inputRecords.WriteRecord(makeRecordToInclude("node1", 2))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 3))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 4))
	inputRecords.WriteRecord(makeRecordToInclude("node2", 5))
	inputRecords.WriteRecord(makeRecordToInclude("node3", 6))
	inputRecords.EndWriting()

	outputRecords := FilterNodes(&inputRecords, "node2")
	runIncludeNodes(outputRecords)

	// Output:
	// node2 3
	// node2 4
	// node2 5
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:19,代碼來源:filtertraces_test.go

示例8: 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
}
開發者ID:sburnett,項目名稱:transformer,代碼行數:43,代碼來源:join_test.go


注:本文中的github.com/sburnett/transformer/store.SliceStore.EndWriting方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。