Documentation
¶
Index ¶
- type BufferPool
- type IndexScanner
- type IndexScannerImpl
- func (is *IndexScannerImpl) InitBuffers()
- func (is *IndexScannerImpl) ScanDocumentReader(docPath string, r ScipReader) error
- func (is *IndexScannerImpl) ScanIndexFile(path string) error
- func (is *IndexScannerImpl) ScanIndexFolder(path string, parallel bool) error
- func (is *IndexScannerImpl) ScanIndexReader(r ScipReader) error
- type ScipReader
- type SyncPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool is a wrapper for sync.Pool that returns variable size buffers. It uses a set of sync.Pools under the hood to bucket the buffers (defined by the startSize and sizeCount). Buffer requests beyond the underlying sync pool will be one-off allocations. Ideally a consumer picks a set of pools/sizes that minimizes the amount of one-off allocations.
func NewBufferPool ¶
func NewBufferPool(startSize, sizeCnt int) *BufferPool
NewBufferPool creates a new BufferPool. startSize indicates the initial bucket's size, which gets doubled for the subsequent buckets, up to the number defined in sizeCnt.
func (*BufferPool) Get ¶
func (bp *BufferPool) Get(size int) []byte
Get returns a buffer of a specific size.
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buf []byte)
Put discards a specific size bufer back into the pools.
type IndexScanner ¶
type IndexScanner interface {
ScanIndexFile(file string) error
ScanIndexFolder(folder string, parallel bool) error
ScanIndexReader(reader ScipReader) error
ScanDocumentReader(relativeDocPath string, reader ScipReader) error
}
IndexScanner defines the ways an index can be read.
type IndexScannerImpl ¶
type IndexScannerImpl struct {
MatchDocumentPath func(string) bool
MatchSymbol func([]byte) bool
MatchOccurrence func([]byte) bool
// TODO(IDE-1335): Implement MatchExternalSymbol
// MatchExternalSymbol func([]byte) bool
VisitDocument func(*scip.Document)
VisitSymbol func(string, *scip.SymbolInformation)
VisitOccurrence func(string, *scip.Occurrence)
VisitExternalSymbol func(*scip.SymbolInformation)
Pool *BufferPool
MaxConcurrency int
}
IndexScannerImpl implements the IndexScanner interface. A consumer can instantiate this implementation and implement any subset of the Match* methods, and (optionally) the matching Visit* method. After instantiating the struct, the consumer SHALL call .InitBuffers() Performance Considerations:
- When multiple IndexScannerImpl's are expected to be instantiated at the same time, a shared BufferPool can be provided to the struct's Pool property. This improves performance and memory consumption.
- The Match* methods use []byte's for performance reasons.
- The Visit* method will only be called if: the Visit* method is defined AND the Match* function returns true
- Should the consumer only require the monikers (symbol IDs), using the Visit* method and returning false is the recommended method.
- Consider the size of the indices, there's an order of magnitude more occurrences than symbols, and more symbols than documents. So if a consumer Matches & Visits every occurrence, or document the performance gains over a traditional proto parser will be limited.
func (*IndexScannerImpl) InitBuffers ¶
func (is *IndexScannerImpl) InitBuffers()
InitBuffers initializes the relevant buffers, and pools
func (*IndexScannerImpl) ScanDocumentReader ¶
func (is *IndexScannerImpl) ScanDocumentReader(docPath string, r ScipReader) error
ScanDocumentReader scans through an individual document. This requires the path of the document only to pass into VisitSymbol/Occurrence methods.
func (*IndexScannerImpl) ScanIndexFile ¶
func (is *IndexScannerImpl) ScanIndexFile(path string) error
ScanIndexFile scans an individual index file.
func (*IndexScannerImpl) ScanIndexFolder ¶
func (is *IndexScannerImpl) ScanIndexFolder(path string, parallel bool) error
ScanIndexFolder scans an entire folder's indices. Good to use when the consumer needs to scan through a bunch of indices for specific symbols.
func (*IndexScannerImpl) ScanIndexReader ¶
func (is *IndexScannerImpl) ScanIndexReader(r ScipReader) error
ScanIndexReader incrementally processes an index by reading input from the io.Reader It skips over any other fields defined in the SCIP index.
type ScipReader ¶
ScipReader defines the minimum interface required for a reader to be passed into the IndexScanner