Dataset Viewer
Auto-converted to Parquet Duplicate
query
stringlengths
8
6.75k
document
stringlengths
9
1.89M
negatives
sequencelengths
19
19
metadata
dict
Returns the value of the 'go_package' option of the first .proto file found in the same directory as projectFile
func detectGoPackageForProject(projectFile string) (string, error) { var goPkg string projectDir := filepath.Dir(projectFile) if err := filepath.Walk(projectDir, func(protoFile string, info os.FileInfo, err error) error { // already set if goPkg != "" { return nil } if !strings.HasSuffix(protoFile, ".proto") { return nil } // search for go_package on protos in the same dir as the project.json if projectDir != filepath.Dir(protoFile) { return nil } content, err := ioutil.ReadFile(protoFile) if err != nil { return err } lines := strings.Split(string(content), "\n") for _, line := range lines { goPackage := goPackageStatementRegex.FindStringSubmatch(line) if len(goPackage) == 0 { continue } if len(goPackage) != 2 { return errors.Errorf("parsing go_package error: from %v found %v", line, goPackage) } goPkg = goPackage[1] break } return nil }); err != nil { return "", err } if goPkg == "" { return "", errors.Errorf("no go_package statement found in root dir of project %v", projectFile) } return goPkg, nil }
[ "func (c *common) GetPackage() string { return c.file.GetPackage() }", "func (pkg *goPackage) firstGoFile() string {\n\tgoSrcs := []platformStringsBuilder{\n\t\tpkg.library.sources,\n\t\tpkg.binary.sources,\n\t\tpkg.test.sources,\n\t}\n\tfor _, sb := range goSrcs {\n\t\tif sb.strs != nil {\n\t\t\tfor s := range s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
NewQueueManager instantiates a new QueueManager object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed
func NewQueueManager(name string, clusters []string, aliasQueues []AliasQueue, remoteQueues []RemoteQueue, clusterQueues []ClusterQueue, ) *QueueManager { this := QueueManager{} this.Name = name this.Clusters = clusters this.AliasQueues = aliasQueues this.RemoteQueues = remoteQueues this.ClusterQueues = clusterQueues return &this }
[ "func New() *QueueManager {\n\treturn &QueueManager{\n\t\thandlers: make(map[string]Handler),\n\t}\n}", "func NewQueueManager(logger log.Logger, cfg config.QueueConfig, externalLabels labels.Labels, relabelConfigs []*relabel.Config, client StorageClient, flushDeadline time.Duration) *QueueManager {\n\tif logger =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
NewQueueManagerWithDefaults instantiates a new QueueManager object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set
func NewQueueManagerWithDefaults() *QueueManager { this := QueueManager{} return &this }
[ "func New() *QueueManager {\n\treturn &QueueManager{\n\t\thandlers: make(map[string]Handler),\n\t}\n}", "func NewQueueManager(logger log.Logger, cfg config.QueueConfig, externalLabels labels.Labels, relabelConfigs []*relabel.Config, client StorageClient, flushDeadline time.Duration) *QueueManager {\n\tif logger =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetClusters returns the Clusters field value
func (o *QueueManager) GetClusters() []string { if o == nil { var ret []string return ret } return o.Clusters }
[ "func (c *ClientImpl) GetClusters(ctx context.Context, hcpHostURL string) (models.ClusterResp, error) {\n\tspan, _ := opentracing.StartSpanFromContext(ctx, \"Get Clusters\")\n\tdefer span.Finish()\n\n\tsession, err := c.getSession(ctx, hcpHostURL, hcpUserName, hcpPassword)\n\tif err != nil {\n\t\treturn models.Clus...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetClustersOk returns a tuple with the Clusters field value and a boolean to check if the value has been set.
func (o *QueueManager) GetClustersOk() (*[]string, bool) { if o == nil { return nil, false } return &o.Clusters, true }
[ "func NewGetClustersOK() *GetClustersOK {\n\treturn &GetClustersOK{}\n}", "func (o *VirtualizationVmwareVcenterAllOf) GetClusterCountOk() (*int64, bool) {\n\tif o == nil || o.ClusterCount == nil {\n\t\treturn nil, false\n\t}\n\treturn o.ClusterCount, true\n}", "func (o *ResourceLimits) GetK8sClustersProvisioned...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SetClusters sets field value
func (o *QueueManager) SetClusters(v []string) { o.Clusters = v }
[ "func (s *RaftDatabase) SetClusters(clusters int) {\n\ts.clusters = clusters\n}", "func setSomeClusterValues(ch chan error, manager ConfigManager) error {\n\t// prepare expected cluster config\n\tconf := new(ClusterConfig)\n\tconf.ClusterId = \"myClusterID\"\n\tconf.Description = \"myDescription\"\n\n\tif err := ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetAliasQueues returns the AliasQueues field value
func (o *QueueManager) GetAliasQueues() []AliasQueue { if o == nil { var ret []AliasQueue return ret } return o.AliasQueues }
[ "func (o *QueueManager) GetAliasQueuesOk() (*[]AliasQueue, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.AliasQueues, true\n}", "func (o *QueueManager) SetAliasQueues(v []AliasQueue) {\n\to.AliasQueues = v\n}", "func (b *backend) Queues(ctx context.Context, qq *entroq.QueuesQuery) (map[stri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetAliasQueuesOk returns a tuple with the AliasQueues field value and a boolean to check if the value has been set.
func (o *QueueManager) GetAliasQueuesOk() (*[]AliasQueue, bool) { if o == nil { return nil, false } return &o.AliasQueues, true }
[ "func (o *QueueManager) GetAliasQueues() []AliasQueue {\n\tif o == nil {\n\t\tvar ret []AliasQueue\n\t\treturn ret\n\t}\n\n\treturn o.AliasQueues\n}", "func (o *QueueManager) SetAliasQueues(v []AliasQueue) {\n\to.AliasQueues = v\n}", "func (o *QueueManager) GetClusterQueuesOk() (*[]ClusterQueue, bool) {\n\tif ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SetAliasQueues sets field value
func (o *QueueManager) SetAliasQueues(v []AliasQueue) { o.AliasQueues = v }
[ "func (p *Process) CmdSetQueue(pac teoapi.Packet) (err error) {\n\tdata := pac.RemoveTrailingZero(pac.Data())\n\trequest := cdb.KeyValue{Cmd: pac.Cmd()}\n\tif err = request.UnmarshalText(data); err != nil {\n\t\treturn\n\t} else if err = p.tcdb.SetQueue(request.Key, request.Value); err != nil {\n\t\treturn\n\t}\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetRemoteQueues returns the RemoteQueues field value
func (o *QueueManager) GetRemoteQueues() []RemoteQueue { if o == nil { var ret []RemoteQueue return ret } return o.RemoteQueues }
[ "func (o *QueueManager) GetRemoteQueuesOk() (*[]RemoteQueue, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.RemoteQueues, true\n}", "func (o *RemoteQueue) GetRemoteQueue() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.RemoteQueue\n}", "func (o *QueueManage...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetRemoteQueuesOk returns a tuple with the RemoteQueues field value and a boolean to check if the value has been set.
func (o *QueueManager) GetRemoteQueuesOk() (*[]RemoteQueue, bool) { if o == nil { return nil, false } return &o.RemoteQueues, true }
[ "func (o *RemoteQueue) GetRemoteQueueOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.RemoteQueue, true\n}", "func (o *RemoteQueue) GetRemoteQueueManagerOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.RemoteQueueManager, true\n}", "func (o *Remo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SetRemoteQueues sets field value
func (o *QueueManager) SetRemoteQueues(v []RemoteQueue) { o.RemoteQueues = v }
[ "func (o *RemoteQueue) SetRemoteQueue(v string) {\n\to.RemoteQueue = v\n}", "func (s *Filters) SetQueues(v []*string) *Filters {\n\ts.Queues = v\n\treturn s\n}", "func (p *Process) CmdSetQueue(pac teoapi.Packet) (err error) {\n\tdata := pac.RemoveTrailingZero(pac.Data())\n\trequest := cdb.KeyValue{Cmd: pac.Cmd(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetClusterQueues returns the ClusterQueues field value
func (o *QueueManager) GetClusterQueues() []ClusterQueue { if o == nil { var ret []ClusterQueue return ret } return o.ClusterQueues }
[ "func (o *QueueManager) GetClusterQueuesOk() (*[]ClusterQueue, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.ClusterQueues, true\n}", "func (o *QueueManager) GetClusters() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\n\treturn o.Clusters\n}", "func (client *Clie...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GetClusterQueuesOk returns a tuple with the ClusterQueues field value and a boolean to check if the value has been set.
func (o *QueueManager) GetClusterQueuesOk() (*[]ClusterQueue, bool) { if o == nil { return nil, false } return &o.ClusterQueues, true }
[ "func (o *QueueManager) GetAliasQueuesOk() (*[]AliasQueue, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.AliasQueues, true\n}", "func (o *QueueManager) GetClustersOk() (*[]string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Clusters, true\n}", "func (o *QueueManager) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a tiploc to the result so that it will be included in the tiploc map
func (bf *boardFilter) addTiploc(tiploc string) { if tiploc != "" { bf.tiplocs[tiploc] = nil } }
[ "func (r *LocationMap) Add(t *Location) {\n\tif _, ok := r.m[t.Tiploc]; !ok {\n\t\tr.m[t.Tiploc] = t\n\t}\n}", "func (bd *BlockDAG) updateTips(b *Block) {\n\tif bd.tips == nil {\n\t\tbd.tips = NewHashSet()\n\t\tbd.tips.AddPair(b.GetHash(), b)\n\t\treturn\n\t}\n\tfor k := range bd.tips.GetMap() {\n\t\tblock := bd....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Process calling points so that we generate the appropriate via and include their tiplocs
func (bf *boardFilter) processCallingPoints(s ldb.Service) { if len(s.CallingPoints) > 0 { viaRequest := bf.addVia(s.RID, s.CallingPoints[len(s.CallingPoints)-1].Tiploc) for _, cp := range s.CallingPoints { bf.addTiploc(cp.Tiploc) viaRequest.AppendTiploc(cp.Tiploc) } } }
[ "func TipCaller(handler interface{}, params ...interface{}) {\n\thandler.(func(*Tip))(params[0].(*Tip))\n}", "func processCoords(gpspoints []GPSPoint) (points Points) {\n\tfor i := 0; i < len(gpspoints); i++ {\n\t\tpoints = append(points, Point{gpspoints[i].Lon, gpspoints[i].Lat, gpspoints[i].SignalDbm})\n\t}\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Process any associations, pulling in their schedules
func (bf *boardFilter) processAssociations(s ldb.Service) { for _, assoc := range s.Associations { assoc.AddTiplocs(bf.tiplocs) //if assoc.IsJoin() || assoc.IsSplit() { ar := assoc.Main.RID ai := assoc.Main.LocInd if ar == s.RID { ar = assoc.Assoc.RID ai = assoc.Assoc.LocInd } // Resolve the schedule if a split, join or if NP only if previous service & we are not yet running //if ar != s.RID { if assoc.Category != "NP" || (s.LastReport.Tiploc == "" && assoc.Assoc.RID == s.RID) { as := bf.d.ldb.GetSchedule(ar) if as != nil { assoc.Schedule = as as.AddTiplocs(bf.tiplocs) as.LastReport = as.GetLastReport() bf.processToc(as.Toc) if ai < (len(as.Locations) - 1) { if as.Origin != nil { bf.addTiploc(as.Destination.Tiploc) } destination := as.Locations[len(as.Locations)-1].Tiploc if as.Destination != nil { destination = as.Destination.Tiploc } viaRequest := bf.addVia(ar, destination) for _, l := range as.Locations[ai:] { bf.addTiploc(l.Tiploc) viaRequest.AppendTiploc(l.Tiploc) } } bf.processReason(as.CancelReason, true) bf.processReason(as.LateReason, false) } } } }
[ "func (s *candidate) Schedule() (constructedSchedule, error) {\n\tsch := constructedSchedule{\n\t\tearliest: s.earliest,\n\t\teventsByAttendee: make(map[AttendeeID]*attendeeEvents),\n\t}\n\tfor _, event := range s.order {\n\t\tif err := sch.Add(s.reqs[event]); err != nil {\n\t\t\treturn sch, err\n\t\t}\n\t}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
acceptService returns true if the service is to be accepted, false if it's to be ignored
func (bf *boardFilter) acceptService(service ldb.Service) bool { // Original requirement, must have an RID if service.RID == "" { return false } // remove terminating services if bf.terminated && bf.atStation(service.Destination) { return false } if bf.callAt && !bf.callsAt(service.CallingPoints, bf.callAtTiplocs) { return false } return true }
[ "func (f *aclFilter) allowService(service string) bool {\n\tif service == \"\" {\n\t\treturn true\n\t}\n\n\tif !f.enforceVersion8 && service == structs.ConsulServiceID {\n\t\treturn true\n\t}\n\treturn f.authorizer.ServiceRead(service)\n}", "func (r *RPCAcceptor) Accept(req *ChannelAcceptRequest) bool {\n\treturn...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rowToRecord converts from pgx.Row to a store.Record
func (s *sqlStore) rowToRecord(row pgx.Row) (*store.Record, error) { var expiry *time.Time record := &store.Record{} metadata := make(Metadata) if err := row.Scan(&record.Key, &record.Value, &metadata, &expiry); err != nil { if err == sql.ErrNoRows { return record, store.ErrNotFound } return nil, err } // set the metadata record.Metadata = toMetadata(&metadata) if expiry != nil { record.Expiry = time.Until(*expiry) } return record, nil }
[ "func (s *sqlStore) rowsToRecords(rows pgx.Rows) ([]*store.Record, error) {\n\tvar records []*store.Record\n\n\tfor rows.Next() {\n\t\tvar expiry *time.Time\n\t\trecord := &store.Record{}\n\t\tmetadata := make(Metadata)\n\n\t\tif err := rows.Scan(&record.Key, &record.Value, &metadata, &expiry); err != nil {\n\t\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rowsToRecords converts from pgx.Rows to []store.Record
func (s *sqlStore) rowsToRecords(rows pgx.Rows) ([]*store.Record, error) { var records []*store.Record for rows.Next() { var expiry *time.Time record := &store.Record{} metadata := make(Metadata) if err := rows.Scan(&record.Key, &record.Value, &metadata, &expiry); err != nil { return records, err } // set the metadata record.Metadata = toMetadata(&metadata) if expiry != nil { record.Expiry = time.Until(*expiry) } records = append(records, record) } return records, nil }
[ "func (s *sqlStore) rowToRecord(row pgx.Row) (*store.Record, error) {\n\tvar expiry *time.Time\n\trecord := &store.Record{}\n\tmetadata := make(Metadata)\n\n\tif err := row.Scan(&record.Key, &record.Value, &metadata, &expiry); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn record, store.ErrNotFound\n\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
findConflict finds the index of the conflict. It returns the first pair of conflicting entries between the existing entries and the given entries, if there are any. If there is no conflicting entries, and the existing entries contains all the given entries, zero will be returned. If there is no conflicting entries, but the given entries contains new entries, the index of the first new entry will be returned. An entry is considered to be conflicting if it has the same index but a different term. The first entry MUST have an index equal to the argument 'from'. The index of the given entries MUST be continuously increasing.
func (l *LogStore) findConflict(entries []*pb.Entry) uint64 { // TODO: 会有第0个冲突么? for _, ne := range entries { if !l.matchTerm(ne.Index, ne.Term) { if ne.Index <= l.lastIndex() { l.logger.Info("log found conflict", zap.Uint64("conflictIndex", ne.Index), zap.Uint64("conflictTerm", ne.Term), zap.Uint64("existTerm", l.termOrPanic(l.term(ne.Index)))) } return ne.Index } } return 0 }
[ "func (l *raftLog) findConflict(from uint64, ents []pb.Entry) uint64 {\n\t// TODO(xiangli): validate the index of ents\n\tfor i, ne := range ents {\n\t\tif oe := l.at(from + uint64(i)); oe == nil || oe.Term != ne.Term {\n\t\t\treturn from + uint64(i)\n\t\t}\n\t}\n\treturn 0\n}", "func FindConflictsByUser(entries ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add adds one or more previously unadded urls to crawler to visit. source can be nil to indicate root. Returns a list of errors if any occured.
func (c *Crawler) Add(source *url.URL, uri ...*url.URL) []error { var errs []error for _, u := range uri { var err error u := u u.Fragment = "" // reset fragment, we don't want it messing our visited list if source != nil { u = source.ResolveReference(u) } if u.Scheme != "http" && u.Scheme != "https" { err = ErrUnsupportedScheme } else if err == nil && c.filter != nil && !c.filter(u) { err = ErrFilteredOut } us := u.String() // For the already-visited test we need to clean up each URL a bit vkey := strings.TrimRight(us[strings.Index(us, ":")+1:], "/") // Remove scheme and trailing slash if err == nil { c.toVisitMu.RLock() if _, ok := c.toVisit[vkey]; ok { err = ErrAlreadyInList } c.toVisitMu.RUnlock() } if err == nil { c.logger.Debugf("Add(%v %v): OK", source, us) atomic.AddUint64(&c.numQueued, 1) } else if err != nil { //c.logger.Warnf("Add(%v %v): %v", source, us, err) atomic.AddUint64(&c.numEncountered, 1) errs = append(errs, errors.Wrapf(err, "Invalid URL %v", u)) continue } c.toVisitMu.Lock() c.toVisit[vkey] = struct{}{} c.toVisitMu.Unlock() { uu := *u uu.Scheme = "" if source != nil && source.Host == uu.Host { uu.Host = "" } if source == nil { c.mapper.Add("<root>", uu.String()) } else { c.mapper.Add(source.String(), uu.String()) } } v := visit{ source: source, target: u, } select { case c.visitChan <- v: case <-c.ctx.Done(): return append(errs, c.ctx.Err()) } } return errs }
[ "func add(url string, verbose bool, scrapeURLs *scrapeURL) {\n\tscrapeURLs.AddedURLsCount++\n\tscrapeURLs.AddedURLs = append(scrapeURLs.AddedURLs, url)\n\tif verbose {\n\t\tlog.Println(\"Added: \" + url)\n\t}\n}", "func (s *Sources) Add(src string) error {\n\tif src == \"\" {\n\t\treturn errors.New(\"src is an em...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
getSourcegraphVersion queries the Sourcegraph GraphQL API to get the current version of the Sourcegraph instance.
func (svc *Service) getSourcegraphVersion(ctx context.Context) (string, error) { var result struct { Site struct { ProductVersion string } } ok, err := svc.client.NewQuery(sourcegraphVersionQuery).Do(ctx, &result) if err != nil || !ok { return "", err } return result.Site.ProductVersion, err }
[ "func GetVersion() string {\n\treturn version\n}", "func (_ EntityAliases) SensuAgentVersion(p graphql.ResolveParams) (string, error) {\n\tval, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)\n\tret, ok := val.(string)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tif !ok {\n\t\treturn ret, errors.New...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
26