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


Golang proto.Int64函數代碼示例

本文整理匯總了Golang中code/google/com/p/goprotobuf/proto.Int64函數的典型用法代碼示例。如果您正苦於以下問題:Golang Int64函數的具體用法?Golang Int64怎麽用?Golang Int64使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: insert

// Insert can insert record into a btree
func (t *Btree) insert(record TreeLog) error {
	tnode, err := t.getTreeNode(t.GetRoot())
	if err != nil {
		if err.Error() != "no data" {
			return err
		}
		nnode := t.newTreeNode()
		nnode.NodeType = proto.Int32(isLeaf)
		_, err = nnode.insertRecord(record, t)
		if err == nil {
			t.Nodes[nnode.GetId()], err = proto.Marshal(nnode)
		}
		t.Root = proto.Int64(nnode.GetId())
		return err
	}
	clonednode, err := tnode.insertRecord(record, t)
	if err == nil && len(clonednode.GetKeys()) > int(t.GetNodeMax()) {
		nnode := t.newTreeNode()
		nnode.NodeType = proto.Int32(isNode)
		key, left, right := clonednode.split(t)
		nnode.insertOnce(key, left, right, t)
		t.Nodes[nnode.GetId()], err = proto.Marshal(nnode)
		t.Root = proto.Int64(nnode.GetId())
	} else {
		t.Root = proto.Int64(clonednode.GetId())
	}
	return err
}
開發者ID:kennylixi,項目名稱:btree,代碼行數:29,代碼來源:insert.go

示例2: TestParseSectionIntro_Valid

func TestParseSectionIntro_Valid(t *testing.T) {
	lines := []string{
		"10",
		"BUILDID",
		"NODEID 123 321 789",
		"12 23 34",
	}
	trace := Trace{}
	err := parseSectionIntro(lines, &trace)
	if err != nil {
		t.Fatal("Unexpected error:", err)
	}
	expectedTrace := Trace{
		FileFormatVersion: proto.Int32(10),
		BuildId:           proto.String("BUILDID"),
		NodeId:            proto.String("NODEID"),
		ProcessStartTimeMicroseconds: proto.Int64(123),
		SequenceNumber:               proto.Int32(321),
		TraceCreationTimestamp:       proto.Int64(789),
		PcapReceived:                 proto.Uint32(12),
		PcapDropped:                  proto.Uint32(23),
		InterfaceDropped:             proto.Uint32(34),
	}
	checkProtosEqual(t, &expectedTrace, &trace)
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:25,代碼來源:trace_test.go

示例3: NewTimestampDatum

func NewTimestampDatum(key string, timestamp int64, t time.Time) (
	d pb.TelemetryDatum) {
	d.Key = proto.String(key)
	d.Timestamp = proto.Int64(timestamp)
	d.UnixTimestamp = proto.Int64(t.Unix())
	return d
}
開發者ID:tstranex,項目名稱:carpcomm,代碼行數:7,代碼來源:datum.go

示例4: TestRunBroadcastFive

func TestRunBroadcastFive(t *testing.T) {
	c := make(chan Packet, 100)
	var r run
	r.seqn = 1
	r.out = c
	r.addr = []*net.UDPAddr{
		MustResolveUDPAddr("udp", "1.2.3.4:5"),
		MustResolveUDPAddr("udp", "2.3.4.5:6"),
		MustResolveUDPAddr("udp", "3.4.5.6:7"),
		MustResolveUDPAddr("udp", "4.5.6.7:8"),
		MustResolveUDPAddr("udp", "5.6.7.8:9"),
	}

	r.broadcast(newInvite(1))
	c <- Packet{}

	exp := msg{
		Seqn: proto.Int64(1),
		Cmd:  invite,
		Crnd: proto.Int64(1),
	}

	addr := make([]*net.UDPAddr, len(r.addr))
	for i := 0; i < len(r.addr); i++ {
		p := <-c
		addr[i] = p.Addr
		var got msg
		err := proto.Unmarshal(p.Data, &got)
		assert.Equal(t, nil, err)
		assert.Equal(t, exp, got)
	}

	assert.Equal(t, Packet{}, <-c)
	assert.Equal(t, r.addr, addr)
}
開發者ID:CrazyJvm,項目名稱:doozerd,代碼行數:35,代碼來源:run_test.go

示例5: TestParseSectionPacketSeries_Valid

func TestParseSectionPacketSeries_Valid(t *testing.T) {
	lines := []string{
		"10 11",
		"0 10 23",
		"20 12 45",
		"10 10 20",
	}
	trace := Trace{}
	err := parseSectionPacketSeries(lines, &trace)
	if err != nil {
		t.Fatal("Unexpected error:", err)
	}
	expectedTrace := Trace{
		PacketSeriesDropped: proto.Uint32(11),
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(10),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(23),
			},
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(30),
				Size:   proto.Int32(12),
				FlowId: proto.Int32(45),
			},
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(40),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(20),
			},
		},
	}
	checkProtosEqual(t, &expectedTrace, &trace)
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:34,代碼來源:trace_test.go

