id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c10100 | atomic.CompareAndSwapInt64(&ai.val, int64(expect), int64(update))
return res
} | |
c10101 | int(atomic.AddInt64(&ai.val, -1))
return res
} | |
c10102 | := int(atomic.LoadInt64(&ai.val))
return res
} | |
c10103 | := int(newVal - int64(delta))
return res
} | |
c10104 | res := int(newVal + 1)
return res
} | |
c10105 | int(atomic.SwapInt64(&ai.val, int64(newValue)))
return res
} | |
c10106 | int(atomic.AddInt64(&ai.val, 1))
return res
} | |
c10107 | atomic.StoreInt64(&ai.val, int64(newValue))
} | |
c10108 | {
val := NewValue(value)
return newFilter(binName, ICT_DEFAULT, val.GetType(), val, val)
} | |
c10109 |
return newFilter(binName, ICT_DEFAULT, vBegin.GetType(), vBegin, vEnd)
} | |
c10110 | return newFilter(binName, indexCollectionType, v.GetType(), v, v)
} | |
c10111 | return newFilter(binName, indexCollectionType, vBegin.GetType(), vBegin, vEnd)
} | |
c10112 | return newFilter(binName, ICT_DEFAULT, ParticleType.GEOJSON, v, v)
} | |
c10113 | return newFilter(binName, collectionType, ParticleType.GEOJSON, v, v)
} | |
c10114 | {
v := NewStringValue(point)
return newFilter(binName, ICT_DEFAULT, ParticleType.GEOJSON, v, v)
} | |
c10115 | return newFilter(binName, collectionType, ParticleType.GEOJSON, v, v)
} | |
c10116 | valueParticleType: valueParticleType,
begin: begin,
end: end,
}
} | |
c10117 | copy(cmd.key.digest[:], cmd.dataBuffer[1:size+1])
case NAMESPACE:
cmd.key.namespace = string(cmd.dataBuffer[1 : size+1])
case TABLE:
cmd.key.setName = string(cmd.dataBuffer[1 : size+1])
case KEY:
if cmd.key.userKey, err = bytesToKeyValue(int(cmd.dataBuffer[1]), cmd.dataBuffer, 2, size-1); err != nil {... | |
c10118 | - (4 + nameSize)
if err := cmd.readBytes(particleBytesSize); err != nil {
return nil, err
}
value, err := bytesToParticle(particleType, cmd.dataBuffer, 0, particleBytesSize)
if err != nil {
return nil, err
}
bins[name] = value
}
return newRecord(cmd.node, key, bins, generation, expiration), nil
} | |
c10119 |
if record == nil {
log.Fatalf(
"Failed to get record: namespace=%s set=%s key=%s",
key.Namespace(), key.SetName(), key.Value())
}
received := record.Bins[bin.Name]
expected := bin.Value.String()
if received == expected {
log.Printf("Get record successful: namespace=%s set=%s key=%s bin=%s value=%s",
... | |
c10120 | if err != nil {
ae, ok := err.(AerospikeError)
if ok && ae.ResultCode() == TIMEOUT {
ae.MarkInDoubt()
}
ch <- ae
return
} else if done {
ch <- nil
return
}
} // select
} // for
}()
return ch
} | |
c10121 | nil, ErrClosed
}
return &txn{d, d.DB.NewTransaction(!readOnly), false}, nil
} | |
c10122 | return &txn{d, d.DB.NewTransaction(!readOnly), true}
} | |
c10123 |
}
lsm, vlog := d.DB.Size()
return uint64(lsm + vlog), nil
} | |
c10124 | {
return ErrClosed
}
return t.close()
} | |
c10125 | more efficient version of calling Remove() and
// then Push()
heap.Fix(pq, item.index)
} | |
c10126 |
return -1, fmt.Errorf("PriorityQueue is empty. No top priority.")
}
} | |
c10127 | return
}
// Only allow supported subscription categories:
if category != "public_actions" && category != "larry_actions" &&
category != "moe_actions" && category != "curly_actions" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Subscription channel does not exist."))
return
}
// Client... | |
c10128 |
if lastElement := eb.List.Back(); lastElement != nil {
lastEvent, ok := lastElement.Value.(*lpEvent)
if !ok {
return fmt.Errorf("Found non-event type in event buffer.")
}
eb.oldestEventTime = lastEvent.Timestamp
}
return nil
} | |
c10129 | %s.\n", err)
}
io.WriteString(w, "{\"error\": \"Error creating new Subscription.\"}")
return
}
subscriptionRequests <- *subscription
// Listens for connection close and un-register subscription in the
// event that a client crashes or the connection goes down. We don't
// need to wait around to ful... | |
c10130 | sm.handleClientDisconnect(&disconnected)
sm.seeIfTimeToPurgeStaleCategories()
case event := <-sm.Events:
sm.handleNewEvent(&event)
sm.seeIfTimeToPurgeStaleCategories()
case <-time.After(time.Duration(5) * time.Second):
sm.seeIfTimeToPurgeStaleCategories()
case _ = <-sm.Quit:
if sm.LoggingEnabled... | |
c10131 | return
}
if len(pr.Events) > 0 {
if c.LoggingEnabled {
log.Println("Got", len(pr.Events), "event(s) from URL", u.String())
}
for _, event := range pr.Events {
since = event.Timestamp
c.EventsChan <- event
}
} else {
// Only push timestamp forward if its greater than the la... | |
c10132 | u, err)
return PollResponse{}, errors.New(msg)
}
if resp.StatusCode != http.StatusOK {
msg := fmt.Sprintf("Wrong status code received from longpoll server: %d", resp.StatusCode)
return PollResponse{}, errors.New(msg)
}
decoder := json.NewDecoder(resp.Body)
defer resp.Body.Close()
var pr PollResponse
er... | |
c10133 | == "" {
g.upperLetters = UpperLetters
}
if g.digits == "" {
g.digits = Digits
}
if g.symbols == "" {
g.symbols = Symbols
}
return g, nil
} | |
c10134 |
}
}
// Digits
for i := 0; i < numDigits; i++ {
d, err := randomElement(g.digits)
if err != nil {
return "", err
}
if !allowRepeat && strings.Contains(result, d) {
i--
continue
}
result, err = randomInsert(result, d)
if err != nil {
return "", err
}
}
// Symbols
for i := 0; i < n... | |
c10135 | noUpper, allowRepeat)
if err != nil {
panic(err)
}
return res
} | |
c10136 | return gen.Generate(length, numDigits, numSymbols, noUpper, allowRepeat)
} | |
c10137 | return "", err
}
i := n.Int64()
return s[0:i] + val + s[i:len(s)], nil
} | |
c10138 | return "", err
}
return string(s[n.Int64()]), nil
} | |
c10139 | {
fmt.Println("Metrics available at http://localhost:8080/debug/vars")
http.Serve(sock, nil)
}()
} | |
c10140 | dynamodb.ErrCodeProvisionedThroughputExceededException, dynamodb.ErrCodeLimitExceededException:
return true
default:
return false
}
}
return false
} | |
c10141 |
// necessarily close at the same time, so we could potentially get a
// thundering heard of notifications from the consumer.
for {
select {
case <-ctx.Done():
ticker.Stop()
return
case <-ticker.C:
b.findNewShards()
}
}
} | |
c10142 | _, shard := range shards {
if _, ok := b.shards[*shard.ShardId]; ok {
continue
}
b.shards[*shard.ShardId] = shard
b.shardc <- shard
}
} | |
c10143 | }
ss = append(ss, resp.Shards...)
if resp.NextToken == nil {
return ss, nil
}
listShardsInput = &kinesis.ListShardsInput{
NextToken: resp.NextToken,
StreamName: aws.String(b.streamName),
}
}
} | |
c10144 | *Checkpoint) {
c.maxInterval = maxInterval
}
} | |
c10145 | func(c *Checkpoint) {
c.client = svc
}
} | |
c10146 | &sync.Mutex{},
checkpoints: map[key]string{},
retryer: &DefaultRetryer{},
}
for _, opt := range opts {
opt(ck)
}
go ck.loop()
return ck, nil
} | |
c10147 | func(c *Consumer) {
c.client = client
}
} | |
c10148 | &noopCheckpoint{},
counter: &noopCounter{},
logger: &noopLogger{
logger: log.New(ioutil.Discard, "", log.LstdFlags),
},
}
// override defaults
for _, opt := range opts {
opt(c)
}
// default client if none provided
if c.client == nil {
newSession, err := session.NewSes... | |
c10149 | := c.ScanShard(ctx, shardID, fn); err != nil {
select {
case errc <- fmt.Errorf("shard %s error: %v", shardID, err):
// first error to occur
cancel()
default:
// error has already occured
}
}
}(aws.StringValue(shard.ShardId))
}
close(errc)
return <-errc
} | |
c10150 | })
// attempt to recover from GetRecords error by getting new shard iterator
if err != nil {
shardIterator, err = c.getShardIterator(c.streamName, shardID, lastSeqNum)
if err != nil {
return fmt.Errorf("get shard iterator error: %v", err)
}
continue
}
// loop over records, call call... | |
c10151 |
// verify we can ping server
_, err := client.Ping().Result()
if err != nil {
return nil, err
}
return &Checkpoint{
appName: appName,
client: client,
}, nil
} | |
c10152 | _ := c.client.Get(c.key(streamName, shardID)).Result()
return val, nil
} | |
c10153 | {
return fmt.Sprintf("%v:checkpoint:%v:%v", c.appName, streamName, shardID)
} | |
c10154 | appName,
tableName: tableName,
done: make(chan struct{}),
maxInterval: 1 * time.Minute,
mu: new(sync.Mutex),
checkpoints: map[key]string{},
}
for _, opt := range opts {
opt(ck)
}
go ck.loop()
return ck, nil
} | |
c10155 | <- struct{}{}
return c.save()
} | |
c10156 | interface compliance
var _ Interface = s
return s
} | |
c10157 | {
return false
}
equal := true
t.Each(func(item interface{}) bool {
_, equal = s.m[item]
return equal // if false, Each() will end
})
return equal
} | |
c10158 | fmt.Sprintf("%v", item))
}
return fmt.Sprintf("[%s]", strings.Join(t, ", "))
} | |
c10159 |
for _, set := range sets {
if !set.Has(item) {
result.Remove(item)
}
}
return true
})
return result
} | |
c10160 | Difference(t, s)
return Union(u, v)
} | |
c10161 | continue
}
slice = append(slice, v)
}
return slice
} | |
c10162 | s.List() {
v, ok := item.(int)
if !ok {
continue
}
slice = append(slice, v)
}
return slice
} | |
c10163 | err
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", tc.Token.AccessToken))
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
} | |
c10164 |
glog.Infof("[Gin-OAuth] Grant access to %s as team member of \"%s\"\n", tc.Scopes["uid"].(string), teamInfo.Id)
}
if teamInfo.Type == "official" {
ctx.Set("uid", tc.Scopes["uid"].(string))
ctx.Set("team", teamInfo.Id)
}
}
}
return granted
}
} | |
c10165 | s)
ctx.Set(s, cur) // set value from token of configured scope to the context, which you can use in your application.
}
}
//Getting the uid for identification of the service calling
if cur, ok := tc.Scopes["uid"]; ok {
ctx.Set("uid", cur)
}
return len(scopesFromToken) > 0
}
} | |
c10166 | t.Token == nil {
return false
}
return t.Token.Valid()
} | |
c10167 | conf = &oauth2.Config{
ClientID: c.ClientID,
ClientSecret: c.ClientSecret,
RedirectURL: redirectURL,
Scopes: scopes,
Endpoint: google.Endpoint,
}
} | |
c10168 |
return &FS{root, prefix}
} | |
c10169 | + string(fs.PathSeparator()) + path
} | |
c10170 | return fs.Filesystem.OpenFile(fs.PrefixPath(name), flag, perm)
} | |
c10171 | {
return fs.Filesystem.Remove(fs.PrefixPath(name))
} | |
c10172 | fs.Filesystem.Rename(fs.PrefixPath(oldpath), fs.PrefixPath(newpath))
} | |
c10173 | fs.Filesystem.Mkdir(fs.PrefixPath(name), perm)
} | |
c10174 | fs.Filesystem.Stat(fs.PrefixPath(name))
} | |
c10175 | fs.Filesystem.ReadDir(fs.PrefixPath(path))
} | |
c10176 | *MemFile {
return &MemFile{
Buffer: NewBuffer(buf),
mutex: rwMutex,
name: name,
}
} | |
c10177 | = b.Buffer.Truncate(size)
b.mutex.Unlock()
return
} | |
c10178 | + a little extra in case Size is
// zero, and to avoid another allocation after Read has filled the buffer.
// The readAll call will read into its allocated internal buffer cheaply. If
// the size was wrong, we'll either waste some space off the end or
// reallocate as needed, but in the overwhelmingly common case... | |
c10179 | error {
return ErrReadOnly
} | |
c10180 | root: root,
wd: root,
lock: &sync.RWMutex{},
}
} | |
c10181 | name, fmt.Errorf("Directory %q already exists", name)}
}
fi = &fileInfo{
name: base,
dir: true,
mode: perm,
parent: parent,
modTime: time.Now(),
fs: fs,
}
parent.childs[base] = fi
return nil
} | |
c10182 | {
return 0, ErrReadOnly
} | |
c10183 | {
return 0, ErrWriteOnly
} | |
c10184 | err = ErrTooLarge
return
}
}()
b = make([]byte, n)
return
} | |
c10185 | int, perm os.FileMode) (File, error) {
return nil, fs.err
} | |
c10186 | error {
return fs.err
} | |
c10187 | {
return nil, fs.err
} | |
c10188 | ([]os.FileInfo, error) {
return nil, fs.err
} | |
c10189 | (n int, err error) {
return 0, f.err
} | |
c10190 | err error) {
return 0, f.err
} | |
c10191 | whence int) (int64, error) {
return 0, f.err
} | |
c10192 |
return os.OpenFile(name, flag, perm)
} | |
c10193 | return os.Mkdir(name, perm)
} | |
c10194 | return os.Rename(oldpath, newpath)
} | |
c10195 | error) {
return ioutil.ReadDir(path)
} | |
c10196 | mounts: make(map[string]vfs.Filesystem),
parents: make(map[string][]string),
}
} | |
c10197 | mountPath := strings.Join(segs[0:i], pathSeparator)
if fs, ok := mounts[mountPath]; ok {
return fs, "/" + strings.Join(segs[i:l], pathSeparator)
}
}
return fallback, path
} | |
c10198 | findMount(name, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
return mount.Remove(innerPath)
} | |
c10199 |
newMount, newInnerPath := findMount(newpath, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
if oldMount != newMount {
return ErrBoundary
}
return oldMount.Rename(oldInnerPath, newInnerPath)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.