Skip to content

Commit

Permalink
Move some headers around to fix nightly build failures due to Windows…
Browse files Browse the repository at this point in the history
… includes. (#4179)

* Move `Azure::BlockListUploadState::next_block_id` to the implementation file.

* Move windows.h inclusion later in `unit-capi-array.cs`.

Fixes the nightly build failures.

---
TYPE: NO_HISTORY
  • Loading branch information
teo-tsirpanis authored Jul 20, 2023
1 parent c0d7c6a commit 3467385
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
14 changes: 10 additions & 4 deletions test/src/unit-capi-array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
#include "test/support/src/serialization_wrappers.h"
#include "test/support/src/vfs_helpers.h"
#ifdef _WIN32
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#include <Windows.h>
#include "tiledb/sm/filesystem/win.h"
#else
#include "tiledb/sm/filesystem/posix.h"
Expand All @@ -71,6 +67,16 @@
#include <sstream>
#include <thread>

#ifdef _WIN32
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
#endif

using namespace tiledb::test;
using namespace tiledb::common;
using namespace tiledb::sm;
Expand Down
24 changes: 24 additions & 0 deletions tiledb/sm/filesystem/azure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,30 @@ Status Azure::parse_azure_uri(
return Status::Ok();
}

/* Generates the next base64-encoded block id. */
std::string Azure::BlockListUploadState::next_block_id() {
const uint64_t block_id = next_block_id_++;
const std::string block_id_str = std::to_string(block_id);

// Pad the block id string with enough leading zeros to support
// the maximum number of blocks (50,000). All block ids must be
// of equal length among a single blob.
const int block_id_chars = 5;
std::vector<uint8_t> padded_block_id(
block_id_chars - block_id_str.length(), '0');
std::copy(
block_id_str.begin(),
block_id_str.end(),
std::back_inserter(padded_block_id));

const std::string b64_block_id_str =
::Azure::Core::Convert::Base64Encode(padded_block_id);

block_ids_.emplace_back(b64_block_id_str);

return b64_block_id_str;
}

} // namespace sm
} // namespace tiledb

Expand Down
25 changes: 1 addition & 24 deletions tiledb/sm/filesystem/azure.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#define TILEDB_AZURE_H

#ifdef HAVE_AZURE
#include <azure/core/base64.hpp>

#include "tiledb/common/common.h"
#include "tiledb/common/status.h"
#include "tiledb/common/thread_pool.h"
Expand Down Expand Up @@ -325,28 +323,7 @@ class Azure {
}

/* Generates the next base64-encoded block id. */
std::string next_block_id() {
const uint64_t block_id = next_block_id_++;
const std::string block_id_str = std::to_string(block_id);

// Pad the block id string with enough leading zeros to support
// the maximum number of blocks (50,000). All block ids must be
// of equal length among a single blob.
const int block_id_chars = 5;
std::vector<uint8_t> padded_block_id(
block_id_chars - block_id_str.length(), '0');
std::copy(
block_id_str.begin(),
block_id_str.end(),
std::back_inserter(padded_block_id));

const std::string b64_block_id_str =
::Azure::Core::Convert::Base64Encode(padded_block_id);

block_ids_.emplace_back(b64_block_id_str);

return b64_block_id_str;
}
std::string next_block_id();

/* Returns all generated block ids. */
std::list<std::string> get_block_ids() const {
Expand Down

0 comments on commit 3467385

Please sign in to comment.