示例6: UpdateBatch

// UpdateBatch implements HighWatermarker.
func (w *LevelDBHighWatermarker) UpdateBatch(m FingerprintHighWatermarkMapping) error {
	batch := leveldb.NewBatch()
	defer batch.Close()

	for fp, t := range m {
		existing, present, err := w.Get(&fp)
		if err != nil {
			return err
		}
		k := &dto.Fingerprint{}
		dumpFingerprint(k, &fp)
		v := &dto.MetricHighWatermark{}
		if !present {
			v.Timestamp = proto.Int64(t.Unix())
			batch.Put(k, v)

			continue
		}

		// BUG(matt): Replace this with watermark management.
		if t.After(existing) {
			v.Timestamp = proto.Int64(t.Unix())
			batch.Put(k, v)
		}
	}

	return w.LevelDBPersistence.Commit(batch)
}
開發者ID:pjjw,項目名稱:prometheus,代碼行數:29,代碼來源:watermark.go

示例7: TestRunBroadcastFive

func TestRunBroadcastFive(t *testing.T) {
	c := make(chan Packet, 100)
	var r run
	r.seqn = 1
	r.out = c
	r.addr = []*net.UDPAddr{
		&net.UDPAddr{net.IP{1, 2, 3, 4}, 5},
		&net.UDPAddr{net.IP{2, 3, 4, 5}, 6},
		&net.UDPAddr{net.IP{3, 4, 5, 6}, 7},
		&net.UDPAddr{net.IP{4, 5, 6, 7}, 8},
		&net.UDPAddr{net.IP{5, 6, 7, 8}, 9},
	}

	r.broadcast(newInvite(1))
	c <- Packet{}

	exp := msg{
		Seqn: proto.Int64(1),
		Cmd:  invite,
		Crnd: proto.Int64(1),
	}

	addr := make([]*net.UDPAddr, len(r.addr))
	for i := 0; i < len(r.addr); i++ {
		p := <-c
		addr[i] = p.Addr
		var got msg
		err := proto.Unmarshal(p.Data, &got)
		assert.Equal(t, nil, err)
		assert.Equal(t, exp, got)
	}

	assert.Equal(t, Packet{}, <-c)
	assert.Equal(t, r.addr, addr)
}
開發者ID:lfranchi,項目名稱:doozerd,代碼行數:35,代碼來源:run_test.go

示例8: OnReceive

func (p *Actor) OnReceive(uid interface{}, data []byte) {
	m, err := kodec.Unboxing(data)
	if err != nil {
		log.Println("decode err ", err)
		return
	}

	switch v := m.(type) {
	case *kodec.Msg:
		v.From = proto.Int64(int64(uid.(int)))
		v.Ct = proto.Int64(tick())

		if v.GetTp() != kodec.Msg_SYS {
			from := int(v.GetFrom())
			to := v.GetTo()
			if !p.checker.CheckUp(from, to) {
				log.Println(fmt.Errorf("warning: chat not allow, %d -> %v \n", from, to))
				return
			}
		}
		p.dispatchMsg(v)
	default:
		log.Println(fmt.Errorf("unknown data frame"))
	}
}
開發者ID:zhaijian,項目名稱:tok,代碼行數:25,代碼來源:actor.go

示例9: scuttlebutt

