MCPcopy
hub / github.com/uber/aresdb / prefilterSlice

Method prefilterSlice

query/aql_processor.go:915–966  ·  view source on GitHub ↗

prefilterSlice does the following: 1. binary search for prefilter values following the matched sort column order 2. record matched index range on these matched sort columns 3. binary search on unmatched compressed columns for the row number range 4. index slice on uncompressed columns for the row nu

(vp memCom.ArchiveVectorParty, prefilterIndex, startRow, endRow int)

Source from the content-addressed store, hash-verified

913// 4. index slice on uncompressed columns for the row number range
914// 5. align/pad all slices to be pushed
915func (qc *AQLQueryContext) prefilterSlice(vp memCom.ArchiveVectorParty, prefilterIndex, startRow, endRow int) (int, int, memCom.HostVectorPartySlice) {
916 startIndex, endIndex := 0, vp.GetLength()
917
918 unmatchedColumn := false
919 scanner := qc.TableScanners[0]
920 if prefilterIndex < len(scanner.EqualityPrefilterValues) {
921 // matched equality filter
922 filterValue := scanner.EqualityPrefilterValues[prefilterIndex]
923 startRow, endRow, startIndex, endIndex = vp.SliceByValue(startRow, endRow, unsafe.Pointer(&filterValue))
924 } else if prefilterIndex == len(scanner.EqualityPrefilterValues) {
925 // matched range filter
926 // lower bound
927 filterValue := scanner.RangePrefilterValues[0]
928 boundaryType := scanner.RangePrefilterBoundaries[0]
929
930 if boundaryType != noBoundary {
931 lowerStartRow, lowerEndRow, lowerStartIndex, lowerEndIndex := vp.SliceByValue(startRow, endRow, unsafe.Pointer(&filterValue))
932 if boundaryType == inclusiveBoundary {
933 startRow, startIndex = lowerStartRow, lowerStartIndex
934 } else {
935 startRow, startIndex = lowerEndRow, lowerEndIndex
936 }
937 } else {
938 // treat as unmatchedColumn when there is one range filter missing
939 unmatchedColumn = true
940 }
941
942 // SliceByValue of upperBound
943 filterValue = scanner.RangePrefilterValues[1]
944 boundaryType = scanner.RangePrefilterBoundaries[1]
945 if boundaryType != noBoundary {
946 upperStartRow, upperEndRow, upperStartIndex, upperEndIndex := vp.SliceByValue(startRow, endRow, unsafe.Pointer(&filterValue))
947 if boundaryType == inclusiveBoundary {
948 endRow, endIndex = upperEndRow, upperEndIndex
949 } else {
950 endRow, endIndex = upperStartRow, upperStartIndex
951 }
952 } else {
953 // treat as unmatchedColumn when there is one range filter missing
954 unmatchedColumn = true
955 }
956 } else {
957 unmatchedColumn = true
958 }
959
960 if unmatchedColumn {
961 // unmatched columns, simply slice based on row number range
962 startIndex, endIndex = vp.SliceIndex(startRow, endRow)
963 }
964
965 return startRow, endRow, vp.(memstore.TransferableVectorParty).GetHostVectorPartySlice(startIndex, endIndex-startIndex)
966}
967
968// calculateMemoryRequirement estimate memory requirement for batch data.
969func (qc *AQLQueryContext) calculateMemoryRequirement(memStore memstore.MemStore) int {

Callers 3

transferArchiveBatchMethod · 0.95

Calls 4

GetLengthMethod · 0.65
SliceByValueMethod · 0.65
SliceIndexMethod · 0.65

Tested by

no test coverage detected