示例#1
0
Status VoltDBDriver::search(const ComplexQuery& query, vector<string>* files) {
  vector<voltdb::Parameter> param_types(3);
  param_types[0] = voltdb::Parameter(voltdb::WIRE_TYPE_STRING);
  param_types[1] = voltdb::Parameter(voltdb::WIRE_TYPE_BIGINT);
  param_types[2] = voltdb::Parameter(voltdb::WIRE_TYPE_BIGINT);
  voltdb::Procedure procedure("SearchFile", param_types);
  auto index_names = query.get_names_of_range_queries();
  auto name = index_names[0];
  const auto range_query  = query.range_query(name);
  int64_t lower = std::numeric_limits<int64_t>::min();
  int64_t upper = std::numeric_limits<int64_t>::max();
  if (!range_query->lower.empty()) {
    lower = std::stol(range_query->lower);
  }
  if (!range_query->upper.empty()) {
    upper = std::stol(range_query->upper);
  }
  voltdb::ParameterSet* params = procedure.params();
  params->addString(name).addInt64(lower).addInt64(upper);
  auto response = client_->client.invoke(procedure);
  if (response.failure()) {
    LOG(ERROR) << "Failed to search files: " << response.toString();
  }
  auto count = response.results()[0].rowCount();
  files->reserve(count);
  auto iter = response.results()[0].iterator();
  for (int i = 0; i < count; i++) {
    auto row = iter.next();
    files->push_back(row.getString(0));
  }
  return Status::OK;
}
示例#2
0
文件: main.cpp 项目: AnyDSL/impala
const impala::Type* llvm2impala(impala::TypeTable& tt, llvm::Type* type) {
    if (auto int_type = llvm::dyn_cast<llvm::IntegerType>(type)) {
        switch (int_type->getBitWidth()) {
            case  1: return tt.type_bool();
            case  8: return tt.type_i8();
            case 16: return tt.type_i16();
            case 32: return tt.type_i32();
            case 64: return tt.type_i64();
            default: return nullptr;
        }
    }

    if (type->isHalfTy())   return tt.type_f16();
    if (type->isFloatTy())  return tt.type_f32();
    if (type->isDoubleTy()) return tt.type_f64();

    if (auto ptr = llvm::dyn_cast<llvm::PointerType>(type)) {
        auto elem = llvm2impala(tt, ptr->getElementType());
        return elem == nullptr ? nullptr : tt.borrowed_ptr_type(elem, false, ptr->getAddressSpace());
    }

    if (auto vector_type = llvm::dyn_cast<llvm::VectorType>(type)) {
        auto elem = llvm2impala(tt, vector_type->getElementType());
        return elem == nullptr ? nullptr : tt.simd_type(elem, vector_type->getNumElements());
    }

    if (auto struct_type = llvm::dyn_cast<llvm::StructType>(type)) {
        std::vector<const impala::Type*> args;

        for (auto elem : struct_type->elements()) {
            args.push_back(llvm2impala(tt, elem));
            if (args.back() == nullptr)
                return nullptr;
        }

        return tt.tuple_type(args);
    }

    if (auto fn = llvm::dyn_cast<llvm::FunctionType>(type)) {
        std::vector<const impala::Type*> param_types(fn->getNumParams()+1);
        for (size_t i = 0, e = fn->getNumParams(); i != e; ++i) {
            auto t = llvm2impala(tt, fn->getParamType(i));
            if (!t)
                return nullptr;
            param_types[i] = t;
        }

        auto ret = fn->getReturnType()->isVoidTy() ? (const impala::Type*)tt.unit() : llvm2impala(tt, fn->getReturnType());
        if (!ret)
            return nullptr;
        param_types.back() = fn->getReturnType()->isVoidTy() ? tt.fn_type(tt.unit()) : tt.fn_type(ret);
        return tt.fn_type(param_types);
    }

    return nullptr;
}
示例#3
0
Status VoltDBDriver::import(const vector<string>& files) {
  vector<voltdb::Parameter> param_types(2);
  param_types[0] = voltdb::Parameter(voltdb::WIRE_TYPE_BIGINT);
  param_types[1] = voltdb::Parameter(voltdb::WIRE_TYPE_STRING);
  voltdb::Procedure procedure("FILE_META.insert", param_types);
  for (const auto& file : files) {
    voltdb::ParameterSet* params = procedure.params();
    auto hash = PathUtil::path_to_hash(file);
    params->addInt64(hash).addString(file);
    auto response = client_->client.invoke(procedure);
    if (response.failure()) {
      LOG(ERROR) << "Failed to insert file: " << response.toString();
    }
  }
  return Status::OK;
}
示例#4
0
Status VoltDBDriver::insert(const RecordVector& records) {
  // Insert into Big Single Index Table.
  vector<voltdb::Parameter> param_types(3);
  param_types[0] = voltdb::Parameter(voltdb::WIRE_TYPE_STRING);
  param_types[1] = voltdb::Parameter(voltdb::WIRE_TYPE_STRING);
  param_types[2] = voltdb::Parameter(voltdb::WIRE_TYPE_BIGINT);
  voltdb::Procedure procedure("BIG_INDEX_TABLE_UINT64.insert", param_types);
  voltdb::ParameterSet* params = procedure.params();

  boost::shared_ptr<EmptyCallback> callback(new EmptyCallback);
  for (const auto& record : records) {
    // TODO(eddyxu): batch insert.
    string file_path, index_name;
    uint64_t key;
    std::tie(file_path, index_name, key) = record;
    params->addString(file_path).addString(index_name).addInt64(key);
    client_->client.invoke(procedure, callback);
  }
  while (!client_->client.drain()) {}
  return Status::OK;
}
 Attribute_Access(T Class::* t_attr)
   : Proxy_Function_Base(param_types()),
   m_attr(t_attr)
 {
 }