Ejemplo n.º 1
0
// ***************************************************************************
// Initialize internal data structures.
// ***************************************************************************
void JBBDetails::init(CollHeap* heap)
{
  // Check if this JBB has a GroupBy in it.
  const QRGroupByPtr groupBy = jbbDesc_->getGroupBy();
  if (groupBy != NULL)
  {
    hasGroupBy_ = TRUE;
    hasEmptyGroupBy_ = groupBy->isEmpty();
  }

  initBaseTables(heap);
  initRangePreds(heap);  // For query descriptors, partial init only.

  if (isAnMV_)
  {
    // Init residual predicate data stuctures for MVs only.
    initResidualPreds(heap);
  }
  else
  {
    // This is a query descriptor.
    // Check if it explicitly uses MVs, and if so - replace them so that
    // the query will be only on base tables.
    // TBD...
  }
}
NABoolean QRGroupLattice::getGroupingLatticeKeys(LatticeKeyList&         keyList,
                                                 QRJoinSubGraphMapPtr    map,
						 DescriptorDetailsPtr    queryDetails, 
                                                 const QRJBBPtr          jbb,
                                                 NABoolean               primaryOnly,
                                                 NABoolean               insertMode)
{
  QRTRACER("QRGroupLattice::getGroupingLatticeKeys()");
  // Start with the list of primary grouping columns in the Hub.
  const QRGroupByPtr groupBy = jbb->getGroupBy();
  // In the aggregate with no GroupBy case, return an empty list.
  if (groupBy->isEmpty())
    return TRUE;

  const ElementPtrList& gbList = groupBy->getPrimaryList()->getList();
  NABoolean ok = elementListToKeyList(gbList, keyList, map, queryDetails, insertMode);
  if (!ok)
    return FALSE;

  if (primaryOnly)
    return TRUE;

  // Now check for dependent grouping columns in the extra-Hub.
  QRDependentGroupByPtr depGroupBy = groupBy->getDependentList();
  if (depGroupBy != NULL)
  {
    const ElementPtrList& depKeyList = depGroupBy->getList();
    if (!depKeyList.isEmpty())
    {
      // Dependent grouping columns found - add them to the key list.
      ok = elementListToKeyList(depKeyList, keyList, map, queryDetails, insertMode);
      if (!ok)
        return FALSE;
    }
  }

  return TRUE;
}