/******************************************************************************
* Copyright (C) 2010 by Niko Välimäki *
* *
- * FMIndex implementation for the TextCollection interface *
+ * SWCSA implementation for the TextCollection interface *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
public:
SWCSAWrapper(uchar * text, ulong length, unsigned samplerate,
unsigned numberOfTexts_)
- : index(0), offsets(0), n(length), seSize(0), numberOfTexts(numberOfTexts_)
+ : index(0), offsets(0), offit(0), n(length), seSize(0), numberOfTexts(numberOfTexts_)
{
// Inicializes the arrays used to detect if a char is valid or not.
StartValid();
fprintf(stderr,"\n-----------------------\nnumber of words = %lu\n------------------------\n", seSize);
encoder.setBit(seSize);
offsets = new CSA::DeltaVector(encoder, seSize+1);
- std::cerr << "Number of texts: " << numberOfTexts << " vs " << offsets->rank(seSize - 1) << std::endl;
+ offit = new CSA::DeltaVector::Iterator(*offsets);
+
+ std::cerr << "Number of texts: " << numberOfTexts << " vs " << offit->rank(seSize - 1) << std::endl;
char opt[100];
snprintf(opt, 99, "sA=%u;sAinv=%u;sPsi=%u", samplerate, samplerate, samplerate);
std::exit(r);
}
index = 0;
+ delete offit; offit = 0;
delete offsets; offsets = 0;
}
{
ulong from, to, l;
uchar *text;
- from = offsets->select(i);
- to = offsets->select(i+1); // ADD one 1-bit in to end!!!
+ from = offit->select(i);
+ to = offit->select(i+1); // ADD one 1-bit in to end!!!
int r = extractWords(index, from, to, &text, &l);
if (r)
document_result dr;
dr.reserve(numocc+1);
for (ulong i = 0; i < numocc; ++i)
- dr.push_back(offsets->rank(occ[i])-1);
+ dr.push_back(offit->rank(occ[i])-1);
free(occ);
return dr;
// Index from/to disk
SWCSAWrapper(FILE *file, char const *filename)
- : index(0), offsets(0), n(0), seSize(0), numberOfTexts(0)
+ : index(0), offsets(0), offit(0), n(0), seSize(0), numberOfTexts(0)
{
uchar verFlag = 0;
if (std::fread(&verFlag, 1, 1, file) != 1)
if (std::fread(&(this->numberOfTexts), sizeof(unsigned), 1, file) != 1)
throw std::runtime_error("FMIndex::Load(): file read error (numberOfTexts).");
- offsets = new CSA::DeltaVector(file);
+ offsets = new CSA::DeltaVector(file);
+ offit = new CSA::DeltaVector::Iterator(*offsets);
// FIXME Const correctness is broken!
int r = load_index((char *)filename, &index);
private:
void *index;
CSA::DeltaVector *offsets;
+ CSA::DeltaVector::Iterator *offit;
TextPosition n;
ulong seSize;