int Wildcard::wildcardfit(const char *wildcard, const char *test) { int fit = 1; for (; ('\000' != *wildcard) && (1 == fit) && ('\000' != *test); wildcard++) { switch (*wildcard) { case '[': wildcard++; /* leave out the opening square bracket */ fit = set (&wildcard, &test); /* we don't need to decrement the wildcard as in case */ /* of asterisk because the closing ] is still there */ break; case '?': test++; break; case '*': fit = asterisk (&wildcard, &test); /* the asterisk was skipped by asterisk() but the loop will */ /* increment by itself. So we have to decrement */ wildcard--; break; default: fit = (int) (*wildcard == *test); test++; } } while ((*wildcard == '*') && (1 == fit)) /* here the teststring is empty otherwise you cannot */ /* leave the previous loop */ wildcard++; return (int) ((1 == fit) && ('\0' == *test) && ('\0' == *wildcard)); }
int wildcardfit(char *wildcard, char *test) { int fit = 1; for (; ('\000' != *wildcard) && (1 == fit) && ('\000' != *test); wildcard++) { switch (*wildcard) { case '[': wildcard++; fit = set (&wildcard, &test); break; case '?': test++; break; case '*': fit = asterisk (&wildcard, &test); wildcard--; break; default: fit = (int) (*wildcard == *test); test++; } } while ((*wildcard == '*') && (1 == fit)) wildcard++; return ((int) ((1 == fit) && ('\0' == *test) && ('\0' == *wildcard))); }
int ToolsPmatch(char *express, char *text) { int nret = 1; for (; ('\0' != *express) && (1 == nret) && ('\0' != *text); express++) { switch (*express) { case '[': express++; nret = set (&express, &text); break; case '?': text++; break; case '*': nret = asterisk (&express, &text); express--; break; default: nret = (int) (*express == *text); text++; } } while ((*express == '*') && (1 == nret)) express++; return (int) ((1 == nret) && ('\0' == *text) && ('\0' == *express)); }
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget)) return QProxyStyle::drawControl(element, option, painter, widget); switch (element) { case CE_Splitter: painter->fillRect(option->rect, Utils::StyleHelper::borderColor()); break; case CE_TabBarTabShape: // Most styles draw a single dark outline. This looks rather ugly when combined with our // single pixel dark separator so we adjust the first tab to compensate for this if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { QStyleOptionTabV3 adjustedTab = *tab; if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && ( tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab)) { if (option->direction == Qt::LeftToRight) adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0); else adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0); } QProxyStyle::drawControl(element, &adjustedTab, painter, widget); return; } break; case CE_MenuBarItem: painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120); bool act = mbi->state & State_Sunken; bool dis = !(mbi->state & State_Enabled); Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; QPalette pal = mbi->palette; pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black); item.palette = pal; QCommonStyle::drawControl(element, &item, painter, widget); QRect r = option->rect; if (act) { // Fill| QColor baseColor = Utils::StyleHelper::baseColor(); QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft()); grad.setColorAt(0, baseColor.lighter(120)); grad.setColorAt(1, baseColor.lighter(130)); painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad); // Outline painter->setPen(QPen(highlightOutline, 0)); painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); highlightOutline.setAlpha(60); painter->setPen(QPen(highlightOutline, 0)); painter->drawPoint(r.topLeft()); painter->drawPoint(r.topRight()); QPalette pal = mbi->palette; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60)); drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white); drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); } } painter->restore(); break; case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (panelWidget(widget)) { painter->save(); QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); QPalette customPal = cb->palette; bool drawIcon = !(widget && widget->property("hideicon").toBool()); if (!cb->currentIcon.isNull() && drawIcon) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); if (cb->editable) painter->fillRect(iconRect, customPal.brush(QPalette::Base)); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); else editRect.translate(cb->iconSize.width() + 4, 0); // Reserve some space for the down-arrow editRect.adjust(0, 0, -13, 0); } QLatin1Char asterisk('*'); int elideWidth = editRect.width(); bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool() && cb->currentText.endsWith(asterisk) && option->fontMetrics.width(cb->currentText) > elideWidth; QString text; if (notElideAsterisk) { elideWidth -= option->fontMetrics.width(asterisk); text = asterisk; } text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); if ((option->state & State_Enabled)) { painter->setPen(QColor(0, 0, 0, 70)); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); } else { painter->setOpacity(0.8); } painter->setPen(Utils::StyleHelper::panelTextColor()); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->restore(); } else { QProxyStyle::drawControl(element, option, painter, widget); } } break; case CE_SizeGrip: { painter->save(); QColor dark = Qt::white; dark.setAlphaF(0.1); int x, y, w, h; option->rect.getRect(&x, &y, &w, &h); int sw = qMin(h, w); if (h > w) painter->translate(0, h - w); else painter->translate(w - h, 0); int sx = x; int sy = y; int s = 4; painter->setPen(dark); if (option->direction == Qt::RightToLeft) { sx = x + sw; for (int i = 0; i < 4; ++i) { painter->drawLine(x, sy, sx, sw); sx -= s; sy += s; } } else { for (int i = 0; i < 4; ++i) { painter->drawLine(sx, sw, sw, sy); sx += s; sy += s; } } painter->restore(); } break; case CE_MenuBarEmptyArea: { Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); painter->save(); painter->setPen(Utils::StyleHelper::borderColor()); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->restore(); } break; case CE_ToolBar: { QRect rect = option->rect; bool horizontal = option->state & State_Horizontal; // Map offset for global window gradient QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) - widget->mapToGlobal(option->rect.topLeft()); QRect gradientSpan; if (widget) gradientSpan = QRect(offset, widget->window()->size()); bool drawLightColored = lightColored(widget); if (horizontal) Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); else Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored); if (!drawLightColored) painter->setPen(Utils::StyleHelper::borderColor()); else painter->setPen(QColor(0x888888)); if (horizontal) { // Note: This is a hack to determine if the // toolbar should draw the top or bottom outline // (needed for the find toolbar for instance) QColor lighter(Utils::StyleHelper::sidebarHighlight()); if (drawLightColored) lighter = QColor(255, 255, 255, 180); if (widget && widget->property("topBorder").toBool()) { painter->drawLine(rect.topLeft(), rect.topRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1)); } else { painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft(), rect.topRight()); } } else { painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } } break; default: QProxyStyle::drawControl(element, option, painter, widget); break; } }
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget)) return QProxyStyle::drawControl(element, option, painter, widget); switch (element) { case CE_Splitter: painter->fillRect(option->rect, StyleHelper::borderColor()); break; case CE_TabBarTabShape: // Most styles draw a single dark outline. This looks rather ugly when combined with our // single pixel dark separator so we adjust the first tab to compensate for this if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { QStyleOptionTabV3 adjustedTab = *tab; if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && ( tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab)) { if (option->direction == Qt::LeftToRight) adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0); else adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0); } QProxyStyle::drawControl(element, &adjustedTab, painter, widget); return; } break; case CE_MenuBarItem: painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { QColor highlightOutline = StyleHelper::borderColor().lighter(120); bool act = mbi->state & State_Sunken; bool dis = !(mbi->state & State_Enabled); StyleHelper::menuGradient(painter, option->rect, option->rect); QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; QPalette pal = mbi->palette; pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black); item.palette = pal; QCommonStyle::drawControl(element, &item, painter, widget); QRect r = option->rect; if (act) { // Fill| QColor baseColor = StyleHelper::baseColor(); QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft()); grad.setColorAt(0, baseColor.lighter(120)); grad.setColorAt(1, baseColor.lighter(130)); painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad); // Outline painter->setPen(QPen(highlightOutline, 0)); painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); highlightOutline.setAlpha(60); painter->setPen(QPen(highlightOutline, 0)); painter->drawPoint(r.topLeft()); painter->drawPoint(r.topRight()); QPalette pal = mbi->palette; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60)); drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white); drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); } } painter->restore(); break; case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (panelWidget(widget)) { painter->save(); QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); QPalette customPal = cb->palette; bool drawIcon = !(widget && widget->property("hideicon").toBool()); if (!cb->currentIcon.isNull() && drawIcon) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); if (cb->editable) painter->fillRect(iconRect, customPal.brush(QPalette::Base)); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); else editRect.translate(cb->iconSize.width() + 4, 0); // Reserve some space for the down-arrow editRect.adjust(0, 0, -13, 0); } QLatin1Char asterisk('*'); int elideWidth = editRect.width(); bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool() && cb->currentText.endsWith(asterisk) && option->fontMetrics.width(cb->currentText) > elideWidth; QString text; if (notElideAsterisk) { elideWidth -= option->fontMetrics.width(asterisk); text = asterisk; } text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); if ((option->state & State_Enabled)) { painter->setPen(QColor(0, 0, 0, 70)); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); } else { painter->setOpacity(0.8); } painter->setPen(StyleHelper::panelTextColor()); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->restore(); } else { QProxyStyle::drawControl(element, option, painter, widget); } } break; case CE_SizeGrip: { painter->save(); QColor dark = Qt::white; dark.setAlphaF(0.1); int x, y, w, h; option->rect.getRect(&x, &y, &w, &h); int sw = qMin(h, w); if (h > w) painter->translate(0, h - w); else painter->translate(w - h, 0); int sx = x; int sy = y; int s = 4; painter->setPen(dark); if (option->direction == Qt::RightToLeft) { sx = x + sw; for (int i = 0; i < 4; ++i) { painter->drawLine(x, sy, sx, sw); sx -= s; sy += s; } } else { for (int i = 0; i < 4; ++i) { painter->drawLine(sx, sw, sw, sy); sx += s; sy += s; } } painter->restore(); } break; case CE_MenuBarEmptyArea: { StyleHelper::menuGradient(painter, option->rect, option->rect); painter->save(); painter->setPen(StyleHelper::borderColor()); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->restore(); } break; case CE_ToolBar: { QRect rect = option->rect; bool horizontal = option->state & State_Horizontal; rect = option->rect; // Map offset for global window gradient QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) - widget->mapToGlobal(option->rect.topLeft()); QRect gradientSpan; if (widget) gradientSpan = QRect(offset, widget->window()->size()); bool drawLightColored = lightColored(widget); if (horizontal) StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); else StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored); if (!drawLightColored) painter->setPen(StyleHelper::borderColor()); else painter->setPen(QColor(0x888888)); if (horizontal) { // Note: This is a hack to determine if the // toolbar should draw the top or bottom outline // (needed for the find toolbar for instance) QColor lighter(StyleHelper::sidebarHighlight()); if (drawLightColored) lighter = QColor(255, 255, 255, 180); if (widget && widget->property("topBorder").toBool()) { painter->drawLine(rect.topLeft(), rect.topRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1)); } else { painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft(), rect.topRight()); } } else { painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } } break; #if defined(Q_OS_MAC) case CE_ToolButtonLabel: if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { QStyleOptionToolButton myTb = *tb; myTb.state &= ~State_AutoRaise; QRect cr = tb->rect; bool needText = false; int alignment = 0; bool down = tb->state & (State_Sunken | State_On); // The down state is special for QToolButtons in a toolbar on the Mac // The text is a bit bolder and gets a drop shadow and the icons are also darkened. // This doesn't really fit into any particular case in QIcon, so we // do the majority of the work ourselves. if (!(tb->features & QStyleOptionToolButton::Arrow)) { Qt::ToolButtonStyle tbstyle = tb->toolButtonStyle; if (tb->icon.isNull() && !tb->text.isEmpty()) tbstyle = Qt::ToolButtonTextOnly; switch (tbstyle) { case Qt::ToolButtonTextOnly: { needText = true; alignment = Qt::AlignCenter; break; } case Qt::ToolButtonIconOnly: case Qt::ToolButtonTextBesideIcon: case Qt::ToolButtonTextUnderIcon: { QRect pr = cr; QIcon::Mode iconMode = (tb->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; QIcon::State iconState = (tb->state & State_On) ? QIcon::On : QIcon::Off; QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState); // Draw the text if it's needed. if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { needText = true; if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { QMainWindow *mw = widget ? qobject_cast<QMainWindow *>(widget->window()) : 0; if (mw && mw->unifiedTitleAndToolBarOnMac()) { pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio()); cr.adjust(0, pr.bottom() + 1, 0, 1); } else { pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); cr.adjust(0, pr.bottom(), 0, -3); } alignment |= Qt::AlignCenter; } else { pr.setWidth(pixmap.width() / pixmap.devicePixelRatio() + 8); cr.adjust(pr.right(), 0, 0, 0); alignment |= Qt::AlignLeft | Qt::AlignVCenter; } } proxy()->drawItemPixmap(painter, pr, Qt::AlignCenter, pixmap); break; } default: Q_ASSERT(false); break; } if (needText) { QPalette pal = tb->palette; QPalette::ColorRole role = QPalette::WindowText; if (!proxy()->styleHint(SH_UnderlineShortcut, tb, widget)) alignment |= Qt::TextHideMnemonic; if (tbstyle == Qt::ToolButtonTextOnly || (tbstyle != Qt::ToolButtonTextOnly && !down)) { painter->drawText(cr, alignment, tb->text); if (down && tbstyle == Qt::ToolButtonTextOnly) { pal = QApplication::palette("QMenu"); pal.setCurrentColorGroup(tb->palette.currentColorGroup()); role = QPalette::HighlightedText; } } proxy()->drawItemText(painter, cr, alignment, pal, tb->state & State_Enabled, tb->text, role); } } else { QProxyStyle::drawControl(element, option, painter, widget); } } break; #endif default: QProxyStyle::drawControl(element, option, painter, widget); break; } }
boost::shared_ptr< LogicalQueryPlanNode> Optimizer::logicalRewriteIfNeeded(const boost::shared_ptr<Query>& query, boost::shared_ptr< LogicalQueryPlanNode> instance) { //rewrite load(array,'filename') into store(input(array,'filename'),array) //Note: this rewrite mechanism should be // 1. generic // 2. user-extensible //Note: optimizer also performs rewrites like "sum" -> "sum2(sum)" but we can't do these here because: // 1. they are physical; not logical // 2. they are recursive. We don't want logical rewrites to be recursive. OperatorLibrary *olib = OperatorLibrary::getInstance(); if (instance->getLogicalOperator()->getLogicalName()=="load") { boost::shared_ptr< LogicalOperator> loadOperator = instance->getLogicalOperator(); LogicalOperator::Parameters loadParameters = loadOperator->getParameters(); ArrayDesc outputSchema = loadOperator->getSchema(); boost::shared_ptr< LogicalOperator> inputOperator = olib->createLogicalOperator("input"); inputOperator->setParameters(loadParameters); inputOperator->setSchema(outputSchema); boost::shared_ptr< OperatorParam> paramArrayName = loadParameters[0]; if ( query->getInstancesCount() == 1) { boost::shared_ptr< LogicalOperator> storeOperator = olib->createLogicalOperator("store"); storeOperator->addParameter(paramArrayName); std::vector< ArrayDesc> storeInputSchemas; storeInputSchemas.push_back(inputOperator->getSchema()); storeOperator->setSchema(storeOperator->inferSchema(storeInputSchemas, query)); boost::shared_ptr< LogicalQueryPlanNode> inputInstance( new LogicalQueryPlanNode (instance->getParsingContext(), inputOperator)); boost::shared_ptr< LogicalQueryPlanNode> storeInstance( new LogicalQueryPlanNode (instance->getParsingContext(), storeOperator)); //load instance does not have any children. so the input instance will also have none. assert(instance->getChildren().size()==0); storeInstance->addChild(inputInstance); return storeInstance; } else { LogicalOperator::Parameters sgParams(3); Value ival(TypeLibrary::getType(TID_INT32)); ival.setInt32(psRoundRobin); sgParams[0] = boost::shared_ptr<OperatorParam>( new OperatorParamLogicalExpression(instance->getParsingContext(), boost::shared_ptr<LogicalExpression>(new Constant(instance->getParsingContext(), ival, TID_INT32)), TypeLibrary::getType(TID_INT32), true)); ival.setInt32(-1); sgParams[1] = boost::shared_ptr<OperatorParam>( new OperatorParamLogicalExpression(instance->getParsingContext(), boost::shared_ptr<LogicalExpression>(new Constant(instance->getParsingContext(), ival, TID_INT32)), TypeLibrary::getType(TID_INT32), true)); sgParams[2] = paramArrayName; boost::shared_ptr< LogicalOperator> sgOperator = olib->createLogicalOperator("sg"); sgOperator->setParameters(sgParams); std::vector< ArrayDesc> sgInputSchemas; sgInputSchemas.push_back(inputOperator->getSchema()); sgOperator->setSchema(sgOperator->inferSchema(sgInputSchemas,query)); boost::shared_ptr< LogicalQueryPlanNode> inputInstance( new LogicalQueryPlanNode (instance->getParsingContext(), inputOperator)); boost::shared_ptr< LogicalQueryPlanNode> sgInstance( new LogicalQueryPlanNode (instance->getParsingContext(), sgOperator)); //load instance does not have any children. so the input instance will also have none. assert(instance->getChildren().size()==0); sgInstance->addChild(inputInstance); return sgInstance; } } else if (instance->getLogicalOperator()->getLogicalName()=="sum" || instance->getLogicalOperator()->getLogicalName()=="avg" || instance->getLogicalOperator()->getLogicalName()=="min" || instance->getLogicalOperator()->getLogicalName()=="max" || instance->getLogicalOperator()->getLogicalName()=="stdev" || instance->getLogicalOperator()->getLogicalName()=="var" || instance->getLogicalOperator()->getLogicalName()=="count") { boost::shared_ptr< LogicalOperator> oldStyleOperator = instance->getLogicalOperator(); boost::shared_ptr< LogicalOperator> aggOperator = olib->createLogicalOperator("aggregate"); aggOperator->setSchema(oldStyleOperator->getSchema()); LogicalOperator::Parameters oldStyleParams = oldStyleOperator->getParameters(); if (instance->getLogicalOperator()->getLogicalName()=="count") { shared_ptr<OperatorParam> asterisk (new OperatorParamAsterisk(instance->getParsingContext())); shared_ptr<OperatorParam> aggCall ( new OperatorParamAggregateCall (instance->getParsingContext(), instance->getLogicalOperator()->getLogicalName(), asterisk, "")); aggOperator->addParameter(aggCall); } else if (oldStyleParams.size() == 0) { ArrayDesc const& inputSchema = instance->getChildren()[0]->getLogicalOperator()->getSchema(); shared_ptr<OperatorParamReference> attRef ( new OperatorParamAttributeReference(instance->getParsingContext(), inputSchema.getName(), inputSchema.getAttributes()[0].getName(), true)); attRef->setInputNo(0); attRef->setObjectNo(0); shared_ptr<OperatorParam> aggCall ( new OperatorParamAggregateCall (instance->getParsingContext(), instance->getLogicalOperator()->getLogicalName(), attRef, "")); aggOperator->addParameter(aggCall); } for (size_t i =0; i<oldStyleParams.size(); i++) { if (oldStyleParams[i]->getParamType() == PARAM_ATTRIBUTE_REF) { shared_ptr<OperatorParam> aggCall ( new OperatorParamAggregateCall (oldStyleParams[i]->getParsingContext(), instance->getLogicalOperator()->getLogicalName(), oldStyleParams[i], "")); aggOperator->addParameter(aggCall); } else if (oldStyleParams[i]->getParamType() == PARAM_DIMENSION_REF) { aggOperator->addParameter(oldStyleParams[i]); } } boost::shared_ptr< LogicalQueryPlanNode> aggInstance( new LogicalQueryPlanNode (instance->getParsingContext(), aggOperator)); assert(instance->getChildren().size() == 1); aggInstance->addChild(instance->getChildren()[0]); return aggInstance; } else { return instance; } }