Exemplo n.º 1
0
void TupleHavingStep::initialize(const RowGroup& rgIn, const JobInfo& jobInfo)
{
	fRowGroupIn = rgIn;
	fRowGroupIn.initRow(&fRowIn);

	map<uint32_t, uint32_t> keyToIndexMap;
	for (uint64_t i = 0; i < fRowGroupIn.getKeys().size(); ++i)
		if (keyToIndexMap.find(fRowGroupIn.getKeys()[i]) == keyToIndexMap.end())
			keyToIndexMap.insert(make_pair(fRowGroupIn.getKeys()[i], i));
	updateInputIndex(keyToIndexMap, jobInfo);

	vector<uint32_t> oids, oidsIn = fRowGroupIn.getOIDs();
	vector<uint32_t> keys, keysIn = fRowGroupIn.getKeys();
	vector<uint32_t> scale, scaleIn = fRowGroupIn.getScale();
	vector<uint32_t> precision, precisionIn = fRowGroupIn.getPrecision();
	vector<erydbSystemCatalog::ColDataType> types, typesIn = fRowGroupIn.getColTypes();
	vector<uint32_t> pos, posIn = fRowGroupIn.getOffsets();

	size_t n = 0;
	RetColsVector::const_iterator i = jobInfo.deliveredCols.begin();
	while (i != jobInfo.deliveredCols.end())
		if (NULL == dynamic_cast<const ConstantColumn*>(i++->get()))
			n++;

	oids.insert(oids.end(), oidsIn.begin(), oidsIn.begin() + n);
	keys.insert(keys.end(), keysIn.begin(), keysIn.begin() + n);
	scale.insert(scale.end(), scaleIn.begin(), scaleIn.begin() + n);
	precision.insert(precision.end(), precisionIn.begin(), precisionIn.begin() + n);
	types.insert(types.end(), typesIn.begin(), typesIn.begin() + n);
	pos.insert(pos.end(), posIn.begin(), posIn.begin() + n + 1);

	fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision, jobInfo.stringTableThreshold);
	fRowGroupOut.initRow(&fRowOut);
}
Exemplo n.º 2
0
// Synchronize the RowGroup list and the WTable rows with the MemoryMap
void
WMemoryMap::synchronize() {
    memoryMap_.checkConsistency();
    MemoryMap::NodeIterator mmNode = memoryMap_.nodes().begin();
    RowGroups::iterator rg = rowGroups_.begin();
    size_t rgIdx = 0;

    for (/*void*/; mmNode != memoryMap_.nodes().end(); ++mmNode, ++rg, ++rgIdx) {
        size_t tableIdx = rowGroupTableIndex(rgIdx);
        if (rg == rowGroups_.end()) {
            // Append a RowGroup and the corresponding table rows
            rg = rowGroups_.insert(rg, RowGroup(mmNode->key().least()));
            instantiateTableWidgets(*rg, tableIdx);
        } else {
            // Make sure the existing RowGroup is linked to the correct MemoryMap node.  Since MemoryMap::NodeIterator is not
            // stable over insert and erase, we need to store a lookup key rather than an iterator.
            ASSERT_require2(rowGroupTableIndex(rgIdx+1)-1 < (size_t)wTable_->rowCount(), "table rows must already exist");
            rg->segmentVa = mmNode->key().least();
        }

        // Make sure the table is showing correct data.
        rg->editingColumn = ZeroColumn;
        rg->wId->setText(StringUtility::numberToString(rgIdx+1));
        updateRowGroupWidgets(*rg, mmNode);
    }

    // Remove extra RowGroup entries and their corresponding WTable rows.
    rowGroups_.erase(rg, rowGroups_.end());
    size_t tableIdx = rowGroupTableIndex(rgIdx);
    while ((size_t)wTable_->rowCount() > tableIdx)
        wTable_->deleteRow(wTable_->rowCount()-1);
}
Exemplo n.º 3
0
void TupleConstantOnlyStep::initialize(const RowGroup& rgIn, const JobInfo& jobInfo)
{
	vector<uint> oids;
	vector<uint> keys;
	vector<uint> scale;
	vector<uint> precision;
	vector<CalpontSystemCatalog::ColDataType> types;
	vector<uint> pos;
	pos.push_back(2);

	for (uint64_t i = 0; i < jobInfo.deliveredCols.size(); i++)
	{
		const ConstantColumn* cc =
						dynamic_cast<const ConstantColumn*>(jobInfo.deliveredCols[i].get());
		if (cc == NULL)
			throw runtime_error("none constant column found.");

		CalpontSystemCatalog::ColType ct = cc->resultType();
		if (ct.colDataType == CalpontSystemCatalog::VARCHAR)
			ct.colWidth++;

		//Round colWidth up
		if (ct.colWidth == 3)
			ct.colWidth = 4;
		else if (ct.colWidth == 5 || ct.colWidth == 6 || ct.colWidth == 7)
			ct.colWidth = 8;

		oids.push_back(-1);
		keys.push_back(-1);
		scale.push_back(ct.scale);
		precision.push_back(ct.precision);
		types.push_back(ct.colDataType);
		pos.push_back(pos.back() + ct.colWidth);

		fIndexConst.push_back(i);
	}

	fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision, jobInfo.stringTableThreshold);
	fRowGroupOut.initRow(&fRowOut);
	fRowGroupOut.initRow(&fRowConst, true);

	constructContanstRow(jobInfo);
}
Exemplo n.º 4
0
void TupleAnnexStep::initialize(const RowGroup& rgIn, const JobInfo& jobInfo)
{
    fRowGroupIn = rgIn;
    fRowGroupIn.initRow(&fRowIn);

    if (fOrderBy)
    {
        fOrderBy->distinct(fDistinct);
        fOrderBy->initialize(rgIn, jobInfo);
    }

    if (fConstant == NULL)
    {
        vector<uint> oids, oidsIn = fRowGroupIn.getOIDs();
        vector<uint> keys, keysIn = fRowGroupIn.getKeys();
        vector<uint> scale, scaleIn = fRowGroupIn.getScale();
        vector<uint> precision, precisionIn = fRowGroupIn.getPrecision();
        vector<CalpontSystemCatalog::ColDataType> types, typesIn = fRowGroupIn.getColTypes();
        vector<uint> pos, posIn = fRowGroupIn.getOffsets();

        size_t n = jobInfo.nonConstDelCols.size();
        oids.insert(oids.end(), oidsIn.begin(), oidsIn.begin() + n);
        keys.insert(keys.end(), keysIn.begin(), keysIn.begin() + n);
        scale.insert(scale.end(), scaleIn.begin(), scaleIn.begin() + n);
        precision.insert(precision.end(), precisionIn.begin(), precisionIn.begin() + n);
        types.insert(types.end(), typesIn.begin(), typesIn.begin() + n);
        pos.insert(pos.end(), posIn.begin(), posIn.begin() + n + 1);

        fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision, jobInfo.stringTableThreshold);
    }
    else
    {
        fConstant->initialize(jobInfo, &rgIn);
        fRowGroupOut = fConstant->getOutputRowGroup();
    }

    fRowGroupOut.initRow(&fRowOut);
    fRowGroupDeliver = fRowGroupOut;
}
Exemplo n.º 5
0
void TupleConstantStep::initialize(const JobInfo& jobInfo, const RowGroup* rgIn)
{
	vector<uint> oids, oidsIn = fRowGroupIn.getOIDs();
	vector<uint> keys, keysIn = fRowGroupIn.getKeys();
	vector<uint> scale, scaleIn = fRowGroupIn.getScale();
	vector<uint> precision, precisionIn = fRowGroupIn.getPrecision();
	vector<CalpontSystemCatalog::ColDataType> types, typesIn = fRowGroupIn.getColTypes();
	vector<uint> pos;
	pos.push_back(2);

	if (rgIn)
	{
		fRowGroupIn = *rgIn;
		fRowGroupIn.initRow(&fRowIn);
		oidsIn = fRowGroupIn.getOIDs();
		keysIn = fRowGroupIn.getKeys();
		scaleIn = fRowGroupIn.getScale();
		precisionIn = fRowGroupIn.getPrecision();
		typesIn = fRowGroupIn.getColTypes();
	}

	for (uint64_t i = 0, j = 0; i < jobInfo.deliveredCols.size(); i++)
	{
		const ConstantColumn* cc =
						dynamic_cast<const ConstantColumn*>(jobInfo.deliveredCols[i].get());
		if (cc != NULL)
		{
			CalpontSystemCatalog::ColType ct = cc->resultType();
			if (ct.colDataType == CalpontSystemCatalog::VARCHAR)
				ct.colWidth++;

			//Round colWidth up
			if (ct.colWidth == 3)
				ct.colWidth = 4;
			else if (ct.colWidth == 5 || ct.colWidth == 6 || ct.colWidth == 7)
				ct.colWidth = 8;

			oids.push_back(-1);
			keys.push_back(-1);
			scale.push_back(ct.scale);
			precision.push_back(ct.precision);
			types.push_back(ct.colDataType);
			pos.push_back(pos.back() + ct.colWidth);

			fIndexConst.push_back(i);
		}
		else
		{
			// select (select a) from region;
			if (j >= oidsIn.size() && jobInfo.tableList.empty())
			{
				throw IDBExcept(ERR_NO_FROM);
			}
			idbassert(j < oidsIn.size());

			oids.push_back(oidsIn[j]);
			keys.push_back(keysIn[j]);
			scale.push_back(scaleIn[j]);
			precision.push_back(precisionIn[j]);
			types.push_back(typesIn[j]);
			pos.push_back(pos.back() + fRowGroupIn.getColumnWidth(j));
			j++;

			fIndexMapping.push_back(i);
		}
	}

	fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision,
		jobInfo.stringTableThreshold);
	fRowGroupOut.initRow(&fRowOut);
	fRowGroupOut.initRow(&fRowConst, true);

	constructContanstRow(jobInfo);
}