Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function random_label to utilize PRNG for random string generation #4564

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions test/src/unit-capi-array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ struct ArrayFx {
void create_dense_vector(const std::string& path);
void create_dense_array(const std::string& path);
void write_fragment(tiledb_array_t* array, uint64_t timestamp);
static std::string random_name(const std::string& prefix);
bekadavis9 marked this conversation as resolved.
Show resolved Hide resolved
static int get_fragment_timestamps(const char* path, void* data);
};

Expand Down Expand Up @@ -141,13 +140,6 @@ void ArrayFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string ArrayFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

int ArrayFx::get_fragment_timestamps(const char* path, void* data) {
auto data_vec = (std::vector<uint64_t>*)data;
std::pair<uint64_t, uint64_t> timestamp_range;
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-array_schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB, Inc.
* @copyright Copyright (c) 2017-2023 TileDB, Inc.
* @copyright Copyright (c) 2016 MIT and Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -123,7 +123,6 @@ struct ArraySchemaFx {
void delete_array(const std::string& path);
bool is_array(const std::string& path);
void load_and_check_array_schema(const std::string& path);
static std::string random_name(const std::string& prefix);

int array_create_wrapper(
const std::string& path, tiledb_array_schema_t* array_schema);
Expand Down Expand Up @@ -945,13 +944,6 @@ void ArraySchemaFx::load_and_check_array_schema(const std::string& path) {
tiledb_array_schema_free(&array_schema);
}

std::string ArraySchemaFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

int ArraySchemaFx::get_schema_file_struct(const char* path, void* data) {
auto data_struct = (ArraySchemaFx::schema_file_struct*)data;
auto ctx = data_struct->ctx;
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2021 TileDB Inc.
* @copyright Copyright (c) 2021-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -77,7 +77,6 @@ struct Attributesfx {
const std::string& path,
const std::string& attr_name,
tiledb_datatype_t attr_type);
static std::string random_name(const std::string& prefix);
};

Attributesfx::Attributesfx()
Expand Down Expand Up @@ -105,13 +104,6 @@ void Attributesfx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string Attributesfx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void Attributesfx::create_dense_vector(
const std::string& path,
const std::string& attr_name,
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-dense_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
* @copyright Copyright (c) 2016 MIT and Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -150,7 +150,6 @@ struct DenseArrayFx {
const tiledb_layout_t layout,
std::vector<TestRange>& ranges,
std::vector<uint64_t>& a1);
static std::string random_name(const std::string& prefix);

/**
* Creates a 2D dense array.
Expand Down Expand Up @@ -3094,13 +3093,6 @@ void DenseArrayFx::check_non_empty_domain(const std::string& path) {
tiledb_array_free(&array);
};

std::string DenseArrayFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

TEST_CASE_METHOD(
DenseArrayFx,
"C API: Test dense array, sorted reads",
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-dense_neg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -76,7 +76,6 @@ struct DenseNegFx {
void read_dense_array_global(const std::string& path);
void read_dense_array_row(const std::string& path);
void read_dense_array_col(const std::string& path);
static std::string random_name(const std::string& prefix);
};

DenseNegFx::DenseNegFx()
Expand Down Expand Up @@ -104,13 +103,6 @@ void DenseNegFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string DenseNegFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void DenseNegFx::create_dense_vector(const std::string& path) {
int rc;
int64_t dim_domain[] = {-1, 2};
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-dense_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -72,7 +72,6 @@ struct DenseVectorFx {
void check_update(const std::string& path);
void create_temp_dir(const std::string& path);
void remove_temp_dir(const std::string& path);
static std::string random_name(const std::string& prefix);
};

DenseVectorFx::DenseVectorFx()
Expand Down Expand Up @@ -100,13 +99,6 @@ void DenseVectorFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string DenseVectorFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void DenseVectorFx::create_dense_vector(
const std::string& path,
tiledb_layout_t cell_order,
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB Inc.
* @copyright Copyright (c) 2022-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -84,7 +84,6 @@ struct GroupFx {
void remove_temp_dir(const std::string& path) const;
std::string get_golden_walk(const std::string& path);
std::string get_golden_ls(const std::string& path);
static std::string random_name(const std::string& prefix);
std::vector<std::pair<tiledb::sm::URI, tiledb_object_t>> read_group(
tiledb_group_t* group, bool use_get_member_by_index_v2 = true) const;
void set_group_timestamp(
Expand Down Expand Up @@ -359,13 +358,6 @@ std::string GroupFx::get_golden_ls(const std::string& path) {
return golden;
}

std::string GroupFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

TEST_CASE_METHOD(
GroupFx, "C API: Test group metadata", "[capi][group][metadata]") {
// TODO: refactor for each supported FS.
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-object_mgmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -74,7 +74,6 @@ struct ObjectMgmtFx {
std::string get_golden_walk(const std::string& path);
std::string get_golden_ls(const std::string& path);
static int write_path(const char* path, tiledb_object_t type, void* data);
static std::string random_name(const std::string& prefix);
};

ObjectMgmtFx::ObjectMgmtFx()
Expand Down Expand Up @@ -357,13 +356,6 @@ int ObjectMgmtFx::write_path(
return 1;
}

std::string ObjectMgmtFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

TEST_CASE_METHOD(
ObjectMgmtFx,
"C API: Test object management methods: object_type, delete, move",
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB, Inc.
* @copyright Copyright (c) 2017-2023 TileDB, Inc.
* @copyright Copyright (c) 2016 MIT and Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -71,7 +71,6 @@ struct QueryFx {
void test_get_buffer_write_decoupled(const std::string& path);
void test_get_buffer_read(const std::string& path);
void test_get_buffer_read_decoupled(const std::string& path);
static std::string random_name(const std::string& prefix);
};

QueryFx::QueryFx()
Expand All @@ -87,13 +86,6 @@ QueryFx::~QueryFx() {
tiledb_ctx_free(&ctx_);
}

std::string QueryFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void QueryFx::create_temp_dir(const std::string& path) {
remove_temp_dir(path);
REQUIRE(tiledb_vfs_create_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
Expand Down
3 changes: 1 addition & 2 deletions test/src/unit-capi-rest-dense_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
* @copyright Copyright (c) 2016 MIT and Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -98,7 +98,6 @@ struct DenseArrayRESTFx {
void create_dense_array_1_attribute(const std::string& array_name);
void write_dense_array(const std::string& array_name);
void write_dense_array_missing_attributes(const std::string& array_name);
static std::string random_name(const std::string& prefix);

/**
* Creates a 2D dense array.
Expand Down
8 changes: 0 additions & 8 deletions test/src/unit-capi-sparse_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ struct SparseArrayFx {
const std::vector<float>& a3);
void create_temp_dir(const std::string& path);
void remove_temp_dir(const std::string& path);
static std::string random_name(const std::string& prefix);
void check_sorted_reads(
const std::string& array_name,
tiledb_filter_type_t compressor,
Expand Down Expand Up @@ -261,13 +260,6 @@ void SparseArrayFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string SparseArrayFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void SparseArrayFx::create_sparse_array_2D(
const std::string& array_name,
const int64_t tile_extent_0,
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-sparse_heter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -118,7 +118,6 @@ struct SparseHeterFx {
const std::vector<int64_t>& buff_d1,
const std::vector<float>& buff_d2,
const std::vector<int32_t>& buff_a);
static std::string random_name(const std::string& prefix);
int tiledb_array_get_non_empty_domain_from_index_wrapper(
tiledb_ctx_t* ctx,
tiledb_array_t* array,
Expand Down Expand Up @@ -322,13 +321,6 @@ void SparseHeterFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string SparseHeterFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void SparseHeterFx::check_non_empty_domain_float_int64(
const std::string& path,
const float* dom_f,
Expand Down
10 changes: 1 addition & 9 deletions test/src/unit-capi-sparse_neg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB Inc.
* @copyright Copyright (c) 2017-2023 TileDB Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -74,7 +74,6 @@ struct SparseNegFx {
void read_sparse_array_global(const std::string& path);
void read_sparse_array_row(const std::string& path);
void read_sparse_array_col(const std::string& path);
static std::string random_name(const std::string& prefix);
};

SparseNegFx::SparseNegFx()
Expand Down Expand Up @@ -102,13 +101,6 @@ void SparseNegFx::remove_temp_dir(const std::string& path) {
REQUIRE(tiledb_vfs_remove_dir(ctx_, vfs_, path.c_str()) == TILEDB_OK);
}

std::string SparseNegFx::random_name(const std::string& prefix) {
std::stringstream ss;
ss << prefix << "-" << std::this_thread::get_id() << "-"
<< TILEDB_TIMESTAMP_NOW_MS;
return ss.str();
}

void SparseNegFx::create_sparse_vector(const std::string& path) {
int rc;
int64_t dim_domain[] = {-1, 2};
Expand Down
Loading
Loading