本文整理汇总了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
}
示例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)
}
示例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
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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"))
}
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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())
}