Skip to content

Commit

Permalink
Revert "Max empty values for signed primitives" (#1831) (#1834)
Browse files Browse the repository at this point in the history
This reverts commit 1b641b0.

Co-authored-by: Joe Maley <[email protected]>
Co-authored-by: Isaiah Norton <[email protected]>

Co-authored-by: joe maley <[email protected]>
Co-authored-by: Joe Maley <[email protected]>
Co-authored-by: Isaiah Norton <[email protected]>
  • Loading branch information
4 people authored Sep 30, 2020
1 parent ad42855 commit c32e897
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 71 deletions.
1 change: 0 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
## Breaking behavior

* Empty dense arrays now return cells with fill values. Also the result estimator is adjusted to work properly with this new behavior.
* Empty char and signed integers now return their maximum value for empty cells instead of their minimum value.

## New features

Expand Down
18 changes: 9 additions & 9 deletions test/src/unit-capi-consolidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1713,25 +1713,25 @@ void ConsolidationFx::read_dense_vector(uint64_t timestamp) {
if (timestamp >= 1)
c_a[i] = i;
else
c_a[i] = 2147483647;
c_a[i] = -2147483648;
}
for (int i = 200; i < 250; ++i) {
if (timestamp >= 2)
c_a[i] = i;
else
c_a[i] = 2147483647;
c_a[i] = -2147483648;
}
for (int i = 250; i < 310; ++i) {
if (timestamp >= 3)
c_a[i] = i;
else
c_a[i] = 2147483647;
c_a[i] = -2147483648;
}
for (int i = 310; i < 410; ++i) {
if (timestamp == 0 || timestamp >= 4)
c_a[i] = i;
else
c_a[i] = 2147483647;
c_a[i] = -2147483648;
}

// Open array
Expand Down Expand Up @@ -1793,10 +1793,10 @@ void ConsolidationFx::read_dense_vector_with_gaps() {
int c_a[410];
for (int i = 0; i < 410; ++i)
c_a[i] = i;
c_a[200] = INT_MAX;
c_a[201] = INT_MAX;
c_a[308] = INT_MAX;
c_a[309] = INT_MAX;
c_a[200] = INT_MIN;
c_a[201] = INT_MIN;
c_a[308] = INT_MIN;
c_a[309] = INT_MIN;

// Open array
tiledb_array_t* array;
Expand Down Expand Up @@ -1982,7 +1982,7 @@ void ConsolidationFx::read_dense_vector_consolidatable_2() {
for (int i = 0; i < 100; ++i)
c_a[i] = i;
for (int i = 100; i < 200; ++i)
c_a[i] = INT_MAX;
c_a[i] = INT_MIN;
for (int i = 200; i < 300; ++i)
c_a[i] = i + 1;

Expand Down
84 changes: 42 additions & 42 deletions test/src/unit-capi-dense_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4039,22 +4039,22 @@ TEST_CASE_METHOD(

// Read whole array
uint64_t subarray_read[] = {1, 4, 1, 4};
int c_a1[] = {INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
int c_a1[] = {INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
1,
2,
INT_MAX,
INT_MAX,
INT_MIN,
INT_MIN,
3,
4,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX};
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN};
int read_a1[16];
uint64_t read_a1_size = sizeof(read_a1);
rc = tiledb_array_alloc(ctx_, array_name.c_str(), &array);
Expand Down Expand Up @@ -4135,22 +4135,22 @@ TEST_CASE_METHOD(

// Read whole array
uint64_t subarray_read[] = {1, 4, 1, 4};
int c_a1[] = {INT_MAX,
int c_a1[] = {INT_MIN,
1,
INT_MAX,
INT_MIN,
4,
2,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
3,
INT_MAX};
INT_MIN};
uint64_t c_coords_dim1[] = {1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
uint64_t c_coords_dim2[] = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4};
int read_a1[16];
Expand Down Expand Up @@ -4239,22 +4239,22 @@ TEST_CASE_METHOD(

// Read whole array
uint64_t subarray_read[] = {1, 4, 1, 4};
int c_a1[] = {INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
int c_a1[] = {INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
1,
2,
INT_MAX,
INT_MAX,
INT_MIN,
INT_MIN,
3,
4,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX};
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN};
int read_a1[16];
uint64_t read_a1_size = sizeof(read_a1);
rc = tiledb_array_alloc(ctx_, array_name.c_str(), &array);
Expand Down Expand Up @@ -4357,14 +4357,14 @@ TEST_CASE_METHOD(
101,
102,
8,
INT_MAX,
INT_MIN,
103,
104,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX,
INT_MAX};
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN,
INT_MIN};
int read_a[16];
uint64_t read_a_size = sizeof(read_a);
rc = tiledb_array_alloc(ctx_, array_name.c_str(), &array);
Expand Down
14 changes: 7 additions & 7 deletions test/src/unit-capi-fill_values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ TEST_CASE(
const void* value_ptr;
rc = tiledb_attribute_get_fill_value(ctx, a, &value_ptr, &value_size);
CHECK(rc == TILEDB_OK);
CHECK(*(const int32_t*)value_ptr == 2147483647);
CHECK(*(const int32_t*)value_ptr == -2147483648);
CHECK(value_size == sizeof(int32_t));

// Check dump
std::string dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: 1\n" +
"- Filters: 0\n" + "- Fill value: 2147483647\n";
"- Filters: 0\n" + "- Fill value: -2147483648\n";
check_dump(ctx, a, dump);

// Correct setter
Expand All @@ -118,14 +118,14 @@ TEST_CASE(
CHECK(rc == TILEDB_OK);
rc = tiledb_attribute_get_fill_value(ctx, a, &value_ptr, &value_size);
CHECK(rc == TILEDB_OK);
CHECK(((const int32_t*)value_ptr)[0] == 2147483647);
CHECK(((const int32_t*)value_ptr)[1] == 2147483647);
CHECK(((const int32_t*)value_ptr)[0] == -2147483648);
CHECK(((const int32_t*)value_ptr)[1] == -2147483648);
CHECK(value_size == 2 * sizeof(int32_t));

// Check dump
dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: 2\n" + "- Filters: 0\n" +
"- Fill value: 2147483647, 2147483647\n";
"- Fill value: -2147483648, -2147483648\n";
check_dump(ctx, a, dump);

// Set a fill value that is comprised of two integers
Expand Down Expand Up @@ -153,13 +153,13 @@ TEST_CASE(
// Check dump
dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: var\n" + "- Filters: 0\n" +
"- Fill value: 2147483647\n";
"- Fill value: -2147483648\n";
check_dump(ctx, a, dump);

// Get the default var-sized fill value
rc = tiledb_attribute_get_fill_value(ctx, a, &value_ptr, &value_size);
CHECK(rc == TILEDB_OK);
CHECK(*(const int32_t*)value_ptr == 2147483647);
CHECK(*(const int32_t*)value_ptr == -2147483648);
CHECK(value_size == sizeof(int32_t));

// Set a new fill value for the var-sized attribute
Expand Down
14 changes: 7 additions & 7 deletions test/src/unit-cppapi-fill_values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ TEST_CASE(
// Get default
const void* value_ptr;
CHECK_NOTHROW(a.get_fill_value(&value_ptr, &value_size));
CHECK(*(const int32_t*)value_ptr == 2147483647);
CHECK(*(const int32_t*)value_ptr == -2147483648);
CHECK(value_size == sizeof(int32_t));

// Check dump
std::string dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: 1\n" +
"- Filters: 0\n" + "- Fill value: 2147483647\n";
"- Filters: 0\n" + "- Fill value: -2147483648\n";
check_dump(a, dump);

// Correct setter
Expand All @@ -268,14 +268,14 @@ TEST_CASE(
// Setting the cell val num, also sets the fill value to a new default
CHECK_NOTHROW(a.set_cell_val_num(2));
CHECK_NOTHROW(a.get_fill_value(&value_ptr, &value_size));
CHECK(((const int32_t*)value_ptr)[0] == 2147483647);
CHECK(((const int32_t*)value_ptr)[1] == 2147483647);
CHECK(((const int32_t*)value_ptr)[0] == -2147483648);
CHECK(((const int32_t*)value_ptr)[1] == -2147483648);
CHECK(value_size == 2 * sizeof(int32_t));

// Check dump
dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: 2\n" + "- Filters: 0\n" +
"- Fill value: 2147483647, 2147483647\n";
"- Fill value: -2147483648, -2147483648\n";
check_dump(a, dump);

// Set a fill value that is comprised of two integers
Expand All @@ -300,12 +300,12 @@ TEST_CASE(
// Check dump
dump = std::string("### Attribute ###\n") + "- Name: a\n" +
"- Type: INT32\n" + "- Cell val num: var\n" + "- Filters: 0\n" +
"- Fill value: 2147483647\n";
"- Fill value: -2147483648\n";
check_dump(a, dump);

// Get the default var-sized fill value
CHECK_NOTHROW(a.get_fill_value(&value_ptr, &value_size));
CHECK(*(const int32_t*)value_ptr == 2147483647);
CHECK(*(const int32_t*)value_ptr == -2147483648);
CHECK(value_size == sizeof(int32_t));

// Set a new fill value for the var-sized attribute
Expand Down
10 changes: 5 additions & 5 deletions tiledb/sm/misc/constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ int coords_compression_level = -1;
const std::string filelock_name = "__lock.tdb";

/** The special value for an empty int32. */
const int empty_int32 = std::numeric_limits<int32_t>::max();
const int empty_int32 = std::numeric_limits<int32_t>::min();

/** The special value for an empty int64. */
const int64_t empty_int64 = std::numeric_limits<int64_t>::max();
const int64_t empty_int64 = std::numeric_limits<int64_t>::min();

/** The special value for an empty float32. */
const float empty_float32 = std::numeric_limits<float>::quiet_NaN();
Expand All @@ -123,16 +123,16 @@ const float empty_float32 = std::numeric_limits<float>::quiet_NaN();
const double empty_float64 = std::numeric_limits<double>::quiet_NaN();

/** The special value for an empty char. */
const char empty_char = std::numeric_limits<char>::max();
const char empty_char = std::numeric_limits<char>::min();

/** The special value for an empty int8. */
const int8_t empty_int8 = std::numeric_limits<int8_t>::max();
const int8_t empty_int8 = std::numeric_limits<int8_t>::min();

/** The special value for an empty uint8. */
const uint8_t empty_uint8 = std::numeric_limits<uint8_t>::max();

/** The special value for an empty int16. */
const int16_t empty_int16 = std::numeric_limits<int16_t>::max();
const int16_t empty_int16 = std::numeric_limits<int16_t>::min();

/** The special value for an empty uint16. */
const uint16_t empty_uint16 = std::numeric_limits<uint16_t>::max();
Expand Down

0 comments on commit c32e897

Please sign in to comment.