Example #1
0
AMI_err	_LSList::deleteFields(s32 *fields, s32 numFields) {
	u32 buffSize = 0;
	s32* buff = NULL;

	char *base_name = tpie_tempnam("LSList");
	AMI_err result = AMI_ERROR_NO_ERROR;

	AMI_stream<s32>* newBaseStream = new AMI_stream<s32>(base_name);
	newBaseStream->persist(_m_per);

	s32 cdfield = 0;
	_m_baseStream->seek(0);
	for (u32 i=0; i<_m_count();++i) {
		TPIE_OS_OFFSET fs = fieldSize(i);
		if (fs>buffSize) {
			buffSize = fs;
			delete[] buff;
			buff = new s32[buffSize];
			memset(buff,0,buffSize);
		}
		_m_baseStream->read_array(buff,&fs);
		if (cdfield>=numFields || (s32)i != fields[cdfield]) {
			newBaseStream->write_array(buff,fs);
			_m_fields->at(i-cdfield+1)=_m_fields->at(i-cdfield)+fs;
		} else {
			++cdfield;
		}
	}
	_m_fields->erase(_m_fields->begin()+(_m_count()-numFields+1),_m_fields->end());
	delete[] buff;	delete _m_baseStream;
	_m_baseStream = newBaseStream;

	return result;
}
Example #2
0
_LBList<BTECOLL>::_LBList(size_t lbf, persistence per):_entries(NULL), _count(0), _maxEntries(0) {
	char *base_name = tpie_tempnam("LBList");
	_collection=new AMI_collection_single<BTECOLL>(base_name,AMI_READ_WRITE_COLLECTION,lbf);
	_collection->persist(per);
	_entry_cache = new entry_cache_t(200000,8);
	printf("Block size: %d\n",_collection->block_size());
};
Example #3
0
_LSList::_LSList(persistence per):_m_fields(NULL), _m_per(per) {
	char *base_name = tpie_tempnam("LSList");

	_m_fields = new std::vector<off_t>;
	_m_fields->push_back(0);
	_m_baseStream = new AMI_stream<s32>(base_name);
	_m_baseStream->persist(per);
}
Example #4
0
_LSList::_LSList(llist_t* L, persistence per):_m_fields(NULL), _m_per(per) {
	char *base_name = tpie_tempnam("LSList");

	_m_fields = new std::vector<off_t>;
	_m_fields->push_back(0);
	_m_baseStream = new AMI_stream<s32>(base_name);
	_m_baseStream->persist(per);

	for (s32 i=0; i<L->numFields; ++i) {
		appendField(&(L->data[L->index[i]]),L->index[i+1]-L->index[i]);
	}	

}
Example #5
0
_LBList<BTECOLL>::_LBList(llist_t* L, size_t lbf, persistence per):_entries(NULL), _count(0), _maxEntries(0) {
	char *base_name = tpie_tempnam("LBList");
	_collection=new AMI_collection_single<BTECOLL>(base_name,AMI_READ_WRITE_COLLECTION,lbf);
	_collection->persist(per);
	_entry_cache = new entry_cache_t(200000,8);
	printf("Block size: %d\n",_collection->block_size());

	for (s32 i=0; i<L->numFields; ++i) {
		reallocateEntries();
		_LBListField<BTECOLL>* newEntry = new _LBListField<BTECOLL> (_collection,(AMI_bid)0);
		_entries[_count] = newEntry->bid();
		for (int j=L->index[i]; i<L->index[i+1]; ++i) {
			(newEntry->el)[j-L->index[i]]=L->data[j];
		}
		newEntry->info()->entries=L->index[i+1]-L->index[i];
		newEntry->persist(PERSIST_PERSISTENT);
		++_count;
		delete newEntry;
	}	
}
Example #6
0
// Local initialization function. Create a permanent repository for the log
// file name. Should be called only once, by theLogName() below.
static char *__tpie_log_name() {
  static char tln[128];
  TPIE_OS_SRANDOM(time(NULL));
  strncpy(tln, tpie_tempnam(TPLOGPFX, TPLOGDIR), 128);
  return tln;
}
Example #7
0
AMI_err	_LSList::catFields(lpair_t *pairs, s32 numPairs, bool mod2) {
	s32 newEntries[MAX_FIELD_ENTRIES], numNewEntries;
	AMI_err result = AMI_ERROR_NO_ERROR;
	char *base_name = tpie_tempnam("LSList");
	u32 buffSize = 0;
	s32* buff = NULL;
	
	std::vector<off_t>* newOffsets = new std::vector<off_t>;
	newOffsets->push_back(0);

	
	AMI_stream<s32>* newBaseStream = new AMI_stream<s32>(base_name);
	newBaseStream->persist(_m_per);

	_LSListField** pairs_y = new _LSListField*[numPairs];
	s32* pairs_x = new s32[numPairs];
	
	for (s32 i=0; i<numPairs; ++i) {
		pairs_y[i] = fetchField(pairs[i].y);
		pairs_x[i] = pairs[i].x;
	}

	_m_baseStream->seek(0);
	s32 cdfield = 0;
	for (u32 i=0; i<_m_count(); ++i) {
		TPIE_OS_OFFSET fs = fieldSize(i);
		if (fs>buffSize) {
			buffSize = fs;
			delete[] buff;
			buff = new s32[buffSize];
		}
		_m_baseStream->read_array(buff,&fs);
		if (cdfield<numPairs && (s32)i==pairs[cdfield].x && checkPair(pairs_x,cdfield,pairs[cdfield].y)) {
			numNewEntries=0;
			for (u32 j=0; (j<fs) && (numNewEntries < MAX_FIELD_ENTRIES); j++) {
				newEntries[numNewEntries++] = buff[j];
			}
			for (u32 j=0; (j<pairs_y[cdfield]->numEntries()) && (numNewEntries < MAX_FIELD_ENTRIES); j++) {
				newEntries[numNewEntries++] = pairs_y[cdfield]->at(j);
			}
			if (numNewEntries >= MAX_FIELD_ENTRIES) {
				printf("MAX_FIELD_ENTRIES exceeded (i=%" PRId32 ", c0=%" PRId32 ", c1=%" PRId32 ".). Ignoring...\n",i,pairs[i].x,pairs[i].y);
				return AMI_ERROR_GENERIC_ERROR;
			}

			qsort(newEntries, numNewEntries, sizeof(s32), cmpS32s);
			int newEndLoc=0;
			int i=0;
			int j=0;
			while (i<numNewEntries) {
				/* How many copies of newEntries[i] are there? */
				j=i+1;
				while ((j<numNewEntries) && (newEntries[j]==newEntries[i])) {
					j++;
				}
				if (mod2) {
					if ((j-i)%2 == 0) {
						/* An even number of them, so omit them altogether. */
						i=j;
					} else {
						/* Copy one of them over. */
						newEntries[newEndLoc++] = newEntries[i];
						i=j;
					}
				} else {
					/* Copy one of them over. */
					newEntries[newEndLoc++] = newEntries[i];
					i=j;
				}
			}
			newBaseStream->write_array(newEntries,newEndLoc);
			releaseField(pairs_y[cdfield++]);
		} else {
			newBaseStream->write_array(buff,fs);
		}
		newOffsets->push_back(newBaseStream->tell());
	}

	delete[] pairs_y; delete[] buff; delete[] pairs_x;
	delete _m_fields; delete _m_baseStream;
	_m_fields=newOffsets; _m_baseStream = newBaseStream;

	return result;
}