func (g *Gossiper) scuttlebutt(id string, reqd []*Digest) ([]*Digest, []*Delta) {
	digests := make([]*Digest, 0)
	deltas := make([]*Delta, 0)

	for _, d := range reqd {
		p := g.peers[d.GetId()]

		if p == nil {
			digests = append(digests, &Digest{
				Id:      proto.String(d.GetId()),
				Gen:     proto.Int64(0),
				Version: proto.Int64(0),
			})
		} else {
			cr := p.compare(d.GetGen(), d.GetVersion())
			switch {
			case cr > 0:
				deltas = append(deltas, g.deltaAfterVersion(p, d.GetVersion()))
			case cr < 0:
				digests = append(digests, &Digest{
					Id:      proto.String(p.id),
					Gen:     proto.Int64(p.gen),
					Version: proto.Int64(p.version),
				})
			}
		}
	}

	return digests, deltas
}
開發者ID:hujh,項目名稱:gossip,代碼行數:30,代碼來源:scuttlebutt.go

示例10: BenchmarkRegressionSplitter

func BenchmarkRegressionSplitter(b *testing.B) {
	flag.Parse()

	forestConfig := &pb.ForestConfig{
		NumWeakLearners: proto.Int64(int64(*numTrees)),
		SplittingConstraints: &pb.SplittingConstraints{
			MaximumLevels: proto.Int64(int64(*numLevels)),
		},
		LossFunctionConfig: &pb.LossFunctionConfig{
			LossFunction: pb.LossFunction_LOGIT.Enum(),
		},
		Algorithm: pb.Algorithm_BOOSTING.Enum(),
	}

	glog.Info(forestConfig.String())

	generator, err := NewForestGenerator(forestConfig)
	if err != nil {
		glog.Fatal(err)
	}
	examples := constructBenchmarkExamples(b.N, *numFeatures, 0)
	glog.Infof("Starting with %v examples", len(examples))

	b.ResetTimer()
	forest := generator.ConstructForest(examples)
	res, err := json.MarshalIndent(forest, "", "  ")
	if err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.Info(res)
}
開發者ID:adamdrake,項目名稱:decisiontrees,代碼行數:31,代碼來源:regression_splitter_test.go

示例11: ExampleBytesPerDevice_multipleSessions

func ExampleBytesPerDevice_multipleSessions() {
	trace1 := Trace{
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(0),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(4),
			},
		},
		FlowTableEntry: []*FlowTableEntry{
			&FlowTableEntry{
				FlowId:   proto.Int32(4),
				SourceIp: proto.String("1.2.3.4"),
			},
		},
		AddressTableEntry: []*AddressTableEntry{
			&AddressTableEntry{
				IpAddress:  proto.String("1.2.3.4"),
				MacAddress: proto.String("AABBCCDDEEFF"),
			},
		},
	}
	trace2 := Trace{
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(0),
				Size:   proto.Int32(13),
				FlowId: proto.Int32(4),
			},
		},
	}
	trace3 := Trace{
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(0),
				Size:   proto.Int32(20),
				FlowId: proto.Int32(4),
			},
		},
	}
	consistentRanges := []*store.Record{
		&store.Record{
			Key:   lex.EncodeOrDie("node0", "anon0", int64(0), int32(0)),
			Value: lex.EncodeOrDie("node0", "anon0", int64(0), int32(2)),
		},
	}
	firstRecords := map[string]Trace{
		string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(0))): trace1,
	}
	secondRecords := map[string]Trace{
		string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(1))): trace2,
		string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(2))): trace3,
	}
	runBytesPerDevicePipeline(consistentRanges, firstRecords, secondRecords)

	// Output:
	// node0,AABBCCDDEEFF,0: 43
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:58,代碼來源:bytesperdevice_test.go

示例12: ExampleBytesPerDevice_macBoundAtStartOfFlow

func ExampleBytesPerDevice_macBoundAtStartOfFlow() {
	trace1 := Trace{
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(0),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(4),
			},
		},
		FlowTableEntry: []*FlowTableEntry{
			&FlowTableEntry{
				FlowId:        proto.Int32(4),
				SourceIp:      proto.String("1.2.3.4"),
				DestinationIp: proto.String("4.3.2.1"),
			},
		},
		AddressTableEntry: []*AddressTableEntry{
			&AddressTableEntry{
				IpAddress:  proto.String("1.2.3.4"),
				MacAddress: proto.String("AABBCCDDEEFF"),
			},
		},
	}
	trace2 := Trace{
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(0),
				Size:   proto.Int32(12),
				FlowId: proto.Int32(4),
			},
		},
		AddressTableEntry: []*AddressTableEntry{
			&AddressTableEntry{
				IpAddress:  proto.String("1.2.3.4"),
				MacAddress: proto.String("FFEEDDCCBBAA"),
			},
		},
	}
	consistentRanges := []*store.Record{
		&store.Record{
			Key:   lex.EncodeOrDie("node0", "anon0", int64(0), int32(0)),
			Value: lex.EncodeOrDie("node0", "anon0", int64(0), int32(1)),
		},
	}
	records := map[string]Trace{
		string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(0))): trace1,
		string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(1))): trace2,
	}
	runBytesPerDevicePipeline(consistentRanges, records)

	// Output:
	// node0,AABBCCDDEEFF,0: 22
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:53,代碼來源:bytesperdevice_test.go

