Skip to content

Commit

Permalink
fix catch exception on empty specification properties
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandez committed Jun 14, 2016
1 parent 3b322ad commit 42caf47
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 30 deletions.
6 changes: 5 additions & 1 deletion hdt-lib/src/dictionary/FourSectionDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ FourSectionDictionary::FourSectionDictionary(HDTSpecification & spec) : blocksiz
objects = new csd::CSD_PFC();
shared = new csd::CSD_PFC();

string blockSizeStr = spec.get("dict.block.size");
string blockSizeStr = "";
try{
spec.get("dict.block.size");
}catch(exception& e){}

if(blockSizeStr!=""){
//blocksize = atoi((const char*)blockSizeStr.c_str());
}
Expand Down
6 changes: 5 additions & 1 deletion hdt-lib/src/dictionary/KyotoDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ KyotoDictionary::KyotoDictionary() {
}

KyotoDictionary::KyotoDictionary(HDTSpecification &specification) : spec(specification) {
if(spec.get("dictionary.mapping")=="mapping1") {
string map = ""
try{
map = spec.get("dictionary.mapping");
}catch(exception& e){}
if(map=="mapping1") {
this->mapping = MAPPING1;
} else {
this->mapping = MAPPING2;
Expand Down
5 changes: 4 additions & 1 deletion hdt-lib/src/dictionary/LiteralDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ LiteralDictionary::LiteralDictionary(HDTSpecification & spec) : blocksize(8) {
objectsLiterals = new csd::CSD_FMIndex();
shared = new csd::CSD_PFC();

string blockSizeStr = spec.get("dict.block.size");
string blockSizeStr = "";
try{
blockSizeStr = spec.get("dict.block.size");
}catch(exception& e){}
if (blockSizeStr != "") {
blocksize = atoi(blockSizeStr.c_str());
}
Expand Down
6 changes: 5 additions & 1 deletion hdt-lib/src/dictionary/PlainDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ PlainDictionary::PlainDictionary() {
}

PlainDictionary::PlainDictionary(HDTSpecification &specification) : spec(specification) {
if(spec.get("dictionary.mapping")=="mapping1") {
string map ="";
try{
map = spec.get("dictionary.mapping");
}catch(exception& e){}
if(map=="mapping1") {
this->mapping = MAPPING1;
} else {
this->mapping = MAPPING2;
Expand Down
30 changes: 26 additions & 4 deletions hdt-lib/src/hdt/BasicHDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ void BasicHDT::createComponents() {
header = new PlainHeader();

// DICTIONARY
std::string dictType = spec.get("dictionary.type");

std::string dictType = "";
try{
spec.get("dictionary.type");
}
catch (exception& e){
}

if(dictType==HDTVocabulary::DICTIONARY_TYPE_FOUR) {
dictionary = new FourSectionDictionary(spec);
} else if(dictType==HDTVocabulary::DICTIONARY_TYPE_PLAIN) {
Expand All @@ -110,7 +117,11 @@ void BasicHDT::createComponents() {
}

// TRIPLES
std::string triplesType = spec.get("triples.type");
std::string triplesType = "";
try{
triplesType = spec.get("triples.type");
}catch (exception& e) {
}
if(triplesType==HDTVocabulary::TRIPLES_TYPE_BITMAP) {
triples = new BitmapTriples(spec);
} else if(triplesType==HDTVocabulary::TRIPLES_TYPE_COMPACT) {
Expand Down Expand Up @@ -284,8 +295,13 @@ void BasicHDT::loadTriples(const char* fileName, const char* baseUri, RDFNotatio
triplesList->stopProcessing(&iListener);

// SORT & Duplicates
string ord = "";
try{
ord = spec.get("triplesOrder");
}catch (exception& e){
}
TripleComponentOrder order = parseOrder(
spec.get("triplesOrder").c_str());
ord.c_str());
if (order == Unknown) {
order = SPO;
}
Expand Down Expand Up @@ -557,7 +573,13 @@ void BasicHDT::loadTriplesFromHDTs(const char** fileNames, size_t numFiles, cons
triplesList->stopProcessing(&iListener);

// SORT & Duplicates
TripleComponentOrder order = parseOrder(spec.get("triplesOrder").c_str());
string ord = "";
try{
ord = spec.get("triplesOrder");
}
catch (exception& e){
}
TripleComponentOrder order = parseOrder(ord.c_str());
if (order == Unknown) {
order = SPO;
}
Expand Down
9 changes: 7 additions & 2 deletions hdt-lib/src/hdt/BasicModifiableHDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ BasicModifiableHDT::~BasicModifiableHDT() {
}

void BasicModifiableHDT::createComponents() {
std::string dictType = spec.get("dictionary.type");
std::string triplesType = spec.get("triples.type");
try{
std::string dictType = spec.get("dictionary.type");
std::string triplesType = spec.get("triples.type");
}
catch (exception& e)
{
}

// FIXME: SELECT
header = new PlainHeader();
Expand Down
26 changes: 21 additions & 5 deletions hdt-lib/src/triples/BitmapTriples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ namespace hdt {
#define CHECK_BITMAPTRIPLES_INITIALIZED if(bitmapY==NULL || bitmapZ==NULL){ throw "Accessing uninitialized BitmapTriples"; }

BitmapTriples::BitmapTriples() : order(SPO) {
arrayY = IntSequence::getArray(spec.get("stream.y"));
arrayZ = IntSequence::getArray(spec.get("stream.z"));
string typey="";
string typez="";
try{
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
arrayY = IntSequence::getArray(typey);
arrayZ = IntSequence::getArray(typez);
arrayIndex = NULL;
bitmapY = NULL;
bitmapZ = NULL;
Expand All @@ -55,12 +61,22 @@ BitmapTriples::BitmapTriples() : order(SPO) {
}

BitmapTriples::BitmapTriples(HDTSpecification &specification) : spec(specification) {
std::string orderStr = spec.get("triplesOrder");
std::string orderStr = "";
try{
orderStr = spec.get("triplesOrder");
}catch (exception& e){}

order= parseOrder(orderStr.c_str());
if(order==Unknown)
order = SPO;
arrayY = IntSequence::getArray(spec.get("stream.y"));
arrayZ = IntSequence::getArray(spec.get("stream.z"));
string typey="";
string typez="";
try{
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
arrayY = IntSequence::getArray(typey);
arrayZ = IntSequence::getArray(typez);
arrayIndex = NULL;
bitmapY = NULL;
bitmapZ = NULL;
Expand Down
26 changes: 20 additions & 6 deletions hdt-lib/src/triples/CompactTriples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,32 @@ namespace hdt {


CompactTriples::CompactTriples() : numTriples(0), order(SPO) {
streamY = IntSequence::getArray(spec.get("stream.y"));
streamZ = IntSequence::getArray(spec.get("stream.z"));
string typey="";
string typez="";
try{
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
streamY = IntSequence::getArray(typey);
streamZ = IntSequence::getArray(typez);
}

CompactTriples::CompactTriples(HDTSpecification &specification) : spec(specification), numTriples(0) {
std::string orderStr = spec.get("triplesOrder");
std::string orderStr = "";
try{
orderStr = spec.get("triplesOrder");
}catch(exception& e){}
order= parseOrder(orderStr.c_str());
if(order==Unknown)
order = SPO;

streamY = IntSequence::getArray(spec.get("stream.y"));
streamZ = IntSequence::getArray(spec.get("stream.z"));
string typey="";
string typez="";
try{
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
streamY = IntSequence::getArray(typey);
streamZ = IntSequence::getArray(typez);
}

CompactTriples::~CompactTriples() {
Expand Down
33 changes: 26 additions & 7 deletions hdt-lib/src/triples/PlainTriples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,39 @@
namespace hdt {

PlainTriples::PlainTriples() : order(SPO) {
streamX = IntSequence::getArray(spec.get("stream.x"));
streamY = IntSequence::getArray(spec.get("stream.y"));
streamZ = IntSequence::getArray(spec.get("stream.z"));
string typex="";
string typey="";
string typez="";
try{
typex = spec.get("stream.x");
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
streamX = IntSequence::getArray(typex);
streamY = IntSequence::getArray(typey);
streamZ = IntSequence::getArray(typez);
}

PlainTriples::PlainTriples(HDTSpecification &specification) : spec(specification) {
std::string orderStr = spec.get("triplesOrder");
std::string orderStr = "";
try{
orderStr= spec.get("triplesOrder");
}catch(exception& e){}
order = parseOrder(orderStr.c_str());
if(order==Unknown) {
order = SPO;
}
streamX = IntSequence::getArray(spec.get("stream.x"));
streamY = IntSequence::getArray(spec.get("stream.y"));
streamZ = IntSequence::getArray(spec.get("stream.z"));
string typex="";
string typey="";
string typez="";
try{
typex = spec.get("stream.x");
typey = spec.get("stream.y");
typez = spec.get("stream.z");
}catch (exception& e){}
streamX = IntSequence::getArray(typex);
streamY = IntSequence::getArray(typey);
streamZ = IntSequence::getArray(typez);
}

PlainTriples::~PlainTriples() {
Expand Down
7 changes: 5 additions & 2 deletions hdt-lib/src/triples/TriplesKyoto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ int32_t TriplesKyoto::compare (const char *akbuf, size_t aksiz, const char *bkbu

TriplesKyoto::TriplesKyoto(HDTSpecification &specification) : spec(specification) {
unlink("triples.kct");

order = parseOrder(spec.get("triplesOrder").c_str());
string ord = "";
try{
ord = spec.get("triplesOrder");
}catch(exception& e){}
order = parseOrder(ord.c_str());
if(order==Unknown){
order = SPO;
}
Expand Down

0 comments on commit 42caf47

Please sign in to comment.