Skip to content

Commit 45aa25b

Browse files
Merge pull request #193 from ptorrestr/get-literal-info
Get literal info
2 parents a8aafe3 + accafa7 commit 45aa25b

15 files changed

Lines changed: 343 additions & 4 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Others
22
*~
3+
.ycm_extra_conf.py
34
# vim
45
*.swp
56

libhdt/include/Dictionary.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ class Dictionary
116116
/* Return the number of different objects of the current dictionary */
117117
virtual size_t getNobjects()=0;
118118

119+
/* return the number of different literal objects of the current dictionary*/
120+
virtual size_t getNobjectsLiterals()=0;
121+
122+
/* return the number of different non-literal objects of the current dictionary*/
123+
virtual size_t getNobjectsNotLiterals()=0;
124+
119125
/* Return the number of shared subjects-objects of the current dictionary */
120126
virtual size_t getNshared()=0;
121127

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dictionary.type <http://purl.org/HDT/hdt#dictionaryFour>
2+
triples.type <http://purl.org/HDT/hdt#triplesBitmap>
3+
triplesOrder SPO
4+
dict.block.size 32
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dictionary.type <http://purl.org/HDT/hdt#dictionaryLiteral>
2+
triples.type <http://purl.org/HDT/hdt#triplesBitmap>
3+
triplesOrder SPO

libhdt/presets/ops.hdtcfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dictionary.type <http://purl.org/HDT/hdt#dictionaryFour>
2+
triples.type <http://purl.org/HDT/hdt#triplesBitmap>
3+
triplesOrder OPS
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dictionary.type <http://purl.org/HDT/hdt#dictionaryFour>
2+
triples.type <http://purl.org/HDT/hdt#triplesBitmap>
3+
triplesOrder SPO
4+
dict.block.size 0

libhdt/src/dictionary/FourSectionDictionary.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ FourSectionDictionary::FourSectionDictionary(HDTSpecification & spec) : blocksiz
5858

5959
string blockSizeStr = "";
6060
try{
61-
spec.get("dict.block.size");
61+
blockSizeStr = spec.get("dict.block.size");
6262
}catch(exception& e){}
6363

64-
if(blockSizeStr!=""){
65-
//blocksize = atoi((const char*)blockSizeStr.c_str());
64+
if(!blockSizeStr.empty() && (blockSizeStr.find_first_not_of("0123456789") == string::npos))
65+
{
66+
blocksize = std::stoi( blockSizeStr );
67+
if ( blocksize <= 0 )
68+
{
69+
throw std::runtime_error("blocksize must be greater than 0");
70+
}
6671
}
6772
}
6873

@@ -378,6 +383,12 @@ size_t FourSectionDictionary::getNpredicates(){
378383
size_t FourSectionDictionary::getNobjects(){
379384
return shared->getLength()+objects->getLength();
380385
}
386+
size_t FourSectionDictionary::getNobjectsLiterals() {
387+
throw std::logic_error("Not implemented");
388+
}
389+
size_t FourSectionDictionary::getNobjectsNotLiterals() {
390+
throw std::logic_error("Not implemented");
391+
}
381392
size_t FourSectionDictionary::getNshared(){
382393
return shared->getLength();
383394
}

libhdt/src/dictionary/FourSectionDictionary.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class FourSectionDictionary : public Dictionary {
6969
size_t getNsubjects();
7070
size_t getNpredicates();
7171
size_t getNobjects();
72+
size_t getNobjectsLiterals();
73+
size_t getNobjectsNotLiterals();
7274
size_t getNshared();
7375

7476
size_t getMaxID();

libhdt/src/dictionary/LiteralDictionary.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ size_t LiteralDictionary::getNshared() {
506506
return shared->getLength();
507507
}
508508

509+
size_t LiteralDictionary::getNobjectsLiterals() {
510+
return objectsLiterals -> getLength();
511+
}
512+
513+
size_t LiteralDictionary::getNobjectsNotLiterals() {
514+
return objectsNotLiterals -> getLength();
515+
}
509516
size_t LiteralDictionary::getMaxID() {
510517
size_t s = subjects->getLength();
511518
size_t o = objectsLiterals->getLength()+objectsNotLiterals->getLength();

libhdt/src/dictionary/PlainDictionary.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,14 @@ size_t PlainDictionary::getNobjects() {
663663
return shared.size()+objects.size();
664664
}
665665

666+
size_t PlainDictionary::getNobjectsLiterals() {
667+
throw std::logic_error("Not implemented");
668+
}
669+
670+
size_t PlainDictionary::getNobjectsNotLiterals() {
671+
throw std::logic_error("Not implemented");
672+
}
673+
666674
size_t PlainDictionary::getNshared() {
667675
return shared.size();
668676
}

0 commit comments

Comments
 (0)