示例13: Get

func (c curationState) Get() (key, value coding.Encoder) {
	key = coding.NewProtocolBuffer(&dto.CurationKey{
		Fingerprint:      model.NewFingerprintFromRowKey(c.fingerprint).ToDTO(),
		MinimumGroupSize: proto.Uint32(uint32(c.groupSize)),
		OlderThan:        proto.Int64(int64(c.recencyThreshold)),
	})

	value = coding.NewProtocolBuffer(&dto.CurationValue{
		LastCompletionTimestamp: proto.Int64(c.lastCurated.Unix()),
	})

	return
}
開發者ID:bernerdschaefer,項目名稱:prometheus,代碼行數:13,代碼來源:curator_test.go

示例14: createmessage

func createmessage() []byte {
	ProtoMessage := new(msgproto.Msg)
	ProtoMessage.Id = proto.Int32(12344)
	ProtoMessage.Lat = proto.Int64(12344)
	ProtoMessage.Long = proto.Int64(12344)
	ProtoMessage.Utime = proto.Int64(int64(time.Now().Unix()))
	data, err := proto.Marshal(ProtoMessage)
	if err != nil {
		fmt.Println(err)
	}
	return data

}
開發者ID:ramvjai,項目名稱:bustracker,代碼行數:13,代碼來源:db_tets.go

示例15: runAvailabilityPipelineAugmented

func runAvailabilityPipelineAugmented(startTimestamp int64, timestamps map[string]int64, moreTimestamps map[string]int64) {
	levelDbManager := store.NewSliceManager()

	tracesStore := levelDbManager.Writer("traces")
	tracesStore.BeginWriting()
	for encodedKey, timestamp := range timestamps {
		trace := Trace{
			TraceCreationTimestamp: proto.Int64(timestamp),
		}
		encodedTrace, err := proto.Marshal(&trace)
		if err != nil {
			panic(fmt.Errorf("Error encoding protocol buffer: %v", err))
		}
		tracesStore.WriteRecord(&store.Record{Key: []byte(encodedKey), Value: encodedTrace})
	}
	tracesStore.EndWriting()

	writer := bytes.NewBuffer([]byte{})
	transformer.RunPipeline(AvailabilityPipeline(levelDbManager, writer, startTimestamp))

	tracesStore.BeginWriting()
	for encodedKey, timestamp := range moreTimestamps {
		trace := Trace{
			TraceCreationTimestamp: proto.Int64(timestamp),
		}
		encodedTrace, err := proto.Marshal(&trace)
		if err != nil {
			panic(fmt.Errorf("Error encoding protocol buffer: %v", err))
		}
		tracesStore.WriteRecord(&store.Record{Key: []byte(encodedKey), Value: encodedTrace})
	}
	tracesStore.EndWriting()

	anotherTracesSlice := make([]*store.Record, 0)
	for encodedKey, timestamp := range moreTimestamps {
		trace := Trace{
			TraceCreationTimestamp: proto.Int64(timestamp),
		}
		encodedTrace, err := proto.Marshal(&trace)
		if err != nil {
			panic(fmt.Errorf("Error encoding protocol buffer: %v", err))
		}
		anotherTracesSlice = append(anotherTracesSlice, &store.Record{Key: []byte(encodedKey), Value: encodedTrace})
	}

	anotherWriter := bytes.NewBuffer([]byte{})
	transformer.RunPipeline(AvailabilityPipeline(levelDbManager, anotherWriter, startTimestamp))
	fmt.Printf("%s", anotherWriter.Bytes())
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:49,代碼來源:availability_test.go


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