Skip to content

Commit

Permalink
Merge branch 'main' into yt/sc-59605/dont_block_io
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia authored Jan 30, 2025
2 parents c9aa97c + aa9b646 commit 4105c1a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 41 deletions.
19 changes: 1 addition & 18 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,9 @@ if [ "${linkage}" = "shared" ] && [ "${enable_static_tiledb}" = "ON" ]; then
die "cannot specify both --linkage=shared and --enable-static-tiledb"
fi

# Check clang compiler
if [[ x"${CC}" = x"" ]]; then
CC=gcc
fi

if [[ x"${CXX}" = x"" ]]; then
CXX=g++
fi

cmake=`which cmake`

if [[ ! -x ${cmake} ]]; then
die "cannot find cmake"
fi

# Configure
${cmake} -DCMAKE_BUILD_TYPE=${build_type} \
cmake -DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_INSTALL_PREFIX="${prefix_dirs}" \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_PREFIX_PATH="${dependency_dir}" \
-DBUILD_SHARED_LIBS=${build_shared_libs} \
-DTILEDB_ASSERTIONS=${tiledb_assertions} \
Expand Down
36 changes: 22 additions & 14 deletions test/src/unit-cppapi-schema-evolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2023-2024 TileDB Inc.
* @copyright Copyright (c) 2023-2025 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 @@ -806,21 +806,21 @@ TEST_CASE(
}
}

TEST_CASE(
"C++ API: SchemaEvolution, drop fixed attribute and add back as var-sized",
"[cppapi][schema][evolution][add][drop]") {
/**
* C++ API: SchemaEvolution, drop fixed attribute and add back as var-sized
*
* Wrapper function for the following test case of the same name.
* This logic has been moved into a function to resolve intermittent failures
* when using Catch2's GENERATE statements inline with code under test
* (https://app.shortcut.com/tiledb-inc/story/61528).
* We should re-evaluate when Catch2 is upgraded.
*/
void test_schema_evolution_drop_fixed_add_var(
tiledb_array_type_t array_type, tiledb_layout_t layout) {
test::VFSTestSetup vfs_test_setup;
Context ctx{vfs_test_setup.ctx()};
auto array_uri{
vfs_test_setup.array_uri("test_schema_evolution_drop_fixed_add_var")};
tiledb_array_type_t array_type = TILEDB_DENSE;
bool allows_dups = false;
auto layout = GENERATE(TILEDB_UNORDERED, TILEDB_GLOBAL_ORDER);

SECTION("sparse") {
array_type = TILEDB_SPARSE;
allows_dups = GENERATE(true, false);
}

// Create array
Domain domain(ctx);
Expand All @@ -830,8 +830,7 @@ TEST_CASE(
auto b = Attribute::create<int>(ctx, "b");
ArraySchema schema(ctx, array_type);
schema.set_domain(domain);
schema.set_allows_dups(allows_dups);
CHECK(allows_dups == schema.allows_dups());
schema.set_allows_dups(false);
schema.add_attribute(a);
schema.add_attribute(b);
schema.set_cell_order(TILEDB_ROW_MAJOR);
Expand Down Expand Up @@ -908,6 +907,15 @@ TEST_CASE(
Catch::Matchers::Equals(std::vector<int>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
}

TEST_CASE(
"C++ API: SchemaEvolution, drop fixed attribute and add back as var-sized",
"[cppapi][schema][evolution][add][drop]") {
test_schema_evolution_drop_fixed_add_var(TILEDB_DENSE, TILEDB_UNORDERED);
test_schema_evolution_drop_fixed_add_var(TILEDB_DENSE, TILEDB_GLOBAL_ORDER);
test_schema_evolution_drop_fixed_add_var(TILEDB_SPARSE, TILEDB_UNORDERED);
test_schema_evolution_drop_fixed_add_var(TILEDB_SPARSE, TILEDB_GLOBAL_ORDER);
}

TEST_CASE(
"SchemaEvolution Error Handling Tests",
"[cppapi][schema][evolution][errors][rest]") {
Expand Down
8 changes: 6 additions & 2 deletions tiledb/sm/filesystem/mem_filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ class MemFilesystem::File : public MemFilesystem::FSNode {
assert(buffer);

if (offset + nbytes > size_)
return LOG_STATUS(
Status_MemFSError("Cannot read from file; Read exceeds file size"));
return LOG_STATUS(Status_MemFSError(fmt::format(
"Cannot read from file; Read exceeds file size: offset {} nbytes {} "
"size_ {}",
offset,
nbytes,
size_)));

memcpy(buffer, (char*)data_ + offset, nbytes);
return Status::Ok();
Expand Down
11 changes: 9 additions & 2 deletions tiledb/sm/filesystem/posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,15 @@ void Posix::read(
auto path = uri.to_path();
uint64_t file_size;
this->file_size(URI(path), &file_size);
if (offset + nbytes > file_size)
throw IOError("Cannot read from file; Read exceeds file size");
if (offset + nbytes > file_size) {
throw IOError(fmt::format(
"Cannot read from file; Read exceeds file size: offset {}, nbytes {}, "
"file_size {}, URI {}",
offset,
nbytes,
file_size,
uri.to_path()));
}

// Open file
int fd = open(path.c_str(), O_RDONLY);
Expand Down
24 changes: 19 additions & 5 deletions tiledb/sm/filesystem/win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include "uri.h"
#include "win.h"

#include <fmt/format.h>

using namespace tiledb::common;
using tiledb::common::filesystem::directory_entry;

Expand Down Expand Up @@ -462,11 +464,23 @@ Status Win::read(
0) {
auto gle = GetLastError();
CloseHandle(file_h);
return LOG_STATUS(Status_IOError(
"Cannot read from file '" + path + "'; File read error " +
(gle != 0 ? get_last_error_msg(gle, "ReadFile") :
"num_bytes_read " + std::to_string(num_bytes_read) +
" != nbyes " + std::to_string(nbytes))));

std::string err_msg;
if (gle != 0) {
err_msg = get_last_error_msg(gle, "ReadFile");
} else {
err_msg = std::string("num_bytes_read ") +
std::to_string(num_bytes_read) + " != nbytes " +
std::to_string(nbytes);
}

return LOG_STATUS(Status_IOError(fmt::format(
"Cannot read from file '{}'; File read error '{}' offset {} nbytes "
"{}",
path,
err_msg,
offset,
nbytes)));
}
byte_buffer += num_bytes_read;
offset += num_bytes_read;
Expand Down

0 comments on commit 4105c1a

Please sign in to comment.