Skip to content

Commit

Permalink
address Eric's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisStaratzis committed Jun 14, 2024
1 parent eccb87d commit 9113c9d
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 79 deletions.
8 changes: 0 additions & 8 deletions tiledb/sm/misc/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@
namespace tiledb {
namespace sm {

/** Class for generic status exceptions. */
class GenericException : public StatusException {
public:
explicit GenericException(const std::string& msg)
: StatusException("Generic", msg) {
}
};

using namespace tiledb::common;

class Posix;
Expand Down
54 changes: 34 additions & 20 deletions tiledb/sm/serialization/array_schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#include "tiledb/sm/filter/webp_filter.h"
#include "tiledb/sm/filter/xor_filter.h"
#include "tiledb/sm/misc/constants.h"
#include "tiledb/sm/misc/utils.h"
#include "tiledb/sm/serialization/array_schema.h"
#include "tiledb/sm/serialization/enumeration.h"

Expand All @@ -78,6 +77,21 @@
using namespace tiledb::common;

namespace tiledb::sm::serialization {
class ArraySchemaSerializationException : public StatusException {
public:
explicit ArraySchemaSerializationException(const std::string& message)
: StatusException("[TileDB::Serialization][ArraySchema]", message) {
}
};

class ArraySchemaSerializationDisabledException
: public ArraySchemaSerializationException {
public:
explicit ArraySchemaSerializationDisabledException()
: ArraySchemaSerializationException(
"Cannot (de)serialize; serialization not enabled.") {
}
};

#ifdef TILEDB_SERIALIZATION

Expand Down Expand Up @@ -358,7 +372,7 @@ tuple<Status, optional<shared_ptr<FilterPipeline>>> filter_pipeline_from_capnp(
void attribute_to_capnp(
const Attribute* attribute, capnp::Attribute::Builder* attribute_builder) {
if (attribute == nullptr) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing attribute; attribute is null.");
}

Expand Down Expand Up @@ -771,7 +785,7 @@ void dimension_label_to_capnp(
if (dimension_label.uri_is_relative()) {
dim_label_builder->setUri(dimension_label.uri().to_string());
} else {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"[Serialization::dimension_label_to_capnp] Serialization of absolute "
"dimension label URIs not yet implemented.");
}
Expand All @@ -798,7 +812,7 @@ shared_ptr<DimensionLabel> dimension_label_from_capnp(

auto is_relative = dim_label_reader.getRelative();
if (!is_relative) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"[Deserialization::dimension_label_from_capnp] Deserialization of "
"absolute dimension label URIs not yet implemented.");
}
Expand Down Expand Up @@ -1863,18 +1877,18 @@ void serialize_load_array_schema_request(
break;
}
default: {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema request; "
"Unknown serialization type passed");
}
}

} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema request; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema request; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -1908,17 +1922,17 @@ LoadArraySchemaRequest deserialize_load_array_schema_request(
return load_array_schema_request_from_capnp(reader);
}
default: {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema request; "
"Unknown serialization type passed");
}
}
} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema request; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema request; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -1964,18 +1978,18 @@ void serialize_load_array_schema_response(
break;
}
default: {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema response; "
"Unknown serialization type passed");
}
}

} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema response; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error serializing load array schema response; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -2013,17 +2027,17 @@ shared_ptr<ArraySchema> deserialize_load_array_schema_response(
return load_array_schema_response_from_capnp(reader, memory_tracker);
}
default: {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema response; "
"Unknown serialization type passed");
}
}
} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema response; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ArraySchemaSerializationException(
"Error deserializing load array schema response; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -2082,22 +2096,22 @@ Status max_buffer_sizes_deserialize(

void serialize_load_array_schema_request(
const Config&, const LoadArraySchemaRequest&, SerializationType, Buffer&) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ArraySchemaSerializationDisabledException();
}

LoadArraySchemaRequest deserialize_load_array_schema_request(
SerializationType, const Buffer&) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ArraySchemaSerializationDisabledException();
}

void serialize_load_array_schema_response(
const ArraySchema&, SerializationType, Buffer&) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ArraySchemaSerializationDisabledException();
}

shared_ptr<ArraySchema> deserialize_load_array_schema_response(
SerializationType, const Buffer&, shared_ptr<MemoryTracker>) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ArraySchemaSerializationDisabledException();
}

#endif // TILEDB_SERIALIZATION
Expand Down
49 changes: 32 additions & 17 deletions tiledb/sm/serialization/consolidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

#include "tiledb/common/logger_public.h"
#include "tiledb/sm/enums/serialization_type.h"
#include "tiledb/sm/misc/utils.h"
#include "tiledb/sm/serialization/config.h"
#include "tiledb/sm/serialization/consolidation.h"

Expand All @@ -54,6 +53,22 @@ namespace tiledb {
namespace sm {
namespace serialization {

class ConsolidationSerializationException : public StatusException {
public:
explicit ConsolidationSerializationException(const std::string& message)
: StatusException("[TileDB::Serialization][Consolidation]", message) {
}
};

class ConsolidationSerializationDisabledException
: public ConsolidationSerializationException {
public:
explicit ConsolidationSerializationDisabledException()
: ConsolidationSerializationException(
"Cannot (de)serialize; serialization not enabled.") {
}
};

#ifdef TILEDB_SERIALIZATION

Status array_consolidation_request_to_capnp(
Expand Down Expand Up @@ -270,18 +285,18 @@ void serialize_consolidation_plan_request(
break;
}
default: {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan request; "
"Unknown serialization type passed");
}
}

} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan request; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan request; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -311,17 +326,17 @@ uint64_t deserialize_consolidation_plan_request(
return consolidation_plan_request_from_capnp(reader);
}
default: {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan request; "
"Unknown serialization type passed");
}
}
} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan request; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan request; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -361,18 +376,18 @@ void serialize_consolidation_plan_response(
break;
}
default: {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan response; "
"Unknown serialization type passed");
}
}

} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan response; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error serializing consolidation plan response; exception " +
std::string(e.what()));
}
Expand Down Expand Up @@ -402,17 +417,17 @@ std::vector<std::vector<std::string>> deserialize_consolidation_plan_response(
return consolidation_plan_response_from_capnp(reader);
}
default: {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan response; "
"Unknown serialization type passed");
}
}
} catch (kj::Exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan response; kj::Exception: " +
std::string(e.getDescription().cStr()));
} catch (std::exception& e) {
throw SerializationStatusException(
throw ConsolidationSerializationException(
"Error deserializing consolidation plan response; exception " +
std::string(e.what()));
}
Expand All @@ -434,22 +449,22 @@ Status array_consolidation_request_deserialize(

void serialize_consolidation_plan_request(
uint64_t, const Config&, SerializationType, Buffer&) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ConsolidationSerializationDisabledException();
}

uint64_t deserialize_consolidation_plan_request(
SerializationType, const Buffer&) {
throw GenericException("Cannot deserialize; serialization not enabled.");
throw ConsolidationSerializationDisabledException();
}

void serialize_consolidation_plan_response(
const ConsolidationPlan&, SerializationType, Buffer&) {
throw GenericException("Cannot serialize; serialization not enabled.");
throw ConsolidationSerializationDisabledException();
}

std::vector<std::vector<std::string>> deserialize_consolidation_plan_response(
SerializationType, const Buffer&) {
throw GenericException("Cannot deserialize; serialization not enabled.");
throw ConsolidationSerializationDisabledException();
}

#endif // TILEDB_SERIALIZATION
Expand Down
Loading

0 comments on commit 9113c9d

Please sign in to comment.