message: adding binary sorting
diff: @@ -145,6 +145,35 @@ public:
  }
  };
  +class ArrowBinarySortKernel : public ArrowArraySortKernel {
  +public:
  + explicit ArrowBinarySortKernel(std::shared_ptr<arrow::DataType> type,
  + arrow::MemoryPool* pool) :
  + ArrowArraySortKernel(type, pool) {}
  +
  + int Sort(std::shared_ptr<arrow::Array> values,
  + std::shared_ptr<arrow::Array>* offsets) override {
  + auto array = std::static_pointer_cast<arrow::BinaryArray>(values);
  + std::shared_ptr<arrow::Buffer> indices_buf;
  + int64_t buf_size = values->length() * sizeof(uint64_t);
  + arrow::Status status = AllocateBuffer(arrow::default_memory_pool(), buf_size + 1, &indices_buf);
  + if (status != arrow::Status::OK()) {
  + LOG(FATAL) << "Failed to allocate sort indices - " << status.message();
  + return -1;
  + }
  + auto *indices_begin = reinterpret_cast<int64_t *>(indices_buf->mutable_data());
  + for (int64_t i = 0; i < values->length(); i++) {
  + indices_begin[i] = i;
  + }
  + int64_t *indices_end = indices_begin + values->length();
  + std::sort(indices_begin, indices_end, [array](uint64_t left, uint64_t right) {
  + return array->GetView(left).compare(array->GetView(right));
  + });
  + *offsets = std::make_shared<arrow::UInt64Array>(values->length(), indices_buf);
  + return 0;
  + }
  +};
  +
  int CreateSorter(std::shared_ptr<arrow::DataType> type,
  arrow::MemoryPool* pool,
  std::unique_ptr<ArrowArraySortKernel>* out) {
  @@ -183,6 +212,12 @@ int CreateSorter(std::shared_ptr<arrow::DataType> type,
  case arrow::Type::STRING:
  kernel = new ArrowStringSortKernel(type, pool);
  break;
  + case arrow::Type::BINARY:
  + kernel = new ArrowBinarySortKernel(type, pool);
  + break;
  + case arrow::Type::FIXED_SIZE_BINARY:
  + kernel = new ArrowBinarySortKernel(type, pool);
  + break;
  default:
  LOG(FATAL) << "Un-known type";
  return -1;
  