示例#1
0
/**
* 读invLinkDocList时(无需窗口信息时),对其解压。
*/
link::api::InvLinkDocList::InvLinkDocList(lemur::api::LOC_T *vec)
{
	READ_ONLY = false;
	hascache = false;
	LOC_Tsize = sizeof(lemur::api::LOC_T);
	uid = vec[0];
	df = vec[1];
	lemur::api::COUNT_T diff = vec[2];
	lemur::api::COUNT_T vecLength = vec[3];
	size = vecLength * 4;
	unsigned char* buffer = (unsigned char *) (vec + 4);
	// this should be big enough
	//  begin = (LOC_T*) malloc(s);
	// use new/delete[] so an exception will be thrown if out of memory.
	begin = new lemur::api::LOC_T[size/sizeof(lemur::api::LOC_T)];

	// decompress it
	int len = lemur::utility::RVLCompress::decompress_ints(buffer, (int *)begin, vecLength);

	lastid = begin + diff;
	end = begin + len;
	freq = lastid+1;

	deltaDecode();//解压缩
}
示例#2
0
bool lemur::index::InvDocList::binReadC(ifstream& inf) {
  if (inf.eof())
    return false;
  int diff;

  inf.read((char*) &uid, sizeof(lemur::api::TERMID_T));
  if (!(inf.gcount() == sizeof(lemur::api::TERMID_T)))
    return false;

  inf.read((char*) &df, LOC_Tsize);
  if (!inf.gcount() == LOC_Tsize)
    return false;

  inf.read((char*) &diff, LOC_Tsize);
  if (!inf.gcount() == LOC_Tsize)
    return false;

  inf.read((char*) &size, LOC_Tsize);
  if (!inf.gcount() == LOC_Tsize)
    return false;

  //  unsigned char* buffer = (unsigned char*) malloc(size);
  // use new/delete[] so an exception will be thrown if out of memory.
  unsigned char* buffer = new unsigned char[size];
  inf.read((char*) buffer, size);
  if (!inf.gcount() == size) {
    resetFree();
    return false;
  }

  // this should be big enough
  //  begin = (LOC_T*) malloc(size*4);  
  // use new/delete[] so an exception will be thrown if out of memory.
  begin = new lemur::api::LOC_T[(size*4)/sizeof(lemur::api::LOC_T)];  

  // decompress it
  int len = lemur::utility::RVLCompress::decompress_ints(buffer, (int *)begin, size);

  size = size*4;

  if (len * LOC_Tsize > size)
    cerr << "RVLDecompress in DocList buffer overrun!" << endl;

  lastid = begin + diff;
  end = begin + len;
  freq = lastid+1;

  deltaDecode();

  READ_ONLY = false;
  //  free(buffer);
  delete[](buffer);
  return true;
}
示例#3
0
/**
* 读invLinkDocList时(包含窗口),对其解压。
*/
link::api::InvLinkDocList::InvLinkDocList(lemur::api::LOC_T *vec,const std::vector<int> &winsizes)
{

	this->winCount = winsizes.size();
	
	this->winSizes = new int[winCount+1];
	memset(winSizes,0,winCount+1);

	winSizes[0] = 0;
	for(int i=1;i<=winCount;i++) winSizes[i] = winsizes[i-1];


	READ_ONLY = false;
	hascache = false;
	LOC_Tsize = sizeof(lemur::api::LOC_T);
	ulid = vec[0];
	df = vec[1];
	lemur::api::COUNT_T diff = vec[2];
	lemur::api::COUNT_T vecLength = vec[3];
	size = vecLength * 4;
	unsigned char* buffer = (unsigned char *) (vec + 4);
	// this should be big enough
	//  begin = (LOC_T*) malloc(s);
	// use new/delete[] so an exception will be thrown if out of memory.
	begin = new lemur::api::LOC_T[size/sizeof(lemur::api::LOC_T)];

	// decompress it
	int len = lemur::utility::RVLCompress::decompress_ints(buffer, (int *)begin, vecLength);

	lastid = begin + diff;
	end = begin + len;
	freq = lastid+1;

	deltaDecode();//解压缩

}