当前位置: 首页>>代码示例>>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;未经允许,请勿转载。