示例#1
0
bool RowColumn::operator==(const RowColumn& t) const
{
	if (fColumnVec.size() != t.columnVec().size())
		return false;
	for (uint32_t i = 0; i < fColumnVec.size(); i++)
	{
		if (fColumnVec[i].get() != NULL)
		{
			if (t.columnVec()[i].get() == NULL)
				return false;
			if (*(fColumnVec[i].get()) != t.columnVec()[i].get())
				return false;
		}
		else
			if (t.columnVec()[i].get() != NULL)
				return false;
	}
	return true;
}
execplan::ParseTree* ScalarSub::buildParseTree(PredicateOperator* op)
{
    idbassert(fColumn.get() && fSub && fFunc);

    vector<SRCP> cols;
    Filter* filter;
    RowColumn* rcol = dynamic_cast<RowColumn*>(fColumn.get());

    if (rcol)
    {
        // IDB only supports (c1,c2..) =/!= (subquery)
        if (fFunc->functype() != Item_func::EQ_FUNC && fFunc->functype() != Item_func::NE_FUNC)
        {
            fGwip.fatalParseError = true;
            fGwip.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_INVALID_OPERATOR_WITH_LIST);
            return NULL;
        }

        cols = rcol->columnVec();
    }
    else
        cols.push_back(fColumn);

    SCSEP csep(new CalpontSelectExecutionPlan());
    csep->sessionID(fGwip.sessionid);
    csep->location(CalpontSelectExecutionPlan::WHERE);
    csep->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS);

    // gwi for the sub query
    gp_walk_info gwi;
    gwi.thd = fGwip.thd;
    gwi.subQuery = this;

    // @4827 merge table list to gwi in case there is FROM sub to be referenced
    // in the FROM sub
    gwi.derivedTbCnt = fGwip.derivedTbList.size();
    uint32_t tbCnt = fGwip.tbList.size();

    gwi.tbList.insert(gwi.tbList.begin(), fGwip.tbList.begin(), fGwip.tbList.end());
    gwi.derivedTbList.insert(gwi.derivedTbList.begin(), fGwip.derivedTbList.begin(), fGwip.derivedTbList.end());

    if (getSelectPlan(gwi, *(fSub->get_select_lex()), csep) != 0)
    {
        //@todo more in error handling
        if (!gwi.fatalParseError)
        {
            fGwip.fatalParseError = true;
            fGwip.parseErrorText = "Error occured in ScalarSub::transform()";
        }
        else
        {
            fGwip.fatalParseError = gwi.fatalParseError;
            fGwip.parseErrorText = gwi.parseErrorText;
        }

        return NULL;
    }

    fGwip.subselectList.push_back(csep);

    // error out non-support case for now: comparison out of semi join tables.
    // only check for simplecolumn
    if (!gwi.correlatedTbNameVec.empty())
    {
        for (uint32_t i = 0; i < cols.size(); i++)
        {
            SimpleColumn* sc = dynamic_cast<SimpleColumn*>(cols[i].get());

            if (sc)
            {
                CalpontSystemCatalog::TableAliasName tan = make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias());
                uint32_t j = 0;

                for (; j < gwi.correlatedTbNameVec.size(); j++)
                    if (tan == gwi.correlatedTbNameVec[j])
                        break;

                if (j == gwi.correlatedTbNameVec.size())
                {
                    fGwip.fatalParseError = true;
                    fGwip.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_SCALAR);
                    return NULL;
                }
            }
        }
    }

    // remove outer query tables
    CalpontSelectExecutionPlan::TableList tblist;

    if (csep->tableList().size() >= tbCnt)
        tblist.insert(tblist.begin(), csep->tableList().begin() + tbCnt, csep->tableList().end());

    CalpontSelectExecutionPlan::SelectList derivedTbList;

    if (csep->derivedTableList().size() >= gwi.derivedTbCnt)
        derivedTbList.insert(derivedTbList.begin(), csep->derivedTableList().begin() + gwi.derivedTbCnt, csep->derivedTableList().end());

    csep->tableList(tblist);
    csep->derivedTableList(derivedTbList);

