github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/query/algorithm.hpp (about)

     1  //  Copyright (c) 2017-2018 Uber Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  #ifndef QUERY_ALGORITHM_HPP_
    16  #define QUERY_ALGORITHM_HPP_
    17  #include <cuda_runtime.h>
    18  #include <thrust/device_vector.h>
    19  #include <thrust/execution_policy.h>
    20  #include <thrust/host_vector.h>
    21  #include <thrust/system/cuda/execution_policy.h>
    22  #include <cfloat>
    23  #include <cstdint>
    24  #include <algorithm>
    25  #include <type_traits>
    26  #include "query/functor.hpp"
    27  #include "query/iterator.hpp"
    28  #include "query/time_series_aggregate.h"
    29  #include "query/utils.hpp"
    30  
    31  void CheckCUDAError(const char *message);
    32  
    33  namespace ares {
    34  
    35  class HashLookupContext;
    36  
    37  int hashLookup(HashLookupContext ctx, RecordID *output,
    38                 InputVector input, uint32_t *indexVector,
    39                 uint32_t *baseCounts, uint32_t startCount);
    40  
    41  // bind to ctx's bindNext function for further class bindings.
    42  template<typename TransformContext>
    43  int transform(TransformContext ctx, OutputVector output,
    44                InputVector input, uint32_t *indexVector,
    45                uint32_t *baseCounts, uint32_t startCount);
    46  
    47  // filter simply binds uint8_t* as the output iterator type.
    48  template<typename TransformContext>
    49  int filter(TransformContext ctx, InputVector input,
    50             uint32_t *indexVector, RecordID **foreignTableRecordIDVectors,
    51             uint8_t *boolVector, uint32_t *baseCounts, uint32_t startCount);
    52  
    53  // reduce binds aggregate function type and data type from
    54  // aggFunc.
    55  int reduce(DimensionColumnVector inputKeys, uint8_t *inputValues,
    56             DimensionColumnVector outputKeys, uint8_t *outputValues,
    57             int valueBytes, int length, AggregateFunction aggFunc,
    58             cudaStream_t cudaStream);
    59  
    60  // sort binds KeyIter type from keys.
    61  void sort(DimensionColumnVector keys, int length, cudaStream_t cudaStream);
    62  
    63  // expand function is used to uncompress the compressed dimension keys and
    64  // append to outputKeys.
    65  int expand(DimensionColumnVector inputKeys,
    66             DimensionColumnVector outputKeys,
    67             uint32_t *baseCounts,
    68             uint32_t *indexVector,
    69             int indexVectorLen,
    70             int outputOccupiedLen,
    71             cudaStream_t cudaStream);
    72  
    73  // hyperloglog.
    74  int hyperloglog(DimensionColumnVector prevDimOut,
    75                  DimensionColumnVector curDimOut, uint32_t *prevValuesOut,
    76                  uint32_t *curValuesOut, int prevResultSize, int curBatchSize,
    77                  bool isLastBatch, uint8_t **hllVectorPtr,
    78                  size_t *hllVectorSizePtr, uint16_t **hllDimRegIDCountPtr,
    79                  cudaStream_t cudaStream);
    80  
    81  // write geo shape index to dim output.
    82  void write_geo_shape_dim(int shapeTotalWords,
    83      DimensionOutputVector dimOut, int indexVectorLength,
    84      uint32_t *outputPredicate, cudaStream_t cudaStream);
    85  
    86  }  // namespace ares
    87  
    88  #endif  // QUERY_ALGORITHM_HPP_