本文整理汇总了C++中ControlInformation类的典型用法代码示例。如果您正苦于以下问题:C++ ControlInformation类的具体用法?C++ ControlInformation怎么用?C++ ControlInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ControlInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void PlainTriples::load(std::istream &input, ControlInformation &controlInformation, ProgressListener *listener)
{
std::string format = controlInformation.getFormat();
if(format!=getType()) {
throw std::runtime_error("Trying to read PlainTriples but the data is not PlainTriples");
}
//unsigned int numTriples = controlInformation.getUint("numTriples");
order = (TripleComponentOrder) controlInformation.getUint("order");
IntermediateListener iListener(listener);
iListener.setRange(0,33);
iListener.notifyProgress(0, "PlainTriples loading subjects");
delete streamX;
streamX = IntSequence::getArray(input);
streamX->load(input);
iListener.setRange(33, 66);
iListener.notifyProgress(0, "PlainTriples loading predicates");
delete streamY;
streamY = IntSequence::getArray(input);
streamY->load(input);
iListener.setRange(66, 100);
iListener.notifyProgress(0, "PlainTriples loading objects");
delete streamZ;
streamZ = IntSequence::getArray(input);
streamZ->load(input);
}
示例2: save
void FourSectionDictionary::save(std::ostream & output, ControlInformation & controlInformation, ProgressListener *listener)
{
controlInformation.setFormat(HDTVocabulary::DICTIONARY_TYPE_FOUR);
controlInformation.setUint("mapping", this->mapping);
controlInformation.setUint("sizeStrings", this->sizeStrings);
controlInformation.save(output);
IntermediateListener iListener(listener);
iListener.setRange(0,10);
iListener.notifyProgress(0, "Dictionary save shared area.");
shared->save(output);
iListener.setRange(10,45);
iListener.notifyProgress(0, "Dictionary save subjects.");
subjects->save(output);
iListener.setRange(45,60);
iListener.notifyProgress(0, "Dictionary save predicates.");
predicates->save(output);
iListener.setRange(60,100);
iListener.notifyProgress(0, "Dictionary save objects.");
objects->save(output);
}
示例3: load
size_t PlainHeader::load(unsigned char *ptr, unsigned char *ptrMax, ProgressListener *listener)
{
size_t count = 0;
// Read ControlInformation
ControlInformation controlInformation;
count += controlInformation.load(&ptr[count], ptrMax);
std::string format = controlInformation.getFormat();
uint32_t headerSize = controlInformation.getUint("length");
// FIXME: Use format to create custom parser.
if(format!=HDTVocabulary::HEADER_NTRIPLES) {
throw "This Header format is not supported";
}
string str(&ptr[count], &ptr[count+headerSize]);
// Convert into a stringstream
stringstream strstream(str, stringstream::in);
triples.clear();
// Parse header
RDFParserNtriples parser(strstream, NTRIPLES);
while(parser.hasNext()) {
TripleString *ts = parser.next();
triples.push_back(*ts);
}
count+=headerSize;
return count;
}
示例4: in
void BasicHDT::loadOrCreateIndex(ProgressListener *listener) {
string indexname = this->fileName + ".index";
ifstream in(indexname.c_str(), ios::binary);
if(in.good()) {
if(mappedHDT) {
// Map
this->loadMMapIndex(listener);
} else {
// Read from file
ControlInformation ci;
ci.load(in);
triples->loadIndex(in, ci, listener);
}
in.close();
} else {
IntermediateListener iListener(listener);
iListener.setRange(0,90);
triples->generateIndex(&iListener);
iListener.setRange(90,100);
this->saveIndex(&iListener);
}
}
示例5: iListener
size_t FourSectionDictionary::load(unsigned char *ptr, unsigned char *ptrMax, ProgressListener *listener)
{
size_t count=0;
IntermediateListener iListener(listener);
ControlInformation ci;
count += ci.load(&ptr[count], ptrMax);
//this->mapping = ci.getUint("mapping");
this->mapping = MAPPING2;
this->sizeStrings = ci.getUint("sizeStrings");
iListener.setRange(0,25);
iListener.notifyProgress(0, "Dictionary read shared area.");
delete shared;
shared = csd::CSD::create(ptr[count]);
if(shared==NULL){
shared = new csd::CSD_PFC();
throw std::runtime_error("Could not read shared.");
}
count += shared->load(&ptr[count], ptrMax);
//shared = new csd::CSD_Cache(shared);
iListener.setRange(25,50);
iListener.notifyProgress(0, "Dictionary read subjects.");
delete subjects;
subjects = csd::CSD::create(ptr[count]);
if(subjects==NULL){
subjects = new csd::CSD_PFC();
throw std::runtime_error("Could not read subjects.");
}
count += subjects->load(&ptr[count], ptrMax);
//subjects = new csd::CSD_Cache(subjects);
iListener.setRange(50,75);
iListener.notifyProgress(0, "Dictionary read predicates.");
delete predicates;
predicates = csd::CSD::create(ptr[count]);
if(predicates==NULL){
predicates = new csd::CSD_PFC();
throw std::runtime_error("Could not read predicates.");
}
count += predicates->load(&ptr[count], ptrMax);
predicates = new csd::CSD_Cache2(predicates);
iListener.setRange(75,100);
iListener.notifyProgress(0, "Dictionary read objects.");
delete objects;
objects = csd::CSD::create(ptr[count]);
if(objects==NULL){
objects = new csd::CSD_PFC();
throw std::runtime_error("Could not read objects.");
}
count += objects->load(&ptr[count], ptrMax);
//objects = new csd::CSD_Cache(objects);
return count;
}
示例6: save
void PlainDictionary::save(std::ostream &output, ControlInformation &controlInformation, ProgressListener *listener)
{
controlInformation.setFormat(HDTVocabulary::DICTIONARY_TYPE_PLAIN);
controlInformation.setUint("mapping", this->mapping);
controlInformation.setUint("sizeStrings", this->sizeStrings);
controlInformation.setUint("numEntries", this->getNumberOfElements());
controlInformation.save(output);
unsigned int i = 0;
unsigned int counter=0;
const char marker = '\1';
//shared subjects-objects from subjects
for (i = 0; i < shared.size(); i++) {
output << shared[i]->str;
output.put(marker); //character to split file
counter++;
NOTIFYCOND(listener, "PlainDictionary saving shared", counter, getNumberOfElements());
}
output.put(marker); //extra line to set the begining of next part of dictionary
//not shared subjects
for (i = 0; i < subjects.size(); i++) {
output << subjects[i]->str;
output.put(marker); //character to split file
counter++;
NOTIFYCOND(listener, "PlainDictionary saving subjects", counter, getNumberOfElements());
}
output.put(marker); //extra line to set the begining of next part of dictionary
//not shared objects
for (i = 0; i < objects.size(); i++) {
output << objects[i]->str;
output.put(marker); //character to split file
counter++;
NOTIFYCOND(listener, "PlainDictionary saving objects", counter, getNumberOfElements());
}
output.put(marker); //extra line to set the begining of next part of dictionary
//predicates
for (i = 0; i < predicates.size(); i++) {
output << predicates[i]->str;
output.put(marker); //character to split file
counter++;
NOTIFYCOND(listener, "PlainDictionary saving predicates", counter, getNumberOfElements());
}
output.put(marker);
}
示例7: load
void FourSectionDictionary::load(std::istream & input, ControlInformation & ci, ProgressListener *listener)
{
std::string format = ci.getFormat();
if(format!=getType()) {
throw std::runtime_error("Trying to read a FourSectionDictionary but the data is not FourSectionDictionary");
}
//this->mapping = ci.getUint("mapping");
this->mapping = MAPPING2;
this->sizeStrings = ci.getUint("sizeStrings");
IntermediateListener iListener(listener);
iListener.setRange(0,25);
iListener.notifyProgress(0, "Dictionary read shared area.");
delete shared;
shared = csd::CSD::load(input);
if(shared==NULL){
shared = new csd::CSD_PFC();
throw std::runtime_error("Could not read shared.");
}
//shared = new csd::CSD_Cache(shared);
iListener.setRange(25,50);
iListener.notifyProgress(0, "Dictionary read subjects.");
delete subjects;
subjects = csd::CSD::load(input);
if(subjects==NULL){
subjects = new csd::CSD_PFC();
throw std::runtime_error("Could not read subjects.");
}
//subjects = new csd::CSD_Cache(subjects);
iListener.setRange(50,75);
iListener.notifyProgress(0, "Dictionary read predicates.");
delete predicates;
predicates = csd::CSD::load(input);
if(predicates==NULL){
predicates = new csd::CSD_PFC();
throw std::runtime_error("Could not read predicates.");
}
predicates = new csd::CSD_Cache2(predicates);
iListener.setRange(75,100);
iListener.notifyProgress(0, "Dictionary read objects.");
delete objects;
objects = csd::CSD::load(input);
if(objects==NULL){
objects = new csd::CSD_PFC();
throw std::runtime_error("Could not read objects.");
}
//objects = new csd::CSD_Cache(objects);
}
示例8: save
void TripleListDisk::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
controlInformation.setFormat(getType());
controlInformation.save(output);
for(unsigned int i=0; i<numTotalTriples; i++) {
TripleID *tid = getTripleID(i);
if(tid->isValid()) {
//cout << "Write: " << tid << " " << *tid << endl;
output.write((char *)tid, sizeof(TripleID));
}
}
}
示例9: load
void PlainDictionary::load(std::istream & input, ControlInformation &ci, ProgressListener *listener)
{
std::string line;
unsigned char region = 1;
startProcessing();
std::string format = ci.getFormat();
if(format!=getType()) {
throw "Trying to read a PlainDictionary but the data is not PlainDictionary";
}
this->mapping = ci.getUint("mapping");
this->sizeStrings = ci.getUint("sizeStrings");
unsigned int numElements = ci.getUint("numEntries");
unsigned int numLine = 0;
IntermediateListener iListener(listener);
iListener.setRange(0,25);
while(region<5 && getline(input, line,'\1')) {
//std::cout << line << std::endl;
if(line!="") {
if (region == 1) { //shared SO
NOTIFYCOND(&iListener, "Dictionary loading shared area.", numLine, numElements);
insert(line, SHARED_SUBJECT);
} else if (region == 2) { //not shared Subjects
NOTIFYCOND(&iListener, "Dictionary loading subjects.", numLine, numElements);
insert(line, NOT_SHARED_SUBJECT);
NOTIFYCOND(&iListener, "Dictionary loading objects.", numLine, numElements);
} else if (region == 3) { //not shared Objects
insert(line, NOT_SHARED_OBJECT);
NOTIFYCOND(&iListener, "Dictionary loading predicates.", numLine, numElements);
} else if (region == 4) { //predicates
insert(line, NOT_SHARED_PREDICATE);
}
} else {
region++;
}
numLine++;
}
// No stopProcessing() Needed. Dictionary already split and sorted in file.
updateIDs();
}
示例10: save
void CompactTriples::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
controlInformation.clear();
controlInformation.setUint("numTriples", getNumberOfElements());
controlInformation.setFormat(HDTVocabulary::TRIPLES_TYPE_COMPACT);
controlInformation.setUint("order", order);
controlInformation.save(output);
IntermediateListener iListener(listener);
iListener.setRange(0,30);
iListener.notifyProgress(0, "CompactTriples saving Stream Y");
streamY->save(output);
iListener.setRange(30,100);
iListener.notifyProgress(0, "CompactTriples saving Stream Z");
streamZ->save(output);
}
示例11: save
void PlainHeader::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
// TODO: Choose format from spec (NTRIPLES, RDFXML...) and implement.
// Dump header into a stringbuffer to know size.
stringstream strbuf(stringstream::out);
for(vector<TripleString>::iterator it = triples.begin(); it!=triples.end(); it++){
strbuf << *it << " ." << endl;
}
string str = strbuf.str();
// Dump header
controlInformation.setFormat(HDTVocabulary::HEADER_NTRIPLES);
controlInformation.setUint("length", str.length());
controlInformation.save(output);
// Dump data
output << str;
}
示例12: iListener
size_t BasicHDT::loadMMap(unsigned char *ptr, unsigned char *ptrMax, ProgressListener *listener) {
size_t count=0;
ControlInformation controlInformation;
IntermediateListener iListener(listener);
// Load Global ControlInformation
count+=controlInformation.load(&ptr[count], ptrMax);
std::string hdtFormat = controlInformation.getFormat();
if(hdtFormat!=HDTVocabulary::HDT_CONTAINER) {
throw "This software cannot open this version of HDT File.";
}
// Load Header
iListener.setRange(0,5);
controlInformation.load(&ptr[count], ptrMax);
delete header;
header = HDTFactory::readHeader(controlInformation);
count+= header->load(&ptr[count], ptrMax, &iListener);
// Load dictionary
iListener.setRange(5, 60);
controlInformation.load(&ptr[count], ptrMax);
delete dictionary;
dictionary = HDTFactory::readDictionary(controlInformation);
count += dictionary->load(&ptr[count], ptrMax, &iListener);
// Load triples
iListener.setRange(60,100);
controlInformation.load(&ptr[count], ptrMax);
delete triples;
triples = HDTFactory::readTriples(controlInformation);
count += triples->load(&ptr[count], ptrMax, &iListener);
return count;
}
示例13: save
void PlainTriples::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
controlInformation.clear();
controlInformation.setUint("numTriples", getNumberOfElements());
controlInformation.setFormat(HDTVocabulary::TRIPLES_TYPE_PLAIN);
controlInformation.setUint("order", order);
controlInformation.save(output);
IntermediateListener iListener(listener);
iListener.setRange(0,33);
iListener.notifyProgress(0, "PlainTriples saving subjects");
streamX->save(output);
iListener.setRange(33, 66);
iListener.notifyProgress(0, "PlainTriples saving predicates");
streamY->save(output);
iListener.setRange(66, 100);
iListener.notifyProgress(0, "PlainTriples saving objects");
streamZ->save(output);
}
示例14: load
void CompactTriples::load(std::istream &input, ControlInformation &controlInformation, ProgressListener *listener)
{
std::string format = controlInformation.getFormat();
if(format != HDTVocabulary::TRIPLES_TYPE_COMPACT) {
throw "Trying to read CompactTriples but data is not CompactTriples";
}
numTriples = controlInformation.getUint("numTriples");
order = (TripleComponentOrder) controlInformation.getUint("order");
IntermediateListener iListener(listener);
iListener.setRange(0,30);
iListener.notifyProgress(0, "CompactTriples loading Stream Y");
delete streamY;
streamY = IntSequence::getArray(input);
streamY->load(input);
iListener.setRange(30,100);
iListener.notifyProgress(0, "CompactTriples saving Stream Y");
delete streamZ;
streamZ = IntSequence::getArray(input);
streamZ->load(input);
}
示例15: load
void TripleListDisk::load(std::istream & input, ControlInformation &controlInformation, ProgressListener *listener)
{
// FIXME: Read controlInformation
std::string format = controlInformation.getFormat();
if(format!=getType()) {
throw "Trying to read a FourSectionDictionary but the data is not FourSectionDictionary";
}
this->ensureSize(numTotalTriples);
unsigned int numRead=0;
while(input.good() && numRead<numTotalTriples) {
input.read((char *)&arrayTriples[numRead], sizeof(TripleID));
numRead++;
}
cout << "Succesfully read triples: " << numRead << endl;
}