//	if (fSub->is_correlated)
    if (fSub->unit->first_select()->master_unit()->uncacheable)
    {
        SelectFilter* subFilter = new SelectFilter();
        subFilter->correlated(true);
        subFilter->cols(cols);
        subFilter->sub(csep);
        subFilter->op(SOP(op));
        subFilter->returnedColPos(fReturnedColPos);
        filter = subFilter;
    }
    else
    {
        SimpleScalarFilter* subFilter = new SimpleScalarFilter();
        subFilter->cols(cols);
        subFilter->sub(csep);
        subFilter->op(SOP(op));
        filter = subFilter;
    }

    return new ParseTree(filter);

}
示例#3
0
RangeEditor::
RangeEditor(const char* name, Container* parent, bool childManaged) :
    RowColumn(name, parent, false)
{
///\todo allow changing the preferred size through API
const Vector preferredSize(4.0f, 0.0f, 0.0f);

    const StyleSheet* style = getManager()->getStyleSheet();

    setNumMinorWidgets(1);

//- create the min max labels group
    RowColumn* labels = new RowColumn("Rlabels", this, false);
    labels->setNumMinorWidgets(5);
    labels->setColumnWeight(2, 1.0f);

    new Label("RminLabelName", labels, "Min:");

    rangeLabels[0] = new TextField("RminLabel", labels, 9);
    rangeLabels[0]->setFloatFormat(TextField::FIXED);
    rangeLabels[0]->setFieldWidth(9);
    rangeLabels[0]->setPrecision(2);

    Margin* centerMargin = new Margin("RcenterMargin", labels, false);
    centerMargin->setAlignment(Alignment::HCENTER);
    rangeLabels[1] = new TextField("RcenterLabel", centerMargin, 9);
    rangeLabels[1]->setFloatFormat(TextField::FIXED);
    rangeLabels[1]->setFieldWidth(9);
    rangeLabels[1]->setPrecision(2);
    centerMargin->manageChild();

    rangeLabels[2] = new TextField("RmaxLabel", labels, 9);
    rangeLabels[2]->setHAlignment(GLFont::Left);
    rangeLabels[2]->setFloatFormat(TextField::FIXED);
    rangeLabels[2]->setFieldWidth(9);
    rangeLabels[2]->setPrecision(2);

    new Label("RmaxLabelName", labels, ":Max");

    labels->manageChild();


//- create the min/max sliders group
    RowColumn* minmax = new RowColumn("Rminmax", this, false);
    minmax->setNumMinorWidgets(2);
    minmax->setPacking(RowColumn::PACK_GRID);

    RelativeSlider* slider;
    slider = new RelativeSlider("RminSlider", minmax,
                                RelativeSlider::HORIZONTAL,
                                style->fontHeight*preferredSize[0]);
    slider->setValue(0.0);
    slider->setValueRange(-2.0, 2.0, 1.0);
    slider->getValueCallbacks().add(this, &RangeEditor::sliderCallback);

    slider = new RelativeSlider("RmaxSlider", minmax,
                                RelativeSlider::HORIZONTAL,
                                style->fontHeight*preferredSize[0]);
    slider->setValue(0.0);
    slider->setValueRange(-2.0, 2.0, 1.0);
    slider->getValueCallbacks().add(this, &RangeEditor::sliderCallback);

    minmax->manageChild();


//- create the shift slider group
    RowColumn* shift = new RowColumn("Rshift", this, false);
    shift->setNumMinorWidgets(1);

    slider = new RelativeSlider("RshiftSlider", shift,
                                RelativeSlider::HORIZONTAL,
                                style->fontHeight*2.0f*preferredSize[0]);
    slider->setValue(0.0);
    slider->setValueRange(-2.0, 2.0, 1.0);
    slider->getValueCallbacks().add(this, &RangeEditor::sliderCallback);

    shift->manageChild();

//- finalize
    if(childManaged)
        manageChild();
}
示例#4
0
void CrustaApp::
produceDataDialog()
{
    dataDialog = new PopupWindow(
        "DataDialog", Vrui::getWidgetManager(), "Load Crusta Data");
    RowColumn* root = new RowColumn("DataRoot", dataDialog, false);

    RowColumn* top = new RowColumn("DataTop", root, false);
    top->setOrientation(RowColumn::HORIZONTAL);
    top->setColumnWeight(0, 1.0f);

    ScrolledListBox* box = new ScrolledListBox("DataListBox", top,
        ListBox::MULTIPLE, DATALISTBOX_SIZE[0], DATALISTBOX_SIZE[1]);
    dataListBox = box->getListBox();
    dataListBox->setAutoResize(true);

    Margin* addRemoveMargin = new Margin("DataAddRemoveMargin", top, false);
    addRemoveMargin->setAlignment(Alignment::VCENTER);
    RowColumn* addRemoveRoot = new RowColumn("DataAddRemoveRoot",
                                             addRemoveMargin, false);

    Button* button = new Button("DataAddButton", addRemoveRoot, "Add");
    button->getSelectCallbacks().add(this, &CrustaApp::addDataCallback);

    button = new Button("DataRemoveButton", addRemoveRoot, "Remove");
    button->getSelectCallbacks().add(this, &CrustaApp::removeDataCallback);

    button = new Button("DataClearButton", addRemoveRoot, "Clear");
    button->getSelectCallbacks().add(this, &CrustaApp::clearDataCallback);

    addRemoveRoot->manageChild();
    addRemoveMargin->manageChild();
    top->manageChild();

    Margin* actionMargin = new Margin("DataActionMargin", root, false);
    actionMargin->setAlignment(Alignment::RIGHT);
    RowColumn* actionRoot = new RowColumn("DataActionRoot",actionMargin,false);
    actionRoot->setOrientation(RowColumn::HORIZONTAL);

    button = new Button("DataCancelButton", actionRoot, "Cancel");
    button->getSelectCallbacks().add(this, &CrustaApp::loadDataCancelCallback);
    button = new Button("DataOkButton", actionRoot, "Load");
    button->getSelectCallbacks().add(this, &CrustaApp::loadDataOkCallback);

    actionRoot->manageChild();
    actionMargin->manageChild();
    root->manageChild();
}