Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle lists of more than 2^32 triples #136

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions libhdt/src/triples/TriplesList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*
*/
#include <stdexcept>
#include <stdint.h>
#include <HDTVocabulary.hpp>

#include "TriplesList.hpp"
Expand Down Expand Up @@ -91,7 +92,7 @@ void TriplesList::save(std::ostream &output, ControlInformation &controlInformat
controlInformation.setUint("order", order);
controlInformation.save(output);

for( unsigned int i = 0; i < arrayOfTriples.size(); i++ ) {
for(std::vector<TripleID>::size_type i = 0; i < arrayOfTriples.size(); i++ ) {
if ( arrayOfTriples[i].isValid() ) {
output.write((char *)&arrayOfTriples[i], sizeof(TripleID));
NOTIFYCOND(listener, "TriplesList saving", i, arrayOfTriples.size())
Expand All @@ -107,9 +108,9 @@ void TriplesList::load(std::istream &input, ControlInformation &controlInformati
}

order = (TripleComponentOrder) controlInformation.getUint("order");
unsigned int totalTriples = controlInformation.getUint("numTriples");
uint64_t totalTriples = controlInformation.getUint("numTriples");

unsigned int numRead=0;
uint64_t numRead=0;
TripleID readTriple;

while(input.good() && numRead<totalTriples) {
Expand Down Expand Up @@ -231,7 +232,7 @@ void TriplesList::insert(IteratorTripleID *triples)
bool TriplesList::remove(TripleID &pattern)
{
bool removed=false;
for(unsigned int i=0; i< arrayOfTriples.size(); i++) {
for(std::vector<TripleID>::size_type i=0; i< arrayOfTriples.size(); i++) {
TripleID *tid = &arrayOfTriples[i];
if (tid->match(pattern)) {
tid->clear();
Expand All @@ -251,7 +252,7 @@ bool TriplesList::remove(IteratorTripleID *pattern)
allPat.push_back(*pattern->next());
}

for(unsigned int i=0; i< arrayOfTriples.size(); i++) {
for(std::vector<TripleID>::size_type i=0; i< arrayOfTriples.size(); i++) {
TripleID *tid = &arrayOfTriples[i];
for(size_t j=0; j<allPat.size(); j++) {
if (tid->match(allPat[i])) {
Expand Down Expand Up @@ -284,7 +285,7 @@ void TriplesList::setOrder(TripleComponentOrder order)

}

TripleID* TriplesList::getTripleID(unsigned int i)
TripleID* TriplesList::getTripleID(size_t i)
{
return &ptr[i];
//return &this->arrayOfTriples[i];
Expand All @@ -299,10 +300,10 @@ void TriplesList::removeDuplicates(ProgressListener *listener) {
throw std::runtime_error("Cannot remove duplicates on unordered triples");
}

unsigned int j = 0;
std::vector<TripleID>::size_type j = 0;
StopWatch st;

for(unsigned int i=1; i<arrayOfTriples.size(); i++) {
for(std::vector<TripleID>::size_type i=1; i<arrayOfTriples.size(); i++) {
if(!arrayOfTriples[i].isValid()) {
cerr << "WARNING: Triple with null component: " << arrayOfTriples[i] << endl;
}
Expand Down Expand Up @@ -1016,7 +1017,7 @@ void TriplesList::calculateDegreeType(string path, unsigned int rdftypeID) {
cout << "Number of Elements:" << getNumberOfElements() << endl;
// cout << "Predicate rdf:type ID:" << rdftypeID << endl;
fflush(stdout);
for (unsigned int i = 1; i < getNumberOfElements(); i++) {
for (std::vector<TripleID>::size_type i = 1; i < getNumberOfElements(); i++) {
if (i % 1000000 == 0) {
cout << i << " triples" << endl;
}
Expand Down
2 changes: 1 addition & 1 deletion libhdt/src/triples/TriplesList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class TriplesList : public ModifiableTriples {
* @param i
* @return
*/
TripleID *getTripleID(unsigned int i);
TripleID *getTripleID(size_t i);

friend class TriplesListIterator;
};
Expand Down