_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q172400
SetChunkSize
validation
func (file *GridFile) SetChunkSize(bytes int) { file.assertMode(gfsWriting) debugf("GridFile %p: setting chunk size to %d", file, bytes) file.m.Lock() file.doc.ChunkSize = bytes file.m.Unlock() }
go
{ "resource": "" }
q172401
SetId
validation
func (file *GridFile) SetId(id interface{}) { file.assertMode(gfsWriting) file.m.Lock() file.doc.Id = id file.m.Unlock() }
go
{ "resource": "" }
q172402
SetName
validation
func (file *GridFile) SetName(name string) { file.assertMode(gfsWriting) file.m.Lock() file.doc.Filename = name file.m.Unlock() }
go
{ "resource": "" }
q172403
SetContentType
validation
func (file *GridFile) SetContentType(ctype string) { file.assertMode(gfsWriting) file.m.Lock() file.doc.ContentType = ctype file.m.Unlock() }
go
{ "resource": "" }
q172404
Size
validation
func (file *GridFile) Size() (bytes int64) { file.m.Lock() bytes = file.doc.Length file.m.Unlock() return }
go
{ "resource": "" }
q172405
SetUploadDate
validation
func (file *GridFile) SetUploadDate(t time.Time) { file.assertMode(gfsWriting) file.m.Lock() file.doc.UploadDate = t file.m.Unlock() }
go
{ "resource": "" }
q172406
Abort
validation
func (file *GridFile) Abort() { if file.mode != gfsWriting { panic("file.Abort must be called on file opened for writing") } file.err = errors.New("write aborted") }
go
{ "resource": "" }
q172407
Write
validation
func (file *GridFile) Write(data []byte) (n int, err error) { file.assertMode(gfsWriting) file.m.Lock() debugf("GridFile %p: writing %d bytes", file, len(data)) defer file.m.Unlock() if file.err != nil { return 0, file.err } n = len(data) file.doc.Length += int64(n) chunkSize := file.doc.ChunkSize if len...
go
{ "resource": "" }
q172408
Read
validation
func (file *GridFile) Read(b []byte) (n int, err error) { file.assertMode(gfsReading) file.m.Lock() debugf("GridFile %p: reading at offset %d into buffer of length %d", file, file.offset, len(b)) defer file.m.Unlock() if file.offset == file.doc.Length { return 0, io.EOF } for err == nil { i := copy(b, file.r...
go
{ "resource": "" }
q172409
setCursorPosition
validation
func (h *windowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error { position.X = ensureInRange(position.X, window.Left, window.Right) position.Y = ensureInRange(position.Y, window.Top, window.Bottom) err := SetConsoleCursorPosition(h.fd, position) if err != nil { return err } h.logf("...
go
{ "resource": "" }
q172410
collectAnsiIntoWindowsAttributes
validation
func collectAnsiIntoWindowsAttributes(windowsMode uint16, inverted bool, baseMode uint16, ansiMode int16) (uint16, bool) { switch ansiMode { // Mode styles case ansiterm.ANSI_SGR_BOLD: windowsMode = windowsMode | FOREGROUND_INTENSITY case ansiterm.ANSI_SGR_DIM, ansiterm.ANSI_SGR_BOLD_DIM_OFF: windowsMode &^= ...
go
{ "resource": "" }
q172411
invertAttributes
validation
func invertAttributes(windowsMode uint16) uint16 { return (COMMON_LVB_MASK & windowsMode) | ((FOREGROUND_MASK & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4) }
go
{ "resource": "" }
q172412
simulateLF
validation
func (h *windowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { if h.wrapNext { if err := h.Flush(); err != nil { return false, err } h.clearWrap() } pos, info, err := h.getCurrentInfo() if err != nil { return false, err } sr := h.effectiveSr(info.Window) if pos.Y == sr.bottom { // Scro...
go
{ "resource": "" }
q172413
executeLF
validation
func (h *windowsAnsiEventHandler) executeLF() error { handled, err := h.simulateLF(false) if err != nil { return err } if !handled { // Windows LF will reset the cursor column position. Write the LF // and restore the cursor position. pos, _, err := h.getCurrentInfo() if err != nil { return err } h...
go
{ "resource": "" }
q172414
effectiveSr
validation
func (h *windowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion { top := addInRange(window.Top, h.sr.top, window.Top, window.Bottom) bottom := addInRange(window.Top, h.sr.bottom, window.Top, window.Bottom) if top >= bottom { top = window.Top bottom = window.Bottom } return scrollRegion{top: top, ...
go
{ "resource": "" }
q172415
scroll
validation
func (h *windowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSOLE_SCREEN_BUFFER_INFO) error { h.logf("scroll: scrollTop: %d, scrollBottom: %d", sr.top, sr.bottom) h.logf("scroll: windowTop: %d, windowBottom: %d", info.Window.Top, info.Window.Bottom) // Copy from and clip to the scroll region (full ...
go
{ "resource": "" }
q172416
scrollLine
validation
func (h *windowsAnsiEventHandler) scrollLine(columns int, position COORD, info *CONSOLE_SCREEN_BUFFER_INFO) error { // Copy from and clip to the scroll region (full buffer width) scrollRect := SMALL_RECT{ Top: position.Y, Bottom: position.Y, Left: position.X, Right: info.Size.X - 1, } // Origin to wh...
go
{ "resource": "" }
q172417
bytesToHex
validation
func bytesToHex(b []byte) string { hex := make([]string, len(b)) for i, ch := range b { hex[i] = fmt.Sprintf("%X", ch) } return strings.Join(hex, "") }
go
{ "resource": "" }
q172418
readCloser
validation
func (e *FileCacheEntry) readCloser() (*CachedFile, error) { var f *os.File var err error if e.fileDoesNotExist() { f, err = os.Create(e.FilePath) if err != nil { return nil, err } err = compressor.WriteTar(e.ExpandedDirectoryPath+"/", f) if err != nil { return nil, err } // If the directory i...
go
{ "resource": "" }
q172419
New
validation
func New( downloader *Downloader, cache *FileCache, transformer CacheTransformer, ) *cachedDownloader { os.MkdirAll(cache.CachedPath, 0770) return &cachedDownloader{ cache: cache, cacheLocation: filepath.Join(cache.CachedPath, "saved_cache.json"), uncachedPath: createTempCachedDir(cache.CachedPath),...
go
{ "resource": "" }
q172420
populateCache
validation
func (c *cachedDownloader) populateCache( logger lager.Logger, url *url.URL, name string, cachingInfo CachingInfoType, checksum ChecksumInfoType, transformer CacheTransformer, cancelChan <-chan struct{}, ) (download, bool, int64, error) { filename, cachingInfo, err := c.downloader.Download(logger, url, func() (...
go
{ "resource": "" }
q172421
Log
validation
func (ui *ColorUI) Log(message string) { ct.ChangeColor(ui.LogFGColor.Code, ui.LogFGColor.Bright, ui.LogBGColor.Code, ui.LogBGColor.Bright) ui.UI.Log(message) ct.ResetColor() }
go
{ "resource": "" }
q172422
Output
validation
func (ui *ColorUI) Output(message string) { ct.ChangeColor(ui.OutputFGColor.Code, ui.OutputFGColor.Bright, ui.OutputBGColor.Code, ui.OutputBGColor.Bright) ui.UI.Output(message) ct.ResetColor() }
go
{ "resource": "" }
q172423
Success
validation
func (ui *ColorUI) Success(message string) { ct.ChangeColor(ui.SuccessFGColor.Code, ui.SuccessFGColor.Bright, ui.SuccessBGColor.Code, ui.SuccessBGColor.Bright) ui.UI.Success(message) ct.ResetColor() }
go
{ "resource": "" }
q172424
Info
validation
func (ui *ColorUI) Info(message string) { ct.ChangeColor(ui.InfoFGColor.Code, ui.InfoFGColor.Bright, ui.InfoBGColor.Code, ui.InfoBGColor.Bright) ui.UI.Info(message) ct.ResetColor() }
go
{ "resource": "" }
q172425
Error
validation
func (ui *ColorUI) Error(message string) { ct.ChangeColor(ui.ErrorFGColor.Code, ui.ErrorFGColor.Bright, ui.ErrorBGColor.Code, ui.ErrorBGColor.Bright) ui.UI.Error(message) ct.ResetColor() }
go
{ "resource": "" }
q172426
Warn
validation
func (ui *ColorUI) Warn(message string) { ct.ChangeColor(ui.WarnFGColor.Code, ui.WarnFGColor.Bright, ui.WarnBGColor.Code, ui.WarnBGColor.Bright) ui.UI.Warn(message) ct.ResetColor() }
go
{ "resource": "" }
q172427
Running
validation
func (ui *ColorUI) Running(message string) { ct.ChangeColor(ui.RunningFGColor.Code, ui.RunningFGColor.Bright, ui.RunningBGColor.Code, ui.RunningBGColor.Bright) ui.UI.Running(message) ct.ResetColor() }
go
{ "resource": "" }
q172428
Log
validation
func (ui *BasicUI) Log(message string) { timeString := time.Now().Format(timeFormat) message = timeString + ": " + message ui.Output(message) }
go
{ "resource": "" }
q172429
Output
validation
func (ui *BasicUI) Output(message string) { fmt.Fprint(ui.Writer, message) fmt.Fprint(ui.Writer, "\n") }
go
{ "resource": "" }
q172430
Error
validation
func (ui *BasicUI) Error(message string) { if ui.ErrorWriter != nil { fmt.Fprint(ui.ErrorWriter, message) fmt.Fprint(ui.ErrorWriter, "\n") } else { fmt.Fprint(ui.Writer, message) fmt.Fprint(ui.Writer, "\n") } }
go
{ "resource": "" }
q172431
Log
validation
func (ui *PrefixUI) Log(message string) { if ui.LogPrefix == " " { //Lets keep the space if they want one message = ui.LogPrefix + message } else if ui.LogPrefix != "" { message = ui.LogPrefix + " " + message } ui.UI.Log(message) }
go
{ "resource": "" }
q172432
Output
validation
func (ui *PrefixUI) Output(message string) { if ui.OutputPrefix == " " { //Lets keep the space if they want one message = ui.OutputPrefix + message } else if ui.OutputPrefix != "" { message = ui.OutputPrefix + " " + message } ui.UI.Output(message) }
go
{ "resource": "" }
q172433
Success
validation
func (ui *PrefixUI) Success(message string) { if ui.SuccessPrefix == " " { //Lets keep the space if they want one message = ui.SuccessPrefix + message } else if ui.SuccessPrefix != "" { message = ui.SuccessPrefix + " " + message } ui.UI.Success(message) }
go
{ "resource": "" }
q172434
Info
validation
func (ui *PrefixUI) Info(message string) { if ui.InfoPrefix == " " { //Lets keep the space if they want one message = ui.InfoPrefix + message } else if ui.InfoPrefix != "" { message = ui.InfoPrefix + " " + message } ui.UI.Info(message) }
go
{ "resource": "" }
q172435
Error
validation
func (ui *PrefixUI) Error(message string) { if ui.ErrorPrefix == " " { //Lets keep the space if they want one message = ui.ErrorPrefix + message } else if ui.ErrorPrefix != "" { message = ui.ErrorPrefix + " " + message } ui.UI.Error(message) }
go
{ "resource": "" }
q172436
Warn
validation
func (ui *PrefixUI) Warn(message string) { if ui.WarnPrefix == " " { //Lets keep the space if they want one message = ui.WarnPrefix + message } else if ui.WarnPrefix != "" { message = ui.WarnPrefix + " " + message } ui.UI.Warn(message) }
go
{ "resource": "" }
q172437
Running
validation
func (ui *PrefixUI) Running(message string) { if ui.RunningPrefix == " " { //Lets keep the space if they want one message = ui.RunningPrefix + message } else if ui.RunningPrefix != "" { message = ui.RunningPrefix + " " + message } ui.UI.Running(message) }
go
{ "resource": "" }
q172438
New
validation
func New(reader io.Reader, writer, errorWriter io.Writer) *BasicUI { return &BasicUI{ Reader: reader, Writer: writer, ErrorWriter: errorWriter, } }
go
{ "resource": "" }
q172439
AddColor
validation
func AddColor(askColor, errorColor, infoColor, logColor, outputColor, responseColor, runningColor, successColor, warnColor Color, ui UI) *ColorUI { return &ColorUI{ LogFGColor: logColor, LogBGColor: None, OutputFGColor: outputColor, OutputBGColor: None, SuccessFGColor: successColor, SuccessB...
go
{ "resource": "" }
q172440
Log
validation
func (ui *ConcurrentUI) Log(message string) { ui.l.Lock() defer ui.l.Unlock() ui.UI.Log(message) }
go
{ "resource": "" }
q172441
NewMongoStore
validation
func NewMongoStore(c *mgo.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) *MongoStore { store := &MongoStore{ Codecs: securecookie.CodecsFromPairs(keyPairs...), Options: &sessions.Options{ Path: "/", MaxAge: maxAge, }, Token: &CookieToken{}, coll: c, } store.MaxAge(maxAge) if ensur...
go
{ "resource": "" }
q172442
New
validation
func (m *MongoStore) New(r *http.Request, name string) ( *sessions.Session, error) { session := sessions.NewSession(m, name) session.Options = &sessions.Options{ Path: m.Options.Path, MaxAge: m.Options.MaxAge, Domain: m.Options.Domain, Secure: m.Options.Secure, HttpOnly: m.Options.HttpOnly, } s...
go
{ "resource": "" }
q172443
Push
validation
func (s *SegmentStack) Push(id int64) { s.Lock() defer s.Unlock() s.s = append(s.s, id) }
go
{ "resource": "" }
q172444
Pop
validation
func (s *SegmentStack) Pop() (int64, bool) { s.Lock() defer s.Unlock() if s.Len() == 0 { return rootSegment, false } id := s.s[s.Len()-1] s.s = s.s[:s.Len()-1] return id, true }
go
{ "resource": "" }
q172445
Peek
validation
func (s *SegmentStack) Peek() int64 { if s.Len() == 0 { return rootSegment } return s.s[s.Len()-1] }
go
{ "resource": "" }
q172446
RecordMetricsWithRecorder
validation
func RecordMetricsWithRecorder(r Recorder) { ticker := time.NewTicker(r.Interval()) go func() { for _ = range ticker.C { r.Record() } }() }
go
{ "resource": "" }
q172447
Init
validation
func Init(app, key string) { if _, err := sdk.InitEmbeddedMode(key, app); err != nil { panic(err) } }
go
{ "resource": "" }
q172448
errNo
validation
func errNo(i C.int) (int, error) { errno := int(i) if errno < 0 { errMsg := "unknown" if e, ok := errNoMap[errno]; ok { errMsg = e } return errno, errors.New(fmt.Sprintf("newrelic[%s]: %s", caller(), errMsg)) } return errno, nil }
go
{ "resource": "" }
q172449
caller
validation
func caller() string { name := "unknown" if pc, _, _, ok := runtime.Caller(1); ok { name = filepath.Base(runtime.FuncForPC(pc).Name()) } return name }
go
{ "resource": "" }
q172450
doInit
validation
func doInit(license string, appName string, language string, languageVersion string) (int, error) { clicense := C.CString(license) defer C.free(unsafe.Pointer(clicense)) cappName := C.CString(appName) defer C.free(unsafe.Pointer(cappName)) clang := C.CString("Go") defer C.free(unsafe.Pointer(clang)) clangVers...
go
{ "resource": "" }
q172451
RequestShutdown
validation
func RequestShutdown(reason string) (int, error) { creason := C.CString(reason) defer C.free(unsafe.Pointer(creason)) return errNo(C.newrelic_request_shutdown(creason)) }
go
{ "resource": "" }
q172452
NewTx
validation
func NewTx(name string) *tx { return &tx{ Tracer: &NRTxTracer{}, Reporter: &NRTxReporter{}, name: name, txnType: WebTransaction, ss: NewSegmentStack(), mtx: &sync.Mutex{}, } }
go
{ "resource": "" }
q172453
NewRequestTx
validation
func NewRequestTx(name string, url string) *tx { t := NewTx(name) t.url = url return t }
go
{ "resource": "" }
q172454
NewBackgroundTx
validation
func NewBackgroundTx(name string, category string) *tx { t := NewTx(name) t.txnType = OtherTransaction t.category = category return t }
go
{ "resource": "" }
q172455
Start
validation
func (t *tx) Start() (err error) { if t.id != 0 { return ErrTxAlreadyStarted } if t.id, err = t.Tracer.BeginTransaction(); err != nil { return err } if err = t.Tracer.SetTransactionName(t.id, t.name); err != nil { return err } if err = t.Tracer.SetTransactionType(t.id, t.txnType); err != nil { return err...
go
{ "resource": "" }
q172456
End
validation
func (t *tx) End() error { t.mtx.Lock() defer t.mtx.Unlock() for t.ss.Peek() != rootSegment { t.EndSegment() // discarding errors? } return t.Tracer.EndTransaction(t.id) }
go
{ "resource": "" }
q172457
StartGeneric
validation
func (t *tx) StartGeneric(name string) error { t.mtx.Lock() defer t.mtx.Unlock() id, err := t.Tracer.BeginGenericSegment(t.id, t.ss.Peek(), name) if err != nil { return err } t.ss.Push(id) return nil }
go
{ "resource": "" }
q172458
StartDatastore
validation
func (t *tx) StartDatastore(table, operation, sql, rollupName string) error { t.mtx.Lock() defer t.mtx.Unlock() id, err := t.Tracer.BeginDatastoreSegment(t.id, t.ss.Peek(), table, operation, sql, rollupName) if err != nil { return err } t.ss.Push(id) return nil }
go
{ "resource": "" }
q172459
StartExternal
validation
func (t *tx) StartExternal(host, name string) error { t.mtx.Lock() defer t.mtx.Unlock() id, err := t.Tracer.BeginExternalSegment(t.id, t.ss.Peek(), host, name) if err != nil { return err } t.ss.Push(id) return nil }
go
{ "resource": "" }
q172460
EndSegment
validation
func (t *tx) EndSegment() error { t.mtx.Lock() defer t.mtx.Unlock() if id, ok := t.ss.Pop(); ok { return t.Tracer.EndSegment(t.id, id) } return nil }
go
{ "resource": "" }
q172461
ReportError
validation
func (t *tx) ReportError(exceptionType, errorMessage, stackTrace, stackFrameDelim string) error { t.mtx.Lock() defer t.mtx.Unlock() _, err := t.Reporter.ReportError(t.id, exceptionType, errorMessage, stackTrace, stackFrameDelim) return err }
go
{ "resource": "" }
q172462
WithTx
validation
func WithTx(ctx context.Context, t Tx) context.Context { return context.WithValue(ctx, txKey, t) }
go
{ "resource": "" }
q172463
FromContext
validation
func FromContext(ctx context.Context) (Tx, bool) { t, ok := ctx.Value(txKey).(Tx) return t, ok }
go
{ "resource": "" }
q172464
TraceExternal
validation
func TraceExternal(ctx context.Context, host, name string) *Trace { return trace(ctx, name, func(tx Tx) error { return tx.StartExternal(host, name) }) }
go
{ "resource": "" }
q172465
TraceGeneric
validation
func TraceGeneric(ctx context.Context, name string) *Trace { return trace(ctx, name, func(tx Tx) error { return tx.StartGeneric(name) }) }
go
{ "resource": "" }
q172466
TraceDatastore
validation
func TraceDatastore(ctx context.Context, table, operation, sql, rollupName string) *Trace { return trace(ctx, rollupName, func(tx Tx) error { return tx.StartDatastore(table, operation, sql, rollupName) }) }
go
{ "resource": "" }
q172467
trace
validation
func trace(ctx context.Context, name string, fn func(Tx) error) *Trace { if tx, ok := FromContext(ctx); ok { err := fn(tx) return &Trace{ err: err, done: func() error { return tx.EndSegment() }, } } return &Trace{nil, func() error { return nil }} }
go
{ "resource": "" }
q172468
Serve
validation
func Serve(urlPrefix string, fs ServeFileSystem) gin.HandlerFunc { fileserver := http.FileServer(fs) if urlPrefix != "" { fileserver = http.StripPrefix(urlPrefix, fileserver) } return func(c *gin.Context) { if fs.Exists(urlPrefix, c.Request.URL.Path) { fileserver.ServeHTTP(c.Writer, c.Request) c.Abort() ...
go
{ "resource": "" }
q172469
Purge
validation
func (c *LRU) Purge() { for k := range c.items { delete(c.items, k) } c.evictList.Init() }
go
{ "resource": "" }
q172470
RemoveOldest
validation
func (c *LRU) RemoveOldest() (key string, value uint64, ok bool) { ent := c.evictList.Back() if ent != nil { c.removeElement(ent) kv := ent.Value.(*entry) return kv.key, kv.value, true } return "", 0, false }
go
{ "resource": "" }
q172471
Keys
validation
func (c *LRU) Keys() []string { keys := make([]string, len(c.items)) i := 0 for ent := c.evictList.Back(); ent != nil; ent = ent.Prev() { keys[i] = ent.Value.(*entry).key i++ } return keys }
go
{ "resource": "" }
q172472
removeElement
validation
func (c *LRU) removeElement(e *list.Element) { c.evictList.Remove(e) kv := e.Value.(*entry) delete(c.items, kv.key) }
go
{ "resource": "" }
q172473
DefaultCluster
validation
func DefaultCluster() *Cluster { return &Cluster{ hosts: make([]*URI, 0), okList: make([]bool, 0), mutex: &sync.RWMutex{}, } }
go
{ "resource": "" }
q172474
NewClusterWithHost
validation
func NewClusterWithHost(hosts ...*URI) *Cluster { cluster := DefaultCluster() for _, host := range hosts { cluster.AddHost(host) } return cluster }
go
{ "resource": "" }
q172475
AddHost
validation
func (c *Cluster) AddHost(address *URI) { c.mutex.Lock() defer c.mutex.Unlock() c.hosts = append(c.hosts, address) c.okList = append(c.okList, true) }
go
{ "resource": "" }
q172476
Host
validation
func (c *Cluster) Host() *URI { c.mutex.Lock() var host *URI for i := range c.okList { idx := (i + c.lastHostIdx) % len(c.okList) ok := c.okList[idx] if ok { host = c.hosts[idx] break } } c.lastHostIdx++ c.mutex.Unlock() if host != nil { return host } c.reset() return host }
go
{ "resource": "" }
q172477
RemoveHost
validation
func (c *Cluster) RemoveHost(address *URI) { c.mutex.Lock() defer c.mutex.Unlock() for i, uri := range c.hosts { if uri.Equals(address) { c.okList[i] = false break } } }
go
{ "resource": "" }
q172478
Hosts
validation
func (c *Cluster) Hosts() []URI { hosts := make([]URI, 0, len(c.hosts)) for i, host := range c.hosts { if c.okList[i] { hosts = append(hosts, *host) } } return hosts }
go
{ "resource": "" }
q172479
Less
validation
func (b Column) Less(other Record) bool { if ob, ok := other.(Column); ok { if b.RowID == ob.RowID { return b.ColumnID < ob.ColumnID } return b.RowID < ob.RowID } return false }
go
{ "resource": "" }
q172480
Less
validation
func (v FieldValue) Less(other Record) bool { if ov, ok := other.(FieldValue); ok { return v.ColumnID < ov.ColumnID } return false }
go
{ "resource": "" }
q172481
Index
validation
func (s *Schema) Index(name string, options ...IndexOption) *Index { if index, ok := s.indexes[name]; ok { return index } indexOptions := &IndexOptions{} indexOptions.addOptions(options...) return s.indexWithOptions(name, 0, indexOptions) }
go
{ "resource": "" }
q172482
Indexes
validation
func (s *Schema) Indexes() map[string]*Index { result := make(map[string]*Index) for k, v := range s.indexes { result[k] = v.copy() } return result }
go
{ "resource": "" }
q172483
HasIndex
validation
func (s *Schema) HasIndex(indexName string) bool { _, ok := s.indexes[indexName] return ok }
go
{ "resource": "" }
q172484
NewPQLBaseQuery
validation
func NewPQLBaseQuery(pql string, index *Index, err error) *PQLBaseQuery { return &PQLBaseQuery{ index: index, pql: pql, err: err, hasKeys: index.options.keys, } }
go
{ "resource": "" }
q172485
Add
validation
func (q *PQLBatchQuery) Add(query PQLQuery) { err := query.Error() if err != nil { q.err = err } serializedQuery := query.Serialize() q.hasKeys = q.hasKeys || serializedQuery.HasWriteKeys() q.queries = append(q.queries, serializedQuery.String()) }
go
{ "resource": "" }
q172486
NewPQLRowQuery
validation
func NewPQLRowQuery(pql string, index *Index, err error) *PQLRowQuery { return &PQLRowQuery{ index: index, pql: pql, err: err, hasKeys: index.options.keys, } }
go
{ "resource": "" }
q172487
String
validation
func (io IndexOptions) String() string { mopt := map[string]interface{}{} if io.keysSet { mopt["keys"] = io.keys } if io.trackExistenceSet { mopt["trackExistence"] = io.trackExistence } return fmt.Sprintf(`{"options":%s}`, encodeMap(mopt)) }
go
{ "resource": "" }
q172488
OptIndexKeys
validation
func OptIndexKeys(keys bool) IndexOption { return func(options *IndexOptions) { options.keys = keys options.keysSet = true } }
go
{ "resource": "" }
q172489
OptIndexTrackExistence
validation
func OptIndexTrackExistence(trackExistence bool) IndexOption { return func(options *IndexOptions) { options.trackExistence = trackExistence options.trackExistenceSet = true } }
go
{ "resource": "" }
q172490
NewIndex
validation
func NewIndex(name string) *Index { options := &IndexOptions{} return &Index{ name: name, options: options.withDefaults(), fields: map[string]*Field{}, } }
go
{ "resource": "" }
q172491
Fields
validation
func (idx *Index) Fields() map[string]*Field { result := make(map[string]*Field) for k, v := range idx.fields { result[k] = v.copy() } return result }
go
{ "resource": "" }
q172492
HasField
validation
func (idx *Index) HasField(fieldName string) bool { _, ok := idx.fields[fieldName] return ok }
go
{ "resource": "" }
q172493
Field
validation
func (idx *Index) Field(name string, options ...FieldOption) *Field { if field, ok := idx.fields[name]; ok { return field } fieldOptions := &FieldOptions{} fieldOptions = fieldOptions.withDefaults() fieldOptions.addOptions(options...) return idx.fieldWithOptions(name, fieldOptions) }
go
{ "resource": "" }
q172494
BatchQuery
validation
func (idx *Index) BatchQuery(queries ...PQLQuery) *PQLBatchQuery { stringQueries := make([]string, 0, len(queries)) hasKeys := false for _, query := range queries { serializedQuery := query.Serialize() hasKeys = hasKeys || serializedQuery.HasWriteKeys() stringQueries = append(stringQueries, serializedQuery.Str...
go
{ "resource": "" }
q172495
RawQuery
validation
func (idx *Index) RawQuery(query string) *PQLBaseQuery { q := NewPQLBaseQuery(query, idx, nil) // NOTE: raw queries always assumed to have keys set q.hasKeys = true return q }
go
{ "resource": "" }
q172496
Intersect
validation
func (idx *Index) Intersect(rows ...*PQLRowQuery) *PQLRowQuery { if len(rows) < 1 { return NewPQLRowQuery("", idx, NewError("Intersect operation requires at least 1 row")) } return idx.rowOperation("Intersect", rows...) }
go
{ "resource": "" }
q172497
Not
validation
func (idx *Index) Not(row *PQLRowQuery) *PQLRowQuery { return NewPQLRowQuery(fmt.Sprintf("Not(%s)", row.serialize()), idx, row.Error()) }
go
{ "resource": "" }
q172498
Count
validation
func (idx *Index) Count(row *PQLRowQuery) *PQLBaseQuery { serializedQuery := row.serialize() q := NewPQLBaseQuery(fmt.Sprintf("Count(%s)", serializedQuery.String()), idx, nil) q.hasKeys = q.hasKeys || serializedQuery.HasWriteKeys() return q }
go
{ "resource": "" }
q172499
Options
validation
func (idx *Index) Options(row *PQLRowQuery, opts ...OptionsOption) *PQLBaseQuery { oo := &OptionsOptions{} for _, opt := range opts { opt(oo) } text := fmt.Sprintf("Options(%s,%s)", row.serialize(), oo.marshal()) return NewPQLBaseQuery(text, idx, nil) }
go
{ "resource": "" }