text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func (m *Master) Example(args *ExampleArgs, reply *ExampleReply) error {
fmt.Println("I'm in example ", args.X)
reply.Y = args.X + 1
return nil
} | [
0.229221910238266,
0.2550814151763916,
0.45135706663131714,
-0.20636163651943207,
0.03503976762294769,
0.3731304109096527,
0.17910873889923096,
1.14000403881073,
0.2411487102508545,
0.3669050931930542,
-1.3122265338897705,
1.4599785804748535,
-0.4119163453578949,
-0.2855921685695648,
-0.... |
func (m *Master) UpdateMapTaskStatus(args *UpdateStatusRequest, reply *UpdateStatusReply) error {
defer func() {
if err := recover(); err != nil {
log.Println("work failed:", err)
reply.Err = fmt.Sprintf("%s", err)
}
}()
m.mu.Lock()
defer m.mu.Unlock()
if args.Status == SUCCESS {
for _, record := range... | [
-1.5836535692214966,
-1.0321869850158691,
0.8580256700515747,
0.2241227775812149,
-0.5653083324432373,
0.6071317791938782,
-0.2860238254070282,
0.8167163133621216,
0.1740266978740692,
0.8151842951774597,
-0.41373273730278015,
-0.2669089734554291,
0.04395360127091408,
0.9034586548805237,
... |
func (m *Master) server() {
rpc.Register(m)
rpc.HandleHTTP()
//l, e := net.Listen("tcp", ":1234")
sockname := masterSock()
os.Remove(sockname)
l, e := net.Listen("unix", sockname)
if e != nil {
log.Fatal("listen error:", e)
}
go http.Serve(l, nil)
} | [
-0.5627836585044861,
-0.3185119032859802,
0.6255593299865723,
-0.08582790940999985,
1.1791318655014038,
0.8106944561004639,
-0.047648731619119644,
1.27376389503479,
-0.7720423936843872,
-0.20754043757915497,
-0.914108395576477,
0.10757902264595032,
-1.1161320209503174,
1.0134865045547485,
... |
func (m *Master) Done() bool {
// ret := (JobDown == m.phase)
// Your code here.
return JobDown == m.phase
} | [
-0.1124642863869667,
-0.21459312736988068,
0.6441572308540344,
1.1519594192504883,
-0.7989175319671631,
0.31987106800079346,
0.04492393136024475,
0.6542743444442749,
-0.06029779464006424,
-0.28551721572875977,
-0.8437924981117249,
-0.2069910168647766,
-1.1090482473373413,
0.635495841503143... |
func MakeMaster(files []string, nReduce int) *Master {
m := Master{}
m.files = files
m.record = map[string]*record{}
m.tasks = map[int][]*record{}
m.reduceTasks = map[int]*record{}
m.nReduce = nReduce
m.phase = TaskMapType
// Your code here.
m.server()
return &m
} | [
-0.5674536824226379,
-0.45161598920822144,
0.6965057253837585,
0.26368772983551025,
-0.8869243264198303,
0.0973563864827156,
0.339255690574646,
0.36705100536346436,
-0.011698044836521149,
-0.6543678045272827,
-0.7031461596488953,
-0.3873254954814911,
-0.6938121914863586,
0.0837956666946411... |
func isBright() bool {
now := time.Now()
if now.After(sunriseTime) && now.Before(sunsetTime) {
return true
}
return false
} | [
0.131499245762825,
-0.6442182064056396,
0.830406129360199,
1.3301310539245605,
-0.8883586525917053,
0.3209996521472931,
-1.05393648147583,
-0.4701651334762573,
-0.14246876537799835,
-1.0295013189315796,
-0.7558716535568237,
1.225239634513855,
-0.48646217584609985,
1.5929970741271973,
-0.... |
func (idx *IndexBuf)quickSort(s, t int) {
if t < 0 {return}
m := idx.split(s, t)
for s > t {
idx.quickSort(s, m-1)
idx.quickSort(m+1, t)
}
} | [
0.008218635804951191,
0.2190590351819992,
0.09709841758012772,
-0.6313305497169495,
0.08313339203596115,
-0.5309032797813416,
0.2610459327697754,
-0.6115395426750183,
-0.27566152811050415,
-0.9741345643997192,
-1.0726511478424072,
0.14866091310977936,
-0.4754708707332611,
-1.07277727127075... |
func (idx *IndexBuf)split(s, t int) int {
var i, j int
for i, j = s, s; i < t; i++ {
if idx.less(i, t) {
idx.swap(i, j)
j++
}
}
idx.swap(j, t)
return j
} | [
-0.9723411202430725,
-0.07802088558673859,
0.224988654255867,
-0.46152859926223755,
-0.7647473216056824,
-0.9233079552650452,
0.6520358920097351,
-0.34227225184440613,
-0.29251569509506226,
-0.1050666943192482,
-0.9840164184570312,
0.7390708923339844,
-0.6817188858985901,
-1.65339040756225... |
func GetAwsSession(cfg config.ServerConfig) (*session.Session, error) {
var providers []credentials.Provider
customResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
if service == endpoints.RdsServiceID && cfg.AwsEndpointRdsURL != "" {
return endpo... | [
-0.7660092115402222,
0.008138571865856647,
0.7384714484214783,
-0.8376331329345703,
-0.13518308103084564,
-0.13901236653327942,
-0.47629207372665405,
-0.6662711501121521,
0.8021709322929382,
0.4049109220504761,
-0.28806963562965393,
0.6456999182701111,
-0.1654052883386612,
0.25800502300262... |
func NewAuthorizer(ctx *pulumi.Context,
name string, args *AuthorizerArgs, opts ...pulumi.ResourceOpt) (*Authorizer, error) {
if args == nil || args.RestApi == nil {
return nil, errors.New("missing required argument 'RestApi'")
}
inputs := make(map[string]interface{})
if args == nil {
inputs["authorizerCredent... | [
-0.3993353843688965,
-0.12111996114253998,
0.5463095307350159,
-0.24368341267108917,
-0.6520457863807678,
0.04453127086162567,
-0.23774565756320953,
0.3370245099067688,
0.40794649720191956,
0.10468650609254837,
-0.5194653868675232,
0.4889775216579437,
-0.4204021692276001,
0.499599635601043... |
func GetAuthorizer(ctx *pulumi.Context,
name string, id pulumi.ID, state *AuthorizerState, opts ...pulumi.ResourceOpt) (*Authorizer, error) {
inputs := make(map[string]interface{})
if state != nil {
inputs["authorizerCredentials"] = state.AuthorizerCredentials
inputs["authorizerResultTtlInSeconds"] = state.Autho... | [
-0.20278947055339813,
-0.24503766000270844,
0.31145983934402466,
-0.17156949639320374,
-0.642169177532196,
-0.41873788833618164,
-0.5642180442810059,
0.10896966606378555,
0.8644499182701111,
-0.3594408631324768,
0.045786816626787186,
1.1657437086105347,
0.11508996039628983,
-0.484532803297... |
func (r *Authorizer) URN() pulumi.URNOutput {
return r.s.URN()
} | [
0.5915296077728271,
-0.03490220755338669,
0.28982511162757874,
0.8739734292030334,
0.05603164806962013,
-0.24138504266738892,
0.7358342409133911,
2.031604528427124,
0.5459631085395813,
-1.0958504676818848,
-0.22446613013744354,
1.3361668586730957,
0.8109923005104065,
-1.1014678478240967,
... |
func (r *Authorizer) ID() pulumi.IDOutput {
return r.s.ID()
} | [
1.4004552364349365,
0.20381778478622437,
0.2365017682313919,
0.7443278431892395,
-0.1009213998913765,
0.31017935276031494,
0.35958293080329895,
0.7850816249847412,
1.2247358560562134,
-0.07443978637456894,
0.5645331740379333,
0.6797849535942078,
0.08161398768424988,
-0.6317607760429382,
... |
func (r *Authorizer) AuthorizerCredentials() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["authorizerCredentials"])
} | [
0.13922281563282013,
-0.31562498211860657,
0.350396066904068,
0.33783742785453796,
-0.15371255576610565,
0.6404007077217102,
0.011119880713522434,
1.502679467201233,
0.36765605211257935,
-0.04943525046110153,
0.048183560371398926,
0.7024040222167969,
0.5394195914268494,
-1.066864252090454,... |
func (r *Authorizer) AuthorizerResultTtlInSeconds() pulumi.IntOutput {
return (pulumi.IntOutput)(r.s.State["authorizerResultTtlInSeconds"])
} | [
0.966248095035553,
0.406503289937973,
0.3320502042770386,
-0.3310057520866394,
-0.06889861077070236,
-0.11494658142328262,
-0.10008154064416885,
-0.4433286190032959,
0.1960384100675583,
0.1583472490310669,
-0.40991315245628357,
0.2454126924276352,
0.8592826724052429,
-1.1607160568237305,
... |
func (r *Authorizer) IdentitySource() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["identitySource"])
} | [
0.2110012173652649,
0.36553215980529785,
0.45212122797966003,
0.10063827037811279,
-0.045381106436252594,
0.11694154143333435,
0.332288920879364,
1.1769437789916992,
1.2700952291488647,
0.16778849065303802,
-0.22448408603668213,
0.9666178226470947,
0.20481932163238525,
-1.440129280090332,
... |
func (r *Authorizer) IdentityValidationExpression() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["identityValidationExpression"])
} | [
0.3228475749492645,
-0.28645169734954834,
0.45781880617141724,
0.561335027217865,
0.00901817623525858,
0.7907528877258301,
0.41078731417655945,
1.0049834251403809,
0.9524657130241394,
0.37792351841926575,
0.26365968585014343,
1.6218498945236206,
-0.0678592249751091,
-0.8999194502830505,
... |
func (r *Authorizer) Name() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["name"])
} | [
0.10205186158418655,
0.040978915989398956,
0.5093485713005066,
-0.18111786246299744,
-1.245304822921753,
0.12462637573480606,
-0.20223282277584076,
0.5988764762878418,
0.3395521342754364,
1.0464684963226318,
0.1646379679441452,
0.6401857137680054,
0.8642768859863281,
-0.7172247767448425,
... |
func (r *Authorizer) RestApi() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["restApi"])
} | [
0.8418676257133484,
-0.4940117299556732,
0.40293753147125244,
0.8061074018478394,
-0.5277000069618225,
0.3092717230319977,
-0.06706644594669342,
0.7694818377494812,
0.6436099410057068,
-0.2765376567840576,
0.3818058371543884,
0.8992664813995361,
0.2553327977657318,
-1.6791844367980957,
-... |
func (r *Authorizer) Type() pulumi.StringOutput {
return (pulumi.StringOutput)(r.s.State["type"])
} | [
0.5825288891792297,
0.7426773309707642,
0.30115965008735657,
0.4794248938560486,
0.32587727904319763,
0.3502577841281891,
0.21414165198802948,
0.2207765430212021,
1.0671933889389038,
0.4187201261520386,
0.6068390011787415,
1.214982509613037,
0.08915281295776367,
-1.0173605680465698,
0.81... |
func (c *Client) Search(ctx context.Context, args search.SymbolsParameters) (symbols result.Symbols, err error) {
span, ctx := ot.StartSpanFromContext(ctx, "symbols.Client.Search")
defer func() {
if err != nil {
ext.Error.Set(span, true)
span.LogFields(otlog.Error(err))
}
span.Finish()
}()
span.SetTag("... | [
-0.5078926086425781,
0.8982543349266052,
0.4731878936290741,
-0.3762575685977936,
0.22341834008693695,
0.16705772280693054,
0.8655679821968079,
-0.6131309866905212,
-0.138045534491539,
0.5851346850395203,
-0.05345217138528824,
0.9020535349845886,
-0.6855876445770264,
0.3299042582511902,
... |
func ValidateNetwork(network *extensionsv1alpha1.Network) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&network.ObjectMeta, true, apivalidation.NameIsDNSSubdomain, field.NewPath("metadata"))...)
allErrs = append(allErrs, ValidateNetworkSpec(&network.Spec, ... | [
-1.6057863235473633,
0.5709014534950256,
0.5248079895973206,
0.761046290397644,
0.5886582136154175,
0.30338361859321594,
-0.3221839964389801,
0.18800678849220276,
0.7392719984054565,
-0.4462907612323761,
-1.1859196424484253,
-0.713327944278717,
0.6618629097938538,
0.47374939918518066,
-0... |
func ValidateNetworkUpdate(new, old *extensionsv1alpha1.Network) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&new.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))...)
allErrs = append(allErrs, ValidateNetworkSpecUpdate(&new.Spec, &old.Spec, ... | [
-0.5412901639938354,
-0.7209776043891907,
0.3999899625778198,
0.250291645526886,
-0.21747174859046936,
-0.28720518946647644,
-0.4427330493927002,
-0.3073880076408386,
0.2295207381248474,
0.1704528033733368,
-0.4426288902759552,
-0.8484196066856384,
0.18226219713687897,
0.4321011006832123,
... |
func ValidateNetworkSpec(spec *extensionsv1alpha1.NetworkSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(spec.Type) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("type"), "field is required"))
}
var cidrs []cidrvalidation.CIDR
if len(spec.PodCIDR) == 0 {
allE... | [
-0.11651690304279327,
0.023302212357521057,
0.3882054388523102,
-0.5806124210357666,
0.2667267918586731,
0.341835618019104,
0.5754141211509705,
-0.3844899535179138,
-0.05482952296733856,
0.05278807505965233,
-0.5805447697639465,
-0.5929052829742432,
0.19010204076766968,
0.9225417971611023,... |
func ValidateNetworkSpecUpdate(new, old *extensionsv1alpha1.NetworkSpec, deletionTimestampSet bool, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if deletionTimestampSet && !apiequality.Semantic.DeepEqual(new, old) {
allErrs = append(allErrs, apivalidation.ValidateImmutableField(new, old, fld... | [
-0.14665533602237701,
-0.23749031126499176,
0.5512277483940125,
-0.3029579222202301,
-0.5372359752655029,
0.13225850462913513,
0.025033611804246902,
-0.7418045997619629,
0.009899015538394451,
-0.01398323941975832,
-0.23495931923389435,
-0.7697210907936096,
0.28443393111228943,
0.6164481043... |
func ValidateNetworkStatus(spec *extensionsv1alpha1.NetworkStatus, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
return allErrs
} | [
0.15828461945056915,
0.2722368836402893,
-0.09042728692293167,
-0.46666863560676575,
0.013689672574400902,
0.9363530278205872,
0.01482770312577486,
-0.09766380488872528,
0.15275245904922485,
-0.13870787620544434,
-1.009305477142334,
-1.0096993446350098,
0.7058665156364441,
1.32517647743225... |
func ValidateNetworkStatusUpdate(newStatus, oldStatus extensionsv1alpha1.NetworkStatus) field.ErrorList {
allErrs := field.ErrorList{}
return allErrs
} | [
0.4046396017074585,
-0.40835851430892944,
0.06358660012483597,
0.24587666988372803,
-0.5606613159179688,
0.28033533692359924,
-0.9570544958114624,
0.24378804862499237,
0.3708132207393646,
0.1627320945262909,
-0.4774998128414154,
-1.073596477508545,
0.32933592796325684,
0.8840792179107666,
... |
func (m *Master) Example(args *ExampleArgs, reply *ExampleReply) error {
reply.Y = args.X + 1
return nil
} | [
0.32417795062065125,
0.2859414219856262,
0.43225982785224915,
-0.2891663908958435,
0.11762767285108566,
0.09170500189065933,
-0.01638232357800007,
0.7501857280731201,
0.40489038825035095,
0.20812305808067322,
-1.4481412172317505,
1.1364949941635132,
-0.03300471231341362,
-0.332706898450851... |
func (m *Master) server() {
rpc.Register(m)
rpc.HandleHTTP()
//l, e := net.Listen("tcp", ":1234")
sockname := masterSock()
os.Remove(sockname)
l, e := net.Listen("unix", sockname)
if e != nil {
log.Fatal("listen error:", e)
}
go http.Serve(l, nil)
} | [
-0.5627836585044861,
-0.3185119032859802,
0.6255593299865723,
-0.08582790940999985,
1.1791318655014038,
0.8106944561004639,
-0.047648731619119644,
1.27376389503479,
-0.7720423936843872,
-0.20754043757915497,
-0.914108395576477,
0.10757902264595032,
-1.1161320209503174,
1.0134865045547485,
... |
func (m *Master) mapfinished() bool {
t := time.Now().Unix()
ret := true
j := 0
for j < len(m.mapTasks) {
if m.mapTasks[j].state == 1 {
if t-m.mapTasks[j].emittime >= TIMEOUT {
m.mapTasks[j].state = 0
}
}
j++
}
i := 0
for i < len(m.mapTasks) {
if m.mapTasks[i].state == 0 {
m.nextmaptask = i
... | [
-0.8594930768013,
-0.3117219805717468,
0.8897183537483215,
0.2174745351076126,
-0.9029414057731628,
0.33932262659072876,
-0.5588127374649048,
0.8310990333557129,
-0.13141615688800812,
0.7659115791320801,
-1.3394280672073364,
-0.5202337503433228,
0.2445710003376007,
0.9854540228843689,
-0... |
func (m *Master) haveDone() bool {
ret := true
t := time.Now().Unix()
j := 0
for j < len(m.reduceTasks) {
if m.reduceTasks[j].state == 1 {
if t-m.reduceTasks[j].emittime >= TIMEOUT {
m.reduceTasks[j].state = 0
}
}
j++
}
i := 0
for _, reduceTask := range m.reduceTasks {
if reduceTask.state == 0 ... | [
0.17062342166900635,
0.8947570323944092,
1.1008427143096924,
0.1287265568971634,
0.47380897402763367,
-0.39178532361984253,
0.15105387568473816,
0.9027956128120422,
-0.953641951084137,
0.42502978444099426,
-0.8236382603645325,
-0.7703223824501038,
-0.4269070625305176,
1.2321529388427734,
... |
func (m *Master) Done() bool {
ret := false
m.mu.Lock()
defer m.mu.Unlock()
ret = m.haveDone()
return ret
} | [
-0.45432600378990173,
0.6612924337387085,
0.7723225951194763,
0.7528612613677979,
0.07512103766202927,
0.18317794799804688,
-0.19591212272644043,
0.05366813391447067,
-0.47631439566612244,
-0.19270026683807373,
-0.747424840927124,
-0.4190383851528168,
-1.1209211349487305,
0.544079959392547... |
func MakeMaster(files []string, nReduce int) *Master {
m := Master{}
// Your code here.
//record each file as a task
mapTasks := []MapTask{}
j := 0
for _, filename := range files {
mapTasks = append(mapTasks, MapTask{filename, j, 0, 0})
j++
}
m.mapTasks = mapTasks
m.nextmaptask = 0
//generate nReduce red... | [
-0.4424937963485718,
-0.190932035446167,
0.9438905715942383,
0.141677126288414,
-0.7940154075622559,
-0.1314198076725006,
0.32212474942207336,
0.8103337287902832,
-0.013770276680588722,
-0.3837412893772125,
-0.754507303237915,
-0.5736292004585266,
-0.5434606671333313,
0.1519511491060257,
... |
func TestRejectStaleTermMessage(t *testing.T) {
called := false
fakeStep := func(r *raft, m pb.Message) bool {
called = true
return false
}
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
defer closeAndFreeRaft(r)
r.step = fakeStep
r.loadState(pb.HardState{Term: 2})
r.Step(pb.Message{Type... | [
0.3178415298461914,
1.2410123348236084,
0.4347778856754303,
0.12432861328125,
0.28931576013565063,
0.8507658839225769,
0.016471125185489655,
-0.367974191904068,
-0.885424792766571,
-0.4502365291118622,
-0.7550272345542908,
0.12345802783966064,
-0.8590384125709534,
0.9555094242095947,
-0.... |
func TestStartAsFollower(t *testing.T) {
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
defer closeAndFreeRaft(r)
if r.state != StateFollower {
t.Errorf("state = %s, want %s", r.state, StateFollower)
}
} | [
0.16240818798542023,
0.3455291986465454,
0.4262583553791046,
-0.08407421410083771,
-0.02399531565606594,
0.21801291406154633,
0.6769264340400696,
-0.9763283729553223,
0.9089011549949646,
-0.23449522256851196,
-0.7253001928329468,
0.6398939490318298,
0.1641431450843811,
0.7705768346786499,
... |
func TestLeaderBcastBeat(t *testing.T) {
// heartbeat interval
hi := 1
r := newTestRaft(1, []uint64{1, 2, 3}, 10, hi, NewMemoryStorage())
defer closeAndFreeRaft(r)
r.becomeCandidate()
r.becomeLeader()
for i := 0; i < 10; i++ {
r.appendEntry(pb.Entry{Index: uint64(i) + 1})
}
for i := 0; i < hi; i++ {
r.tic... | [
0.33821901679039,
0.7489688396453857,
0.985704779624939,
0.28307369351387024,
0.5223685503005981,
1.216240406036377,
0.6284491419792175,
-0.780792772769928,
-0.6074106693267822,
0.053873222321271896,
-0.14682352542877197,
0.8627727031707764,
-1.4441168308258057,
0.889453649520874,
0.0962... |
func testNonleaderStartElection(t *testing.T, state StateType) {
// election timeout
et := 10
r := newTestRaft(1, []uint64{1, 2, 3}, et, 1, NewMemoryStorage())
defer closeAndFreeRaft(r)
switch state {
case StateFollower:
r.becomeFollower(1, 2)
case StateCandidate:
r.becomeCandidate()
}
for i := 1; i < 2*e... | [
-0.5082271099090576,
-0.01834660768508911,
0.5385188460350037,
-0.25425204634666443,
-0.05186400189995766,
0.31441348791122437,
0.640256404876709,
-0.9245008826255798,
0.15202875435352325,
0.2974170446395874,
-0.19274123013019562,
0.5500136613845825,
-0.9470686316490173,
0.6777465343475342... |
func TestLeaderElectionInOneRoundRPC(t *testing.T) {
tests := []struct {
size int
votes map[uint64]bool
state StateType
}{
// win the election when receiving votes from a majority of the servers
{1, map[uint64]bool{}, StateLeader},
{3, map[uint64]bool{2: true, 3: true}, StateLeader},
{3, map[uint64]boo... | [
-0.02200470119714737,
-0.0035302345640957355,
0.8239373564720154,
-0.7128692865371704,
0.6015269160270691,
0.5779194831848145,
0.5361200571060181,
-0.7468307614326477,
0.017033835873007774,
0.19879478216171265,
-0.33242613077163696,
0.1940748542547226,
-1.2309479713439941,
0.71986985206604... |
func TestFollowerVote(t *testing.T) {
tests := []struct {
vote uint64
nvote uint64
wreject bool
}{
{None, 1, false},
{None, 2, false},
{1, 1, false},
{2, 2, false},
{1, 2, true},
{2, 1, true},
}
for i, tt := range tests {
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
d... | [
-0.10689608752727509,
0.6601453423500061,
0.7551221251487732,
-0.008966328576207161,
0.22018621861934662,
0.2719253599643707,
0.6282604932785034,
-0.711367130279541,
-0.289007306098938,
0.07538695633411407,
-0.0739225447177887,
0.48364099860191345,
-1.2578721046447754,
0.45336082577705383,... |
func TestCandidateFallback(t *testing.T) {
tests := []pb.Message{
{From: 2, To: 1, Term: 1, Type: pb.MsgApp},
{From: 2, To: 1, Term: 2, Type: pb.MsgApp},
}
for i, tt := range tests {
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
defer closeAndFreeRaft(r)
r.Step(pb.Message{From: 1, To: 1... | [
0.20173119008541107,
-0.207561656832695,
0.5476375222206116,
0.2284432202577591,
0.12924346327781677,
0.5909712910652161,
0.20095348358154297,
-0.16758081316947937,
-0.07939572632312775,
-0.0940774455666542,
-0.26407790184020996,
0.7593317627906799,
-0.14866861701011658,
0.8360496163368225... |
func testNonleaderElectionTimeoutRandomized(t *testing.T, state StateType) {
et := 10
r := newTestRaft(1, []uint64{1, 2, 3}, et, 1, NewMemoryStorage())
defer closeAndFreeRaft(r)
timeouts := make(map[int]bool)
for round := 0; round < 50*et; round++ {
switch state {
case StateFollower:
r.becomeFollower(r.Term... | [
-0.48795267939567566,
0.49595779180526733,
0.4610140323638916,
-0.42719897627830505,
0.23326674103736877,
0.5517210960388184,
0.8676289916038513,
-0.6885557770729065,
0.8095470666885376,
0.7718329429626465,
-0.434733122587204,
-0.16914665699005127,
-0.5334338545799255,
0.9633022546768188,
... |
func testNonleadersElectionTimeoutNonconflict(t *testing.T, state StateType) {
et := 10
size := 5
rs := make([]*raft, size)
ids := idsBySize(size)
for k := range rs {
rs[k] = newTestRaft(ids[k], ids, et, 1, NewMemoryStorage())
}
defer func() {
for k := range rs {
closeAndFreeRaft(rs[k])
}
}()
conflict... | [
-0.17594608664512634,
1.042401671409607,
0.8545030951499939,
0.09606809914112091,
0.590430498123169,
-0.02953520603477955,
1.3164149522781372,
-0.45217615365982056,
0.4633627235889435,
0.35434481501579285,
-0.20187467336654663,
-0.7768803238868713,
-0.9782983064651489,
0.3080410063266754,
... |
func TestLeaderStartReplication(t *testing.T) {
s := NewMemoryStorage()
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, s)
defer closeAndFreeRaft(r)
r.becomeCandidate()
r.becomeLeader()
commitNoopEntry(r, s)
li := r.raftLog.lastIndex()
ents := []pb.Entry{{Data: []byte("some data")}}
r.Step(pb.Message{From: 1, T... | [
-0.1882607638835907,
0.695610523223877,
0.8198297619819641,
-0.3487388789653778,
0.23017969727516174,
0.2630622684955597,
1.2457588911056519,
-0.06431646645069122,
-0.11464707553386688,
-0.06844674050807953,
-0.3875291347503662,
0.9152448177337646,
-1.1110560894012451,
-0.14144136011600494... |
func TestLeaderCommitEntry(t *testing.T) {
s := NewMemoryStorage()
r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, s)
defer closeAndFreeRaft(r)
r.becomeCandidate()
r.becomeLeader()
commitNoopEntry(r, s)
li := r.raftLog.lastIndex()
r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []by... | [
0.23001107573509216,
-0.15972283482551575,
0.6805508732795715,
-0.2897116541862488,
0.23719428479671478,
0.4638867974281311,
0.5002931952476501,
-0.6528396010398865,
0.1573280245065689,
0.2095457762479782,
0.05005943402647972,
0.6486149430274963,
-0.9955289363861084,
0.29138603806495667,
... |
func TestLeaderAcknowledgeCommit(t *testing.T) {
tests := []struct {
size int
acceptors map[uint64]bool
wack bool
}{
{1, nil, true},
{3, nil, false},
{3, map[uint64]bool{2: true}, true},
{3, map[uint64]bool{2: true, 3: true}, true},
{5, nil, false},
{5, map[uint64]bool{2: true}, false},
... | [
0.44420894980430603,
0.5280999541282654,
0.9337527751922607,
-0.8140578866004944,
0.18492332100868225,
-0.03825557976961136,
0.801893949508667,
-0.4499722421169281,
-0.1035616472363472,
0.6972355842590332,
-0.21758881211280823,
0.28810620307922363,
-0.7945547699928284,
0.7058237195014954,
... |
func TestFollowerCommitEntry(t *testing.T) {
tests := []struct {
ents []pb.Entry
commit uint64
}{
{
[]pb.Entry{
{Term: 1, Index: 1, Data: []byte("some data")},
},
1,
},
{
[]pb.Entry{
{Term: 1, Index: 1, Data: []byte("some data")},
{Term: 1, Index: 2, Data: []byte("some data2")},
... | [
0.4533421993255615,
0.35424113273620605,
0.8007185459136963,
-0.3061085641384125,
-0.1077350378036499,
0.5332499146461487,
0.6181890964508057,
-0.762707531452179,
-0.4281143248081207,
0.2473287582397461,
-0.3821779489517212,
0.6363742351531982,
-0.6438649892807007,
0.6623479723930359,
0.... |
func TestFollowerCheckMsgApp(t *testing.T) {
ents := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}}
tests := []struct {
term uint64
index uint64
windex uint64
wreject bool
wrejectHint uint64
}{
// match with committed entries
{0, 0, 1, false, 0},
{ents[0].Term, ents[0].Ind... | [
0.5101289749145508,
0.02776203490793705,
0.9686916470527649,
-0.1896180361509323,
-0.11957400292158127,
0.38223379850387573,
0.9512192606925964,
-0.38196858763694763,
-0.5345704555511475,
0.35894718766212463,
0.06691106408834457,
0.5620635747909546,
-0.47347140312194824,
0.5874961018562317... |
func TestFollowerAppendEntries(t *testing.T) {
tests := []struct {
index, term uint64
ents []pb.Entry
wents []pb.Entry
wunstable []pb.Entry
}{
{
2, 2,
[]pb.Entry{{Term: 3, Index: 3}},
[]pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}, {Term: 3, Index: 3}},
[]pb.Entry{{Term: 3, I... | [
0.6515659093856812,
-0.020597141236066818,
0.9930489659309387,
-0.163655623793602,
-0.43709030747413635,
0.13094130158424377,
0.5887036919593811,
-0.4140232801437378,
-0.05420587211847305,
0.07416068017482758,
-0.36563506722450256,
0.4777820408344269,
-0.08477038890123367,
1.20225954055786... |
func TestLeaderSyncFollowerLog(t *testing.T) {
ents := []pb.Entry{
{},
{Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
{Term: 4, Index: 4}, {Term: 4, Index: 5},
{Term: 5, Index: 6}, {Term: 5, Index: 7},
{Term: 6, Index: 8}, {Term: 6, Index: 9}, {Term: 6, Index: 10},
}
term := uint64(8)
test... | [
0.5478450059890747,
-0.01897771842777729,
0.9413824677467346,
-0.4141157269477844,
0.08307875692844391,
-0.7476410865783691,
1.1861505508422852,
-0.8933299779891968,
0.5972785353660583,
-0.1195734366774559,
-0.7468146085739136,
0.03353900462388992,
0.6818905472755432,
-0.3126860558986664,
... |
func TestVoter(t *testing.T) {
tests := []struct {
ents []pb.Entry
logterm uint64
index uint64
wreject bool
}{
// same logterm
{[]pb.Entry{{Term: 1, Index: 1}}, 1, 1, false},
{[]pb.Entry{{Term: 1, Index: 1}}, 1, 2, false},
{[]pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}}, 1, 1, true},
// ... | [
-0.2516510784626007,
-0.12034327536821365,
0.789216935634613,
0.0722547322511673,
0.1815970093011856,
0.21668441593647003,
0.21428292989730835,
-0.5818517208099365,
-0.4997204542160034,
0.3576994836330414,
-0.6437985897064209,
0.22070945799350739,
-0.673047661781311,
0.14687347412109375,
... |
func (m *Message) Free() {
var ch chan *Message
if v := atomic.AddInt32(&m.refcnt, -1); v > 0 {
return
}
for i := range messageCache {
if m.bsize == messageCache[i].maxbody {
ch = messageCache[i].cache
break
}
}
m.Port = nil
select {
case ch <- m:
default:
}
} | [
0.11051709949970245,
1.0166903734207153,
0.6544592380523682,
-0.29966920614242554,
0.043080467730760574,
-0.3263888955116272,
0.7728049159049988,
-1.5718920230865479,
-0.24194277822971344,
-0.4899778962135315,
0.400470495223999,
0.7404816150665283,
-1.7067574262619019,
0.9881595373153687,
... |
func (m *Message) Dup() *Message {
atomic.AddInt32(&m.refcnt, 1)
return m
} | [
0.3375592827796936,
0.6660131812095642,
0.4667125344276428,
-0.7276917695999146,
0.6923261880874634,
0.5032777190208435,
1.3995180130004883,
-1.1804869174957275,
-0.3216365575790405,
-0.33029043674468994,
0.13934868574142456,
0.8532530069351196,
-0.9922460317611694,
0.40784284472465515,
... |
func (m *Message) Expired() bool {
if m.expire.IsZero() {
return false
}
if m.expire.After(time.Now()) {
return false
}
return true
} | [
-0.010545007884502411,
-0.50409996509552,
0.5686928033828735,
0.20373106002807617,
0.2767428755760193,
-0.29335176944732666,
-1.264693260192871,
0.16275407373905182,
-0.36687180399894714,
-0.12743595242500305,
0.043919265270233154,
0.3091293275356293,
-0.9664869904518127,
1.556058168411254... |
func NewMessage(sz int) *Message {
var m *Message
var ch chan *Message
for i := range messageCache {
if sz < messageCache[i].maxbody {
ch = messageCache[i].cache
sz = messageCache[i].maxbody
break
}
}
select {
case m = <-ch:
default:
m = &Message{}
m.bbuf = make([]byte, 0, sz)
m.hbuf = make([]... | [
-0.23714633285999298,
0.25588762760162354,
0.559860110282898,
0.3503831624984741,
-0.5705367922782898,
-0.10645968466997147,
0.21495483815670013,
-0.9318565130233765,
0.8567280173301697,
-0.42839768528938293,
-0.37004053592681885,
0.13061606884002686,
-1.2510159015655518,
1.016180753707885... |
func main() {
k := 3
arr := []int{4,5,8,2}
obj := Constructor(k, arr)
fmt.Println(obj.Add(3))
fmt.Println(obj.Add(5))
fmt.Println(obj.Add(10))
fmt.Println(obj.Add(9))
fmt.Println(obj.Add(4))
} | [
0.18008746206760406,
-0.4839852750301361,
1.0756257772445679,
0.7014939188957214,
-0.7690988183021545,
0.5921693444252014,
0.4955277442932129,
0.27762994170188904,
0.23667651414871216,
0.053638849407434464,
-0.4893701374530792,
-0.1769740879535675,
0.5393016338348389,
0.16239498555660248,
... |
func AddGigasecond(t time.Time) time.Time {
gigasecond := time.Duration(1000000000) * time.Second
return t.Add(gigasecond)
} | [
0.3628453016281128,
0.4431242346763611,
0.4590785801410675,
0.07284978032112122,
-0.43347060680389404,
0.2922897934913635,
-1.130871057510376,
-0.6022825837135315,
-0.5990070104598999,
0.709810733795166,
-0.7325277924537659,
-0.4712682068347931,
-0.2731194794178009,
1.2317614555358887,
-... |
func (d *DNS) Initialize(credentials string, log logger.Interface) error {
var err error
ctx := context.Background()
d.log = log
d.PendingWaitSeconds = 5
d.Calls = &Calls{
ChangesCreate: &calls.ChangesCreateCall{},
ResourceRecordSetsList: &calls.ResourceRecordSetsListCall{},
}
if credentials != "" {... | [
-0.7802048921585083,
1.6887460947036743,
0.6396166086196899,
0.1669711470603943,
0.3344840705394745,
-0.21766218543052673,
-0.4512755274772644,
-0.8672018051147461,
0.6001210808753967,
-0.0131364855915308,
-0.19482183456420898,
0.9508481025695801,
-0.40640148520469666,
0.8853030800819397,
... |
func (d *DNS) GetResourceRecordSets(projectID string, managedZone string) ([]*v1.ResourceRecordSet, error) {
ctx := context.Background()
rrsService := v1.NewResourceRecordSetsService(d.V1)
rrsListCall := rrsService.List(projectID, managedZone).Context(ctx)
rrsList, err := d.Calls.ResourceRecordSetsList.Do(rrsListCa... | [
-0.0246660728007555,
0.8752577900886536,
0.20469462871551514,
-0.1836184859275818,
-0.08608266711235046,
0.12500552833080292,
-0.2144717574119568,
-0.6162337064743042,
0.35819458961486816,
0.10370149463415146,
0.21911516785621643,
0.9176515340805054,
-1.0943853855133057,
0.4385980367660522... |
func (d *DNS) GetResourceRecordSet(projectID string, managedZone string, name string) (*v1.ResourceRecordSet, error) {
ctx := context.Background()
rrsService := v1.NewResourceRecordSetsService(d.V1)
rrsListCall := rrsService.List(projectID, managedZone).Context(ctx).Name(name)
rrsList, err := d.Calls.ResourceRecord... | [
0.389873206615448,
0.45738086104393005,
0.4485257565975189,
-0.641139030456543,
-0.30291593074798584,
-0.13159380853176117,
-0.21562710404396057,
-0.7996249198913574,
0.05363142862915993,
-0.01779758185148239,
0.49671635031700134,
0.7355816960334778,
-1.2338314056396484,
0.233863964676857,... |
func (d *DNS) SetResourceRecordSets(projectID string, managedZone string, records []*v1.ResourceRecordSet) error {
var deletions []*v1.ResourceRecordSet
var additions []*v1.ResourceRecordSet
var change *v1.Change
logItems := []string{}
for _, record := range records {
existing, err := d.GetResourceRecordSet(proj... | [
-0.21304425597190857,
0.15552665293216705,
0.4289497137069702,
-0.5889847278594971,
0.15509802103042603,
-0.003921078983694315,
0.1923649162054062,
-0.6791403889656067,
0.556194007396698,
0.031017804518342018,
0.05299621820449829,
0.33569014072418213,
-0.3918392062187195,
0.582570493221283... |
func (d *DNS) DeleteResourceRecordSets(projectID string, managedZone string) error {
var deletions []*v1.ResourceRecordSet
resourceRecordSets, err := d.GetResourceRecordSets(projectID, managedZone)
if err != nil {
return err
}
d.log.Info("Deleting all records from DNS zone %s:", managedZone)
for _, resourceReco... | [
0.34888187050819397,
0.1449168175458908,
0.2612670660018921,
-0.2128293365240097,
-0.4660528004169464,
0.02951742522418499,
0.42949178814888,
-0.5778874158859253,
0.8795406818389893,
-0.11991167068481445,
0.6120230555534363,
0.48879244923591614,
-0.09117855131626129,
0.8207772970199585,
... |
func (a *ChildrenAggregation) Meta(metaData map[string]interface{}) *ChildrenAggregation {
a.meta = metaData
return a
} | [
0.3073802888393402,
0.16460849344730377,
0.5375185608863831,
0.118108369410038,
0.3517010509967804,
0.5246464610099792,
0.1046314537525177,
0.5016064047813416,
-0.8857781887054443,
-0.31179192662239075,
0.5423710942268372,
-0.18766872584819794,
0.9824123978614807,
-0.10271012783050537,
-... |
func NewCreateSubCategoryCreated() *CreateSubCategoryCreated {
return &CreateSubCategoryCreated{}
} | [
1.0514942407608032,
0.35174527764320374,
0.2578261196613312,
1.1813935041427612,
-0.06681818515062332,
0.23366086184978485,
1.1037217378616333,
-0.0887666791677475,
-0.683251142501831,
-0.8338433504104614,
-1.0284990072250366,
-0.40588638186454773,
0.25034406781196594,
0.672514021396637,
... |
func (o *CreateSubCategoryCreated) WithPayload(payload *models.SubCategory) *CreateSubCategoryCreated {
o.Payload = payload
return o
} | [
1.101525068283081,
0.6460650563240051,
-0.06353341042995453,
0.3256365656852722,
-0.43795254826545715,
0.46920159459114075,
0.1175646185874939,
-0.5283100008964539,
0.017750157043337822,
-1.5450538396835327,
-0.5738450288772583,
-0.6750068068504333,
0.8161989450454712,
0.24188171327114105,... |
func (o *CreateSubCategoryCreated) SetPayload(payload *models.SubCategory) {
o.Payload = payload
} | [
0.6673187017440796,
0.7143928408622742,
-0.10514354705810547,
0.25029975175857544,
-0.1706802248954773,
0.8542497158050537,
0.03846268355846405,
-0.2680976688861847,
-0.6099211573600769,
-1.26211678981781,
-1.1580461263656616,
-0.126805379986763,
0.33042770624160767,
0.6931554675102234,
... |
func (o *CreateSubCategoryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(201)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
} | [
0.020579222589731216,
0.6011106371879578,
0.1568194478750229,
0.9350037574768066,
0.48293647170066833,
-0.03564368933439255,
0.5368155241012573,
-0.19826513528823853,
-0.024792451411485672,
-0.35852766036987305,
-0.6450751423835754,
-0.12215839326381683,
0.31374591588974,
0.221696779131889... |
func NewCreateSubCategoryBadRequest() *CreateSubCategoryBadRequest {
return &CreateSubCategoryBadRequest{}
} | [
0.11160260438919067,
0.1989830583333969,
0.5797269940376282,
1.3138906955718994,
-0.41557347774505615,
0.08035283535718918,
-0.5478805899620056,
0.10984406620264053,
-1.0966421365737915,
-0.9018000364303589,
-0.49957308173179626,
1.1534347534179688,
-0.21656367182731628,
1.0172092914581299... |
func (o *CreateSubCategoryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(400)
} | [
-0.5450519323348999,
-0.12946665287017822,
0.2609425485134125,
0.7420263886451721,
0.960333526134491,
0.15135613083839417,
-0.07824079692363739,
-0.5488060712814331,
-0.5787433981895447,
-0.6256679892539978,
-0.645946741104126,
0.6203539371490479,
-0.5045567750930786,
0.6344149112701416,
... |
func New() helmify.Processor {
return &secret{}
} | [
0.5978236794471741,
-0.6497834324836731,
0.11703894287347794,
0.0055520012974739075,
-0.6099672317504883,
-0.43848779797554016,
-0.44878488779067993,
-0.39469611644744873,
-0.6465086936950684,
-0.06814400851726532,
-0.9851735830307007,
0.7896126508712769,
0.39335155487060547,
0.67531740665... |
func (d secret) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != configMapGVC {
return false, nil, nil
}
sec := corev1.Secret{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &sec)
if err != nil {
retur... | [
0.004099518992006779,
-0.1982901692390442,
1.0607677698135376,
-0.2635546028614044,
-0.5822848081588745,
-0.03172630816698074,
-0.8197301030158997,
-0.2230360358953476,
-0.06734880805015564,
0.9079028964042664,
-0.7455407381057739,
-0.001414931146427989,
0.4076128900051117,
0.8512340784072... |
func (_m *ConstraintReferenceService) Create(ctx context.Context, in *model.FormationTemplateConstraintReference) error {
ret := _m.Called(ctx, in)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *model.FormationTemplateConstraintReference) error); ok {
r0 = rf(ctx, in)
} else {
r0 = ret.Error(0)
... | [
-0.7260231375694275,
-0.3793070912361145,
0.37361621856689453,
0.27577662467956543,
0.17956258356571198,
0.7020334005355835,
0.13896168768405914,
0.05598226562142372,
-0.39020806550979614,
-0.3751492202281952,
-0.16150014102458954,
-0.5864185690879822,
-0.4357634484767914,
-0.0576820597052... |
func (_m *ConstraintReferenceService) Delete(ctx context.Context, constraintID string, formationTemplateID string) error {
ret := _m.Called(ctx, constraintID, formationTemplateID)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, constraintID, formationTemplateI... | [
-0.5191177725791931,
-0.6811450123786926,
0.597991406917572,
0.5811116099357605,
0.23610925674438477,
0.20055453479290009,
0.9255478382110596,
0.7159325480461121,
0.02774587832391262,
-0.06610044836997986,
-0.12336514890193939,
-0.9019648432731628,
-0.43480184674263,
0.2568328082561493,
... |
func NewConstraintReferenceService(t mockConstructorTestingTNewConstraintReferenceService) *ConstraintReferenceService {
mock := &ConstraintReferenceService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
} | [
-0.5956728458404541,
-0.9373450875282288,
0.04737186059355736,
-0.4966174364089966,
0.42360547184944153,
0.14677003026008606,
0.5945718288421631,
-0.5386984944343567,
0.05971391126513481,
0.11120324581861496,
0.28746044635772705,
-0.023337697610259056,
-1.0538936853408813,
0.04091747477650... |
func control_data_type_details(w http.ResponseWriter, r *http.Request) {
//ADMIN
checkAdmin(w,r)
//PARAMETERS
itemID := strings.Split(r.RequestURI,"/")
//fmt.Fprintln(w,itemID[5])
//CONTEXT
c := appengine.NewContext(r)
//DECODE KEY
key,err := datastore.DecodeKey(itemID[5])
//KEY ERR
if err... | [
-0.2541748881340027,
0.6479727029800415,
0.9973929524421692,
-0.7412340641021729,
0.329184353351593,
-0.3698093891143799,
0.1253039389848709,
0.08507820963859558,
-0.1583746075630188,
0.18995080888271332,
-0.9800218939781189,
0.1790742129087448,
-0.1298326700925827,
0.514351487159729,
1.... |
func control_data_type(w http.ResponseWriter, r *http.Request) {
//ADMIN
checkAdmin(w,r)
//CONTEXT
c := appengine.NewContext(r)
/*******************************GET LIST/ADD**************************/
if r.Method == "GET"{
//DATA
data := map[string]string{
"get":"true",
"title"... | [
-0.5045287013053894,
0.17673425376415253,
1.0451734066009521,
-0.12815052270889282,
-0.08687121421098709,
-0.11550359427928925,
-0.34559670090675354,
-0.648443877696991,
0.14143967628479004,
0.397672176361084,
-0.9555040597915649,
0.30933767557144165,
-0.10658232867717743,
0.53958612680435... |
func idDistance(a, b id.ID, max id.ID) id.ID {
// Wrap distance will always be smaller when a > b so
// swap the two if that doesn't hold.
if id.Compare(a, b) < 0 {
return idDistance(b, a, max)
}
var (
one = id.ID{Low: 1}
directDist = absSub(b, a)
maxDist = idSub(max, a)
)
// Don't wrap around if b... | [
-0.316214382648468,
-0.6126827001571655,
0.42265161871910095,
-0.0001223384024342522,
-0.5853285789489746,
0.8362104296684265,
0.07858705520629883,
-0.3052491843700409,
0.9315189719200134,
-0.14714615046977997,
0.26348504424095154,
0.9078012704849243,
-0.08653753995895386,
-0.6814597845077... |
func absSub(a, b id.ID) id.ID {
cmp := id.Compare(a, b)
switch {
case cmp < 0: // a < b
return idSub(b, a)
case cmp == 0: // a == b
return id.Zero
case cmp > 0: // a > b
return idSub(a, b)
default:
panic("impossible case")
}
} | [
0.15163375437259674,
-0.4199637472629547,
0.6627184748649597,
0.5663347840309143,
-0.45281320810317993,
0.4401071071624756,
-1.0051567554473877,
-0.49137672781944275,
-0.3535102605819702,
-0.3336440324783325,
0.9585208892822266,
0.8141679763793945,
0.3606716990470886,
-0.47784414887428284,... |
func addOverflows(v, o, max id.ID) bool {
// o overflows when (max - v) < o
maxDist := idSub(max, v)
return id.Compare(maxDist, o) < 0
} | [
0.04039653390645981,
0.010669566690921783,
0.5024818181991577,
0.1821919083595276,
-0.4192425012588501,
0.36746370792388916,
-0.09905179589986801,
-0.6601421236991882,
0.9819411635398865,
-0.3841136395931244,
-0.16987667977809906,
-0.2778945565223694,
-0.03718232363462448,
-0.6089392304420... |
func idSub(v, o id.ID) id.ID {
low, borrow := bits.Sub64(v.Low, o.Low, 0)
high, borrow := bits.Sub64(v.High, o.High, borrow)
return id.ID{High: high, Low: low}
} | [
0.09765506535768509,
-0.23929359018802643,
0.5364776253700256,
-0.1600928157567978,
-0.6863519549369812,
0.5222554802894592,
-0.2424059510231018,
-0.3825356662273407,
0.4877021610736847,
-0.42857229709625244,
-0.7640377283096313,
1.0977674722671509,
-0.15550276637077332,
-1.290592789649963... |
func idAdd(v, o id.ID) id.ID {
low, borrow := bits.Add64(v.Low, o.Low, 0)
high, _ := bits.Add64(v.High, o.High, borrow)
return id.ID{High: high, Low: low}
} | [
0.10239390283823013,
-0.7789043188095093,
0.44690051674842834,
-0.7083266377449036,
-0.17315761744976044,
0.9850814938545227,
-0.00699459807947278,
-0.6996949315071106,
1.0552759170532227,
0.04697959125041962,
-0.07355104386806488,
1.8823481798171997,
-0.26428255438804626,
-0.2204392403364... |
func setRawMode(fd int) (*raw.Termios, error) {
// make sure this is a tty
if !isatty.IsTerminal(uintptr(fd)) {
return nil, fmt.Errorf("fd %d is not a tty", fd)
}
// get the terminal IO mode
originalMode, err := raw.TcGetAttr(uintptr(fd))
if err != nil {
return nil, err
}
// modify the original mode
newMod... | [
-0.65744948387146,
-0.03262295201420784,
0.7670023441314697,
-1.099849820137024,
-1.1061869859695435,
-0.21728256344795227,
-0.07108376920223236,
-0.19687846302986145,
0.11658397316932678,
-0.31837812066078186,
-0.2586430311203003,
-0.39078378677368164,
0.8268036842346191,
0.27825170755386... |
func restoreMode(fd int, mode *raw.Termios) error {
return raw.TcSetAttr(uintptr(fd), mode)
} | [
0.4656478762626648,
-0.023771658539772034,
0.3681964576244354,
-1.229176640510559,
-0.3232592046260834,
-0.03722440451383591,
-0.245517298579216,
0.18062813580036163,
-0.44264230132102966,
-0.29469043016433716,
0.3261050879955292,
-0.42467057704925537,
0.47721579670906067,
-0.5189455747604... |
func (u *utf8) add(c byte) (r rune, size int) {
switch u.state {
case getByte0:
if c&0x80 == 0 {
// 1 byte
return rune(c), 1
} else if c&0xe0 == 0xc0 {
// 2 byte
u.val = int32(c&0x1f) << 6
u.count = 2
u.state = get1More
return KeycodeNull, 0
} else if c&0xf0 == 0xe0 {
// 3 bytes
u.val... | [
-0.2336595505475998,
-0.3854386508464813,
1.001405954360962,
-0.5376874208450317,
-0.3973308801651001,
-0.5326094031333923,
0.6432832479476929,
0.10897093266248703,
0.5232328176498413,
0.037054236978292465,
-0.46771350502967834,
0.8126296997070312,
-0.23036320507526398,
0.22450360655784607... |
func (u *utf8) getRune(fd int, timeout *syscall.Timeval) rune {
// use select() for the timeout
if timeout != nil {
for true {
rd := syscall.FdSet{}
fdset.Set(fd, &rd)
n, err := syscall.Select(fd+1, &rd, nil, nil, timeout)
if err != nil {
continue
}
if n == 0 {
// nothing is readable
r... | [
0.34708449244499207,
0.5567684769630432,
0.9555702805519104,
0.3021462559700012,
-0.04815296083688736,
-1.2663018703460693,
-0.15934179723262787,
0.49727725982666016,
-0.7020623683929443,
0.057147059589624405,
0.9108847379684448,
0.18115580081939697,
-0.6156582236289978,
-0.020896470174193... |
func wouldBlock(fd int, timeout *syscall.Timeval) bool {
rd := syscall.FdSet{}
fdset.Set(fd, &rd)
n, err := syscall.Select(fd+1, &rd, nil, nil, timeout)
if err != nil {
log.Printf("select error %s\n", err)
return false
}
return n == 0
} | [
-0.4269033968448639,
1.3020738363265991,
0.740044116973877,
0.14293377101421356,
-0.8727418780326843,
0.19085264205932617,
0.3240778148174286,
-0.5299702286720276,
0.16620297729969025,
-1.1112068891525269,
-0.13776884973049164,
-0.03852596879005432,
-0.033964354544878006,
1.201012492179870... |
func puts(fd int, s string) int {
n, err := syscall.Write(fd, []byte(s))
if err != nil {
panic(fmt.Sprintf("puts error %s\n", err))
}
return n
} | [
0.3168797194957733,
0.7359495759010315,
0.5997799038887024,
-1.3647723197937012,
-0.9212788939476013,
-0.6375277042388916,
0.27998340129852295,
-0.4562879204750061,
-0.4424487352371216,
-0.3020422160625458,
-0.1987554281949997,
0.6099430322647095,
-0.6677446961402893,
-0.0829802080988884,
... |
func getCursorPosition(ifd, ofd int) int {
// query the cursor location
if puts(ofd, "\x1b[6n") != 4 {
return -1
}
// read the response: ESC [ rows ; cols R
// rows/cols are decimal number strings
buf := make([]rune, 0, 32)
u := utf8{}
for len(buf) < 32 {
r := u.getRune(ifd, &timeout20ms)
if r == Keycode... | [
-0.13305912911891937,
-0.33201637864112854,
1.0475033521652222,
-0.11296146363019943,
-0.6386122703552246,
-1.29564368724823,
0.1363355964422226,
-0.20532479882240295,
-0.4317348003387451,
0.08001283556222916,
0.012300483882427216,
-0.6598926782608032,
-0.5761114954948425,
-0.1717151850461... |
func getColumns(ifd, ofd int) int {
// try using the ioctl to get the number of cols
var winsize [4]uint16
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)))
if err == 0 {
return int(winsize[1])
}
// the ioctl failed - try using the te... | [
0.16254985332489014,
0.2552041709423065,
0.8909922242164612,
-0.08564208447933197,
0.021468836814165115,
-1.3773857355117798,
0.1892104297876358,
-0.8691136240959167,
-0.560500979423523,
-0.14901770651340485,
0.10849536210298538,
0.021630212664604187,
-0.913830041885376,
-0.419466048479080... |
func unsupportedTerm() bool {
_, ok := unsupported[os.Getenv("TERM")]
return ok
} | [
-0.6651748418807983,
0.10565158724784851,
0.22344239056110382,
0.32907921075820923,
-0.4415917992591858,
1.126645565032959,
-0.8707947731018066,
1.0929192304611206,
-1.0035310983657837,
0.3587407171726227,
-0.8592540621757507,
-0.07660198211669922,
-0.22501704096794128,
0.49623119831085205... |
func (ls *linestate) refreshShowHints() []string {
// do we have a hints callback?
if ls.ts.hintsCallback == nil {
// no hints
return nil
}
// How many columns do we have for the hint?
hintCols := ls.cols - ls.promptWidth - runewidth.StringWidth(string(ls.buf))
if hintCols <= 0 {
// no space to display hint... | [
0.35911616683006287,
-0.6846997737884521,
0.7995211482048035,
-0.41609248518943787,
-0.8395755290985107,
-0.1086392030119896,
-0.8355363011360168,
-0.660247266292572,
0.35965046286582947,
0.5741199254989624,
0.3062722086906433,
0.5848148465156555,
0.04920419305562973,
0.3014026880264282,
... |
func (ls *linestate) refreshLine() {
if ls.ts.mlmode {
ls.refreshMultiline()
} else {
ls.refreshSingleline()
}
} | [
0.3346845805644989,
-0.4132392108440399,
0.3536067306995392,
0.9630600214004517,
-0.1335420459508896,
0.10267288237810135,
-1.0304844379425049,
-0.14944300055503845,
0.32716673612594604,
-0.17851242423057556,
0.35293012857437134,
0.7386423349380493,
0.5154339075088501,
0.9472164511680603,
... |
func (ls *linestate) editDelete() {
if len(ls.buf) > 0 && ls.pos < len(ls.buf) {
ls.buf = append(ls.buf[:ls.pos], ls.buf[ls.pos+1:]...)
ls.refreshLine()
}
} | [
0.18801912665367126,
-0.9999910593032837,
0.6595423221588135,
-0.8045105338096619,
0.8671900033950806,
-0.23631501197814941,
-0.07801979780197144,
-0.0010522679658606648,
0.7281102538108826,
-0.14647620916366577,
-0.16120585799217224,
0.6499024629592896,
-0.11038064956665039,
0.01279297471... |
func (ls *linestate) editBackspace() {
if ls.pos > 0 && len(ls.buf) > 0 {
ls.buf = append(ls.buf[:ls.pos-1], ls.buf[ls.pos:]...)
ls.pos--
ls.refreshLine()
}
} | [
0.16133980453014374,
-0.5776306390762329,
0.6474277973175049,
-0.8694835305213928,
0.9726291298866272,
-0.41283050179481506,
0.23113277554512024,
-0.41851410269737244,
0.36156758666038513,
0.01762532815337181,
-0.17341604828834534,
0.8984008431434631,
-0.4596349000930786,
0.425018817186355... |
func (ls *linestate) editInsert(r rune) {
ls.buf = append(ls.buf[:ls.pos], append([]rune{r}, ls.buf[ls.pos:]...)...)
ls.pos++
ls.refreshLine()
} | [
-0.34077778458595276,
-0.33221763372421265,
0.539890706539154,
-1.4354569911956787,
0.17378997802734375,
-0.22563859820365906,
0.15976020693778992,
-0.08440383523702621,
-0.39448919892311096,
-0.21088126301765442,
-1.0586094856262207,
0.4647655785083771,
-0.16547666490077972,
0.38324475288... |
func (ls *linestate) editSwap() {
if ls.pos > 0 && ls.pos < len(ls.buf) {
tmp := ls.buf[ls.pos-1]
ls.buf[ls.pos-1] = ls.buf[ls.pos]
ls.buf[ls.pos] = tmp
if ls.pos != len(ls.buf)-1 {
ls.pos++
}
ls.refreshLine()
}
} | [
-1.1624553203582764,
-0.6672969460487366,
0.8514966368675232,
-0.9834180474281311,
0.04932551085948944,
0.0776861160993576,
0.24753782153129578,
0.4485197365283966,
0.6140769124031067,
-0.5970005989074707,
-0.6721249222755432,
0.6447672247886658,
0.24153515696525574,
-0.18444055318832397,
... |
func (ls *linestate) editSet(s string) {
ls.buf = []rune(s)
ls.pos = len(ls.buf)
ls.refreshLine()
} | [
-0.38388824462890625,
-1.047359824180603,
0.2790655791759491,
-1.8297785520553589,
-0.23241952061653137,
-0.7088266015052795,
0.18718615174293518,
0.0009085139026865363,
-0.15332259237766266,
-0.49856045842170715,
-0.06911773234605789,
0.8579490780830383,
0.5905798077583313,
-0.41289544105... |
func (ls *linestate) editMoveLeft() {
if ls.pos > 0 {
ls.pos--
ls.refreshLine()
}
} | [
0.49807900190353394,
-1.05256986618042,
0.40685489773750305,
-0.5483933687210083,
0.4586009085178375,
-0.01748223975300789,
-0.08004571497440338,
-0.4673970639705658,
0.24045047163963318,
0.0641452744603157,
-0.3098047971725464,
0.30493584275245667,
0.7944802641868591,
0.6230016946792603,
... |
func (ls *linestate) editMoveRight() {
if ls.pos != len(ls.buf) {
ls.pos++
ls.refreshLine()
}
} | [
0.036359403282403946,
-0.739342987537384,
0.5336835384368896,
-0.3841438293457031,
-0.5019055604934692,
-0.1813420057296753,
-0.6932269930839539,
-0.8863245844841003,
0.31801334023475647,
-0.4718141555786133,
-0.7324867248535156,
0.21206305921077728,
0.43052709102630615,
0.8874629735946655... |
func (ls *linestate) editMoveHome() {
if ls.pos > 0 {
ls.pos = 0
ls.refreshLine()
}
} | [
-0.10511527210474014,
-0.8096370100975037,
0.4091193675994873,
0.41855841875076294,
0.7347452640533447,
-0.29264506697654724,
0.582273542881012,
0.1902080774307251,
0.16974958777427673,
0.48690295219421387,
-0.08059960603713989,
0.6912988424301147,
0.011150745674967766,
-0.1330558657646179... |
func (ls *linestate) editMoveEnd() {
if ls.pos != len(ls.buf) {
ls.pos = len(ls.buf)
ls.refreshLine()
}
} | [
-0.23983325064182281,
-0.806023120880127,
0.5036002993583679,
-0.7656458616256714,
0.2243633270263672,
-0.13820777833461761,
-0.3397834599018097,
-0.15147744119167328,
0.12250786274671555,
0.5480526685714722,
-0.7236540913581848,
0.36592283844947815,
0.14341247081756592,
0.3444965481758117... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.