本文整理汇总了Golang中code/google/com/p/goprotobuf/proto.Int64函数的典型用法代码示例。如果您正苦于以下问题:Golang Int64函数的具体用法?Golang Int64怎么用?Golang Int64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Divide
func (m *MyCalcService) Divide(req *CalcRequest, resp *CalcResponse) (err error) {
resp.Result = proto.Int64(0)
defer func() {
if x := recover(); x != nil {
if ex, ok := x.(error); ok {
err = ex
} else {
err = errors.New(fmt.Sprint(x))
}
}
}()
resp.Result = proto.Int64((*req.A) / (*req.B))
resp.Remainder = proto.Int64((*req.A) % (*req.B))
return
}
开发者ID:yanatan16,项目名称:protorpc,代码行数:15,代码来源:calc_impl.go
示例17: CreateEntryWithDuration
func (project *Project) CreateEntryWithDuration(
content string,
duration time.Duration,
billable bool) *Entry {
e := project.CreateEntry(content, billable)
endTime := time.Now()
startTime := endTime.Add(-duration)
e.Started = proto.Int64(startTime.Unix())
e.Ended = proto.Int64(endTime.Unix())
e.Duration = proto.Int64(duration.Nanoseconds())
return e
}
开发者ID:DrGo,项目名称:samay,代码行数:15,代码来源:data.go
示例18: eventToPbEvent
func eventToPbEvent(event *Event) (*proto.Event, error) {
var e proto.Event
if event.Host == "" {
event.Host, _ = os.Hostname()
}
t := reflect.ValueOf(&e).Elem()
s := reflect.ValueOf(event).Elem()
typeOfEvent := s.Type()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
value := reflect.ValueOf(f.Interface())
if reflect.Zero(f.Type()) != value && f.Interface() != nil {
name := typeOfEvent.Field(i).Name
switch name {
case "State", "Service", "Host", "Description":
tmp := reflect.ValueOf(pb.String(value.String()))
t.FieldByName(name).Set(tmp)
case "Ttl":
tmp := reflect.ValueOf(pb.Float32(float32(value.Float())))
t.FieldByName(name).Set(tmp)
case "Time":
tmp := reflect.ValueOf(pb.Int64(value.Int()))
t.FieldByName(name).Set(tmp)
case "Tags":
tmp := reflect.ValueOf(value.Interface().([]string))
t.FieldByName(name).Set(tmp)
case "Metric":
switch reflect.TypeOf(f.Interface()).Kind() {
case reflect.Int:
tmp := reflect.ValueOf(pb.Int64(int64(value.Int())))
t.FieldByName("MetricSint64").Set(tmp)
case reflect.Float32:
tmp := reflect.ValueOf(pb.Float32(float32(value.Float())))
t.FieldByName("MetricF").Set(tmp)
case reflect.Float64:
tmp := reflect.ValueOf(pb.Float64(value.Float()))
t.FieldByName("MetricD").Set(tmp)
default:
return nil, fmt.Errorf("Metric of invalid type (type %v)",
reflect.TypeOf(f.Interface()).Kind())
}
}
}
}
return &e, nil
}
开发者ID:nelhage,项目名称:raidman,代码行数:48,代码来源:raidman.go
示例19: AllocateIDs
// AllocateIDs returns a range of n integer IDs with the given kind and parent
// combination. kind cannot be empty; parent may be nil. The IDs in the range
// returned will not be used by the datastore's automatic ID sequence generator
// and may be used with NewKey without conflict.
//
// The range is inclusive at the low end and exclusive at the high end. In
// other words, valid intIDs x satisfy low <= x && x < high.
//
// If no error is returned, low + n == high.
func AllocateIDs(c appengine.Context, kind string, parent *Key, n int) (low, high int64, err error) {
if kind == "" {
return 0, 0, errors.New("datastore: AllocateIDs given an empty kind")
}
if n < 0 {
return 0, 0, fmt.Errorf("datastore: AllocateIDs given a negative count: %d", n)
}
if n == 0 {
return 0, 0, nil
}
req := &pb.AllocateIdsRequest{
ModelKey: keyToProto("", NewIncompleteKey(c, kind, parent)),
Size: proto.Int64(int64(n)),
}
res := &pb.AllocateIdsResponse{}
if err := c.Call("datastore_v3", "AllocateIds", req, res, nil); err != nil {
return 0, 0, err
}
// The protobuf is inclusive at both ends. Idiomatic Go (e.g. slices, for loops)
// is inclusive at the low end and exclusive at the high end, so we add 1.
low = res.GetStart()
high = res.GetEnd() + 1
if low+int64(n) != high {
return 0, 0, fmt.Errorf("datastore: internal error: could not allocate %d IDs", n)
}
return low, high, nil
}
开发者ID:yschu7,项目名称:go_test,代码行数:36,代码来源:key.go
示例20: lease
func lease(c appengine.Context, maxTasks int, queueName string, leaseTime int, groupByTag bool, tag []byte) ([]*Task, error) {
req := &taskqueue_proto.TaskQueueQueryAndOwnTasksRequest{
QueueName: []byte(queueName),
LeaseSeconds: proto.Float64(float64(leaseTime)),
MaxTasks: proto.Int64(int64(maxTasks)),
GroupByTag: proto.Bool(groupByTag),
Tag: tag,
}
res := &taskqueue_proto.TaskQueueQueryAndOwnTasksResponse{}
callOpts := &appengine_internal.CallOptions{
Timeout: 10 * time.Second,
}
if err := c.Call("taskqueue", "QueryAndOwnTasks", req, res, callOpts); err != nil {
return nil, err
}
tasks := make([]*Task, len(res.Task))
for i, t := range res.Task {
tasks[i] = &Task{
Payload: t.Body,
Name: string(t.TaskName),
Method: "PULL",
ETA: time.Unix(0, *t.EtaUsec*1e3),
RetryCount: *t.RetryCount,
Tag: string(t.Tag),
}
}
return tasks, nil
}
开发者ID:LeXa4894,项目名称:test,代码行数:28,代码来源:taskqueue.go
注:本文中的code/google/com/p/goprotobuf/proto.Int64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论