Ejemplo n.º 1
0
//-----------------------------------------------
CanESD::CanESD(const char* cIniFile, bool bObjectMode)
{
	m_bObjectMode = bObjectMode;
	m_bIsTXError = false;
	//m_IniFile.SetFileName(cIniFile, "CanESD.cpp");
	initIntern();
}
Ejemplo n.º 2
0
void AggregationProcessorWorker::operator()()
{
	double resultSize = aggregationPlan->getArea()->getSize();
	HashValueStorage *hashStorage = 0;
	if (resultSize < 1000) {
		hashStorage = new HashValueStorage(aggregationPlan->getArea());
		storage.reset(hashStorage);
	} else {
		storage = CreateDoubleCellMap(aggregationPlan->getArea()->dimCount());
		storage->setLimit(IdentifiersType(), (aggregationPlan->getMaxCount() == 0 ? 0 : aggregationPlan->getMaxCount() + 1));
	}

	initIntern();

	bool hasVals = false;
	if (newAlg && hashStorage) {
		hasVals = true;
		reader.aggregate(hashStorage, parentMaps);
	} else {
		while (reader.nextIntern()) {
			aggregateCell(reader.getKey(), reader.getValue().getNumeric());
			hasVals = true;
		}
	}
	if (hasVals) {
		boost::unique_lock<boost::mutex> lock(parent.dataMutex);
		if (parent.threadStorage) {
			storageReader = dynamic_cast<ICellMapStream *>(storage.get())->getValues();
			while (storageReader->next()) {
				parent.threadStorage->add(storageReader->getKey(), storageReader->getDouble());
			}
		} else {
			parent.threadStorage = storage;
		}
	}
}
Ejemplo n.º 3
0
void AggregationProcessorMT::aggregate()
{
	tp = Context::getContext()->getServer()->getThreadPool();
	tg = tp->createThreadGroup();

	double resultSize = aggregationPlan->getArea()->getSize();

	initIntern();

	const vector<PPlanNode> &sources = planNode->getChildren();
	for (vector<PPlanNode>::const_iterator source = sources.begin(); source != sources.end(); ++source) {
		PCellStream sourceDataSP = engine->createProcessor(*source, false);

		reader = dynamic_cast<StorageCpu::Processor *>(sourceDataSP.get());
		if (reader && (*source)->getType() == SOURCE) {
			minJump = (size_t)reader->pageList->maxPageSize() * 20;
			reader->mtCallback = this;
			if (!storage) {
				createStorage(resultSize);
			}
			if (newAlg && hashStorage) {
				reader->aggregate(hashStorage, parentMaps);
			} else {
				while (reader->nextIntern()) {
					if (!storage) {
						createStorage(resultSize);
					}
					aggregateCell(reader->getKey(), reader->getValue().getNumeric());
				}
			}
		} else {
			CellValueStream *sourceData = sourceDataSP.get();
			while (sourceData->next()) {
				if (!storage) {
					createStorage(resultSize);
				}
				aggregateCell(sourceData->getKey(), sourceData->getValue().getNumeric());
			}
		}
	}

	tp->join(tg);
	tp->destroyThreadGroup(tg);
	if (threadStorage) {
		if (storage) {
			storageReader = dynamic_cast<ICellMapStream *>(threadStorage.get())->getValues();
			while (storageReader->next()) {
				storage->add(storageReader->getKey(), storageReader->getDouble());
			}
		} else {
			storage = threadStorage;
		}
	}
	if (!storage) {
		storage = CreateDoubleCellMap(aggregationPlan->getArea()->dimCount());
	}
	if (resultSize > 1000 && (Logger::isDebug() || Logger::isTrace())) {
		Logger::debug << "Aggregated area of " << resultSize << " cells. " << storage->size() << " aggregations exists." << endl;
	}
	storageReader = dynamic_cast<ICellMapStream *>(storage.get())->getValues();
}