id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c162100
dm.Fields == nil { dm.Fields = make([]*FieldMapping, 0) } dm.Fields = append(dm.Fields, fm) }
c162101
start = r.onlyPos r.onlyPos++ } // inidicate if we got to the end of the list return r.onlyPos < len(r.only) }
c162102
rv.currKs[i], rv.currVs[i] = itr.Current() } rv.updateMatches(false) if rv.lowK == nil && len(rv.lowIdxs) == 0 { return rv, vellum.ErrIteratorDone } return rv, nil }
c162103
0 { // reached a new low m.lowK = key m.lowIdxs = m.lowIdxs[:0] m.lowIdxs = append(m.lowIdxs, i) } else if cmp == 0 { m.lowIdxs = append(m.lowIdxs, i) } } }
c162104
if rv == nil { rv = err } } return rv }
c162105
itr, ok := tfr.iterators[i].(*zap.PostingsIterator) if !ok { return nil, nil } docNum, ok := itr.DocNum1Hit() if ok { docNums = append(docNums, uint32(docNum)) continue } if itr.ActualBM != nil { actualBMs = append(actualBMs, itr.ActualBM) } } var bm *roaring.Bitmap if len...
c162106
{ return numeric.Interleave(scaleLon(lon), scaleLat(lat)) }
c162107
a - b if math.Abs(compare) <= geoTolerance { return 0 } return compare }
c162108
|| aMinX > bMaxX || aMaxY < bMinY || aMinY > bMaxY) }
c162109
|| aMinY < bMinY || aMaxX > bMaxX || aMaxY > bMaxY) return rv }
c162110
return 0, false } // trade read lock for write lock f.mutex.RUnlock() f.mutex.Lock() // need to check again with write lock if index, ok := f.fieldIndexes[field]; ok { f.mutex.Unlock() return index, true } // assign next field id index := f.addLOCKED(field, uint16(f.lastFieldIndex+1)) f.mutex.Unlock() r...
c162111
return "" } s = s.Sub[0] } if s.Op == syntax.OpLiteral { return string(s.Rune) } return "" // no literal prefix }
c162112
range unit.suffixes { if u == unitSuffix { return unit.conv, nil } } } return 0, fmt.Errorf("unknown distance unit: %s", u) }
c162113
h2 := 1 - cos((lon1-lon2)*degreesToRadian) h := (h1 + cos(x1)*cos(x2)*h2) / 2 avgLat := (x1 + x2) / 2 diameter := earthDiameter(avgLat) return diameter * asin(math.Min(1, math.Sqrt(h))) }
c162114
!= nil { return nil, nil, err } return i.i, s, nil }
c162115
if !i.open { return ErrorIndexClosed } doc := document.NewDocument(id) err = i.m.MapDocument(doc, data) if err != nil { return } err = i.i.Update(doc) return }
c162116
if !i.open { return ErrorIndexClosed } err = i.i.Update(doc) return }
c162117
if !i.open { return ErrorIndexClosed } err = i.i.Delete(id) return }
c162118
ErrorIndexClosed } return i.i.Batch(b.internal) }
c162119
func() { if cerr := indexReader.Close(); err == nil && cerr != nil { err = cerr } }() doc, err = indexReader.Document(id) if err != nil { return nil, err } return doc, nil }
c162120
reader %v", err) } defer func() { if cerr := indexReader.Close(); err == nil && cerr != nil { err = cerr } }() count, err = indexReader.DocCount() return }
c162121
return i.SearchInContext(context.Background(), req) }
c162122
SearchResult estimate += reflectStaticSizeSearchResult + reflectStaticSizeSearchStatus // overhead from facet results if req.Facets != nil { estimate += len(req.Facets) * facetResultEmptySize } // highlighting, store if len(req.Fields) > 0 || req.Highlight != nil { // Size + From => number of hits estima...
c162123
{ if cerr := indexReader.Close(); err == nil && cerr != nil { err = cerr } }() fields, err = indexReader.Fields() if err != nil { return nil, err } return fields, nil }
c162124
internal: index.NewBatch(), } }
c162125
entries[entry] = struct{}{} ret = append(ret, entry) } } return ret }
c162126
boxSearcher, err := NewDisjunctionSearcher(indexReader, []search.Searcher{leftSearcher, rightSearcher}, 0, options) if err != nil { _ = leftSearcher.Close() _ = rightSearcher.Close() return nil, err } return boxSearcher, nil } // build geoboundinggox searcher for that bounding box boxSearcher,...
c162127
&indexAliasImpl{ name: "alias", indexes: indexes, open: true, } }
c162128
sr.Hits = sr.Hits[req.From:] } else if req.From > 0 { sr.Hits = search.DocumentMatchCollection{} } // now trim to the correct size if req.Size > 0 && len(sr.Hits) > req.Size { sr.Hits = sr.Hits[0:req.Size] } // fix up facets for name, fr := range req.Facets { sr.Facets.Fixup(name, fr.Size) } // fix u...
c162129
mm: mm, path: path, refs: 1, } rv.SegmentBase.updateSize() err = rv.loadConfig() if err != nil { _ = rv.Close() return nil, err } err = rv.loadFields() if err != nil { _ = rv.Close() return nil, err } err = rv.loadDvReaders() if err != nil { _ = rv.Close() return nil, err } return rv...
c162130
dict == nil { return &segment.EmptyDictionary{}, nil } return dict, err }
c162131
{ vdc := visitDocumentCtxPool.Get().(*visitDocumentCtx) defer visitDocumentCtxPool.Put(vdc) return s.visitDocument(vdc, num, visitor) }
c162132
vdc.reader.Reset(meta) // handle _id field special case idFieldValLen, err := binary.ReadUvarint(&vdc.reader) if err != nil { return nil, err } idFieldVal := compressed[:idFieldValLen] visitDocumentCtxPool.Put(vdc) return idFieldVal, nil }
c162133
if id <= sMaxStr { filteredIds = append(filteredIds, id) } } for _, id := range filteredIds { postingsList, err = idDict.postingsList([]byte(id), nil, postingsList) if err != nil { return nil, err } postingsList.OrInto(rv) } } return rv, nil }
c162134
such field '%s'", field) } return s.dictLocs[fieldIDPlus1-1], nil }
c162135
{ return query.NewTermRangeQuery(min, max) }
c162136
return query.NewTermRangeInclusiveQuery(min, max, minInclusive, maxInclusive) }
c162137
query.NewGeoBoundingBoxQuery(topLeftLon, topLeftLat, bottomRightLon, bottomRightLat) }
c162138
query.NewGeoDistanceQuery(lon, lat, distance) }
c162139
len(fields)) for _, field := range fields { if _, ok := f[field]; !ok { rv = append(rv, field) } } return rv }
c162140
copy over from empty TermFieldDoc (0 allocations) *tfd = TermFieldDoc{} // reuse the []byte already allocated (and reset len to 0) tfd.ID = id[:0] tfd.Vectors = vectors[:0] return tfd }
c162141
return s } return o.FloorSegmentSize }
c162142
budgetNumSegments += int(math.Ceil(segmentsInTier)) break } budgetNumSegments += maxSegmentsPerTier totalSize -= int64(maxSegmentsPerTier) * tierSize tierSize = int64(float64(tierSize) * tierGrowth) } return budgetNumSegments }
c162143
over bigger ones. We don't want to // make the exponent too large else we end up with poor merges of // small segments in order to avoid the large merges. score := balance * math.Pow(float64(totAfterSize), 0.05) // Strongly favor merges that reclaim deletes. nonDelRatio := float64(totAfterSize) / float64(totBef...
c162144
0) dm.IndexInternalID = indexInternalID[:0] // reuse the []interface{} already allocated (and reset len to 0) dm.Sort = sort[:0] // reuse the FieldTermLocations already allocated (and reset len to 0) dm.FieldTermLocations = ftls[:0] return dm }
c162145
// might be duplicates that need to be deduplicated if !needsDedupe && len(locs) > 0 { last := locs[len(locs)-1] cmp := loc.ArrayPositions.Compare(last.ArrayPositions) if cmp < 0 || (cmp == 0 && loc.Pos <= last.Pos) { needsDedupe = true } } tlm[ftl.Term] = append(locs, loc) dm.Field...
c162146
float64(len(earthDiameterPerLatitude))) if math.IsNaN(index) { return 0 } return earthDiameterPerLatitude[int(index)] }
c162147
{ segmentBases := make([]*SegmentBase, len(segments)) for segmenti, segment := range segments { segmentBases[segmenti] = &segment.SegmentBase } return MergeSegmentBases(segmentBases, drops, path, chunkFactor, closeCh, s) }
c162148
len(fields)) for i, fieldName := range fields { rv[fieldName] = uint16(i) + 1 } return rv }
c162149
segment.numDocs if drops[segI] != nil { newDocCount -= drops[segI].GetCardinality() } } return newDocCount }
c162150
err := s.convert() if err != nil { return nil, uint64(0), err } sb, err := InitSegmentBase(br.Bytes(), s.w.Sum32(), chunkFactor, s.FieldsMap, s.FieldsInv, uint64(len(results)), storedIndexOffset, fieldsIndexOffset, fdvIndexOffset, dictOffsets) if err == nil && s.reset() == nil { s.lastNumDocs = len(res...
c162151
snapshot.epoch, creator: "persistSnapshotMaybeMerge", } // copy to the equiv the segments that weren't replaced for _, segment := range snapshot.segment { if _, wasMerged := mergedSegmentIDs[segment.id]; !wasMerged { equiv.segment = append(equiv.segment, segment) } } // append to the equiv the new s...
c162152
return 0, err } defer func() { if err == nil { err = tx.Commit() } else { _ = tx.Rollback() } if err == nil { err = s.rootBolt.Sync() } }() snapshots := tx.Bucket(boltSnapshotsBucket) if snapshots == nil { return 0, nil } for _, epochToRemove := range epochsToRemove { k := segment.Enco...
c162153
chunkLens: make([]uint64, total), chunkMeta: make([]MetaData, 0, total), w: w, progressiveWrite: progressiveWrite, } return rv }
c162154
c.chunkMetaBuf.Reset() for i := range c.chunkLens { c.chunkLens[i] = 0 } c.chunkMeta = c.chunkMeta[:0] }
c162155
start = metaHeaders[chunk-1].DocDvOffset } return start, metaHeaders[chunk].DocDvOffset }
c162156
Field: field, Size: size, } }
c162157
fr.DateTimeRanges = append(fr.DateTimeRanges, &dateTimeRange{Name: name, startString: start, endString: end}) }
c162158
r.Facets = make(FacetsRequest, 1) } r.Facets[facetName] = f }
c162159
search.ParseSortOrderStrings(order) r.Sort = so }
c162160
10 } else { r.Size = *temp.Size } if temp.Sort == nil { r.Sort = search.SortOrder{&search.SortScore{Desc: true}} } else { r.Sort, err = search.ParseSortOrderJSON(temp.Sort) if err != nil { return err } } r.From = temp.From r.Explain = temp.Explain r.Highlight = temp.Highlight r.Fields = temp.Fiel...
c162161
from, Explain: explain, Sort: search.SortOrder{&search.SortScore{Desc: true}}, } }
c162162
tmp[k] = v.Error() } return json.Marshal(tmp) }
c162163
make(map[string]error) } for otherIndex, otherError := range other.Errors { ss.Errors[otherIndex] = otherError } } }
c162164
nil && len(other.Facets) != 0 { sr.Facets = other.Facets return } sr.Facets.Merge(other.Facets) }
c162165
var fr search.FacetResult estimate += len(req.Facets) * fr.Size() } // highlighting, store var d document.Document if len(req.Fields) > 0 || req.Highlight != nil { for i := 0; i < (req.Size + req.From); i++ { estimate += (req.Size + req.From) * d.Size() } } return uint64(estimate) }
c162166
rv.Must = NewConjunctionQuery(must) } if len(should) > 0 { rv.Should = NewDisjunctionQuery(should) } if len(mustNot) > 0 { rv.MustNot = NewDisjunctionQuery(mustNot) } return &rv }
c162167
float64) { q.Should.(*DisjunctionQuery).SetMin(minShould) }
c162168
b, err := strconv.ParseBool(v); err == nil && b { return true } } } return false }
c162169
hc.store = newStoreSlice(backingSize, func(i, j *search.DocumentMatch) int { return hc.sort.Compare(hc.cachedScoring, hc.cachedDesc, i, j) }) } // these lookups traverse an interface, so do once up-front if sort.RequiresDocID() { hc.needDocIds = true } hc.neededFields = sort.RequiredFields() hc.cachedS...
c162170
} hc.needDocIds = hc.needDocIds || loadID select { case <-ctx.Done(): return ctx.Err() default: next, err = searcher.Next(searchContext) } for err == nil && next != nil { if hc.total%CheckDoneEvery == 0 { select { case <-ctx.Done(): return ctx.Err() default: } } err = hc.prepareDocum...
c162171
:= hc.dvReader.VisitDocValues(d.IndexInternalID, hc.updateFieldVisitor) if hc.facetsBuilder != nil { hc.facetsBuilder.EndDoc() } return err }
c162172
{ hc.facetsBuilder = facetsBuilder hc.neededFields = append(hc.neededFields, hc.facetsBuilder.RequiredFields()...) }
c162173
return hc.facetsBuilder.Results() } return nil }
c162174
err != nil { return nil, err } vals[i] = val } return vals, nil }
c162175
o, ok := s.searchers[0].(index.Optimizable) if ok { return o.Optimize(kind, octx) } } return octx, nil }
c162176
case *DisjunctionQuery: children, err := expandSlice(q.Disjuncts) if err != nil { return nil, err } q.Disjuncts = children return q, nil case *BooleanQuery: var err error q.Must, err = expand(q.Must) if err != nil { return nil, err } q.Should, err = expand(q.Should) if err !...
c162177
if err != nil { return "", err } data, err := json.MarshalIndent(q, "", " ") return string(data), err }
c162178
chunkSize, chunkLens: make([]uint64, total), final: make([]byte, 0, 64), } return rv }
c162179
c.currChunk = 0 for i := range c.chunkLens { c.chunkLens[i] = 0 } }
c162180
for _, chunkOffset := range chunkOffsets { n += binary.PutUvarint(buf[n:], chunkOffset) } tw, err := w.Write(buf[:n]) if err != nil { return tw, err } // write out the data nw, err := w.Write(c.final) tw += nw if err != nil { return tw, err } return tw, nil }
c162181
cv := make([]byte, len(val)) copy(cv, val) row, err := ParseFromKeyValue(ck, cv) if err != nil { rv <- err return } rv <- row it.Next() key, val, valid = it.Current() } }
c162182
defer func() { cerr := it.Close() if cerr != nil { rv <- cerr } }() for _, key := range keys { it.Seek(key) rkey, rval, valid := it.Current() if !valid { break } rck := make([]byte, len(rkey)) copy(rck, key) rcv := make([]byte, len(rval)) copy(rcv, rval) ...
c162183
_, err := im.cache.DefineCharFilter(name, config) if err != nil { return err } im.CustomAnalysis.CharFilters[name] = config return nil }
c162184
_, err := im.cache.DefineTokenizer(name, config) if err != nil { return err } im.CustomAnalysis.Tokenizers[name] = config return nil }
c162185
_, err := im.cache.DefineTokenMap(name, config) if err != nil { return err } im.CustomAnalysis.TokenMaps[name] = config return nil }
c162186
_, err := im.cache.DefineTokenFilter(name, config) if err != nil { return err } im.CustomAnalysis.TokenFilters[name] = config return nil }
c162187
!= nil { return err } im.CustomAnalysis.DateTimeParsers[name] = config return nil }
c162188
IndexDynamic, StoreDynamic: StoreDynamic, DocValuesDynamic: DocValuesDynamic, CustomAnalysis: newCustomAnalysis(), cache: registry.NewCache(), } }
c162189
err != nil { return err } for _, docMapping := range im.TypeMapping { err = docMapping.Validate(im.cache) if err != nil { return err } } return nil }
c162190
*DocumentMapping) { im.TypeMapping[doctype] = dm }
c162191
} // next we will try default analyzers for the path pathDecoded := decodePath(path) for _, docMapping := range im.TypeMapping { rv := docMapping.defaultAnalyzerName(pathDecoded) if rv != "" { return rv } } return im.DefaultAnalyzer }
c162192
!= nil { preallocPI = pi } if preallocPI == emptyPostingsIterator { preallocPI = nil } return p.iterator(includeFreq, includeNorm, includeLocs, preallocPI) }
c162193
n = p.postings.GetCardinality() if p.except != nil { e = p.postings.AndCardinality(p.except) } } return n - e }
c162194
err := i.locReader.ReadUvarint() if err != nil { return fmt.Errorf("error reading location end: %v", err) } // read off num array pos numArrayPos, err := i.locReader.ReadUvarint() if err != nil { return fmt.Errorf("error reading location num array pos: %v", err) } l.field = i.postings.sb.fieldsInv[fieldID]...
c162195
return i.nextAtOrAfter(docNum) }
c162196
} rv.locs = i.nextSegmentLocs[:0] numLocsBytes, err := i.locReader.ReadUvarint() if err != nil { return nil, fmt.Errorf("error reading location numLocsBytes: %v", err) } j := 0 startBytesRemaining := i.locReader.Len() // # bytes remaining in the locReader for startBytesRemaining-i.locReader.Len() <...
c162197
endFreqNorm := len(i.currChunkFreqNorm) - i.freqNormReader.Len() bytesFreqNorm = i.currChunkFreqNorm[startFreqNorm:endFreqNorm] if hasLocs { startLoc := len(i.currChunkLoc) - i.locReader.Len() numLocsBytes, err := i.locReader.ReadUvarint() if err != nil { return 0, 0, 0, nil, nil, fmt.Errorf("error re...
c162198
!= DocNum1HitFinished { return p.docNum1Hit, true } return 0, false }
c162199
bm.Iterator(), includeFreqNorm: includeFreqNorm, includeLocs: includeLocs, }, nil }