当前位置: 首页>>代码示例>>C++>>正文


C++ CConstraint类代码示例

本文整理汇总了C++中CConstraint的典型用法代码示例。如果您正苦于以下问题:C++ CConstraint类的具体用法?C++ CConstraint怎么用?C++ CConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CConstraintConjunction::Pcnstr
//
//	@doc:
//		Return constraint on a given column
//
//---------------------------------------------------------------------------
CConstraint *
CConstraintConjunction::Pcnstr
	(
	IMemoryPool *mp,
	const CColRef *colref
	)
{
	// all children referencing given column
	CConstraintArray *pdrgpcnstrCol = m_phmcolconstr->Find(colref);
	if (NULL == pdrgpcnstrCol)
	{
		return NULL;
	}

	CConstraintArray *pdrgpcnstr = GPOS_NEW(mp) CConstraintArray(mp);

	const ULONG length = pdrgpcnstrCol->Size();
	for (ULONG ul = 0; ul < length; ul++)
	{
		// the part of the child that references this column
		CConstraint *pcnstrCol = (*pdrgpcnstrCol)[ul]->Pcnstr(mp, colref);
		if (NULL == pcnstrCol || pcnstrCol->IsConstraintUnbounded())
		{
			CRefCount::SafeRelease(pcnstrCol);
			continue;
		}
		pdrgpcnstr->Append(pcnstrCol);
	}

	return CConstraint::PcnstrConjunction(mp, pdrgpcnstr);
}
开发者ID:b-xiang,项目名称:gporca,代码行数:39,代码来源:CConstraintConjunction.cpp

示例2: GPOS_ASSERT

//---------------------------------------------------------------------------
//	@function:
//		CPartConstraint::FSubsume
//
//	@doc:
//		Does constraint subsume given one
//
//---------------------------------------------------------------------------
BOOL
CPartConstraint::FSubsume
	(
	const CPartConstraint *ppartcnstr
	)
	const
{
	GPOS_ASSERT(NULL != ppartcnstr);
	GPOS_ASSERT(!m_fUninterpreted && "Calling FSubsume on uninterpreted partition constraint");

	if (IsConstraintUnbounded())
	{
		return true;
	}

	if (ppartcnstr->IsConstraintUnbounded())
	{
		return false;
	}

	BOOL fSubsumeLevel = true;
	for (ULONG ul = 0; ul < m_num_of_part_levels && fSubsumeLevel; ul++)
	{
		CConstraint *pcnstrCurrent = Pcnstr(ul);
		CConstraint *pcnstrOther = ppartcnstr->Pcnstr(ul);
		GPOS_ASSERT(NULL != pcnstrCurrent);
		GPOS_ASSERT(NULL != pcnstrOther);

		fSubsumeLevel = pcnstrCurrent->Contains(pcnstrOther) &&
						(IsDefaultPartition(ul) || !ppartcnstr->IsDefaultPartition(ul));
	}

	return fSubsumeLevel;
}
开发者ID:b-xiang,项目名称:gporca,代码行数:42,代码来源:CPartConstraint.cpp

示例3: arpdrgpcnstr

// mapping between columns and single column constraints in array of constraints
static
HMColConstr *
PhmcolconstrSingleColConstr
	(
		IMemoryPool *pmp,
		DrgPcnstr *drgPcnstr
	)
{
	CAutoRef<DrgPcnstr> arpdrgpcnstr(drgPcnstr);
	HMColConstr *phmcolconstr = GPOS_NEW(pmp) HMColConstr(pmp);

	const ULONG ulLen = arpdrgpcnstr->UlLength();

	for (ULONG ul = 0; ul < ulLen; ul++)
	{
		CConstraint *pcnstrChild = (*arpdrgpcnstr)[ul];
		CColRefSet *pcrs = pcnstrChild->PcrsUsed();

		if (1 == pcrs->CElements())
		{
			CColRef *pcr = pcrs->PcrFirst();
			DrgPcnstr *pcnstrMapped = phmcolconstr->PtLookup(pcr);
			if (NULL == pcnstrMapped)
			{
				pcnstrMapped = GPOS_NEW(pmp) DrgPcnstr(pmp);
				phmcolconstr->FInsert(pcr, pcnstrMapped);
			}
			pcnstrChild->AddRef();
			pcnstrMapped->Append(pcnstrChild);
		}
	}

	return phmcolconstr;
}
开发者ID:MoZhonghua,项目名称:gporca,代码行数:35,代码来源:CColConstraintsHashMapper.cpp

示例4:

//---------------------------------------------------------------------------
//	@function:
//		CPartConstraint::FEqualConstrMaps
//
//	@doc:
//		Check if two constaint maps have the same constraints
//
//---------------------------------------------------------------------------
BOOL
CPartConstraint::FEqualConstrMaps
	(
	UlongToConstraintMap *phmulcnstrFst,
	UlongToConstraintMap *phmulcnstrSnd,
	ULONG ulLevels
	)
{
	if (phmulcnstrFst->Size() != phmulcnstrSnd->Size())
	{
		return false;
	}

	for (ULONG ul = 0; ul < ulLevels; ul++)
	{
		CConstraint *pcnstrFst = phmulcnstrFst->Find(&ul);
		CConstraint *pcnstrSnd = phmulcnstrSnd->Find(&ul);

		if ((NULL == pcnstrFst || NULL == pcnstrSnd) && pcnstrFst != pcnstrSnd)
		{
			return false;
		}

		if (NULL != pcnstrFst && !pcnstrFst->Equals(pcnstrSnd))
		{
			return false;
		}
	}

	return true;
}
开发者ID:b-xiang,项目名称:gporca,代码行数:39,代码来源:CPartConstraint.cpp

示例5: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CConstraint::PdrgpcnstrOnColumn
//
//	@doc:
//		Return a subset of the given constraints which reference the
//		given column
//
//---------------------------------------------------------------------------
DrgPcnstr *
CConstraint::PdrgpcnstrOnColumn
(
    IMemoryPool *pmp,
    DrgPcnstr *pdrgpcnstr,
    CColRef *pcr,
    BOOL fExclusive		// returned constraints must reference ONLY the given col
)
{
    DrgPcnstr *pdrgpcnstrSubset = GPOS_NEW(pmp) DrgPcnstr(pmp);

    const ULONG ulLen = pdrgpcnstr->UlLength();

    for (ULONG ul = 0; ul < ulLen; ul++)
    {
        CConstraint *pcnstr = (*pdrgpcnstr)[ul];
        CColRefSet *pcrs = pcnstr->PcrsUsed();

        // if the fExclusive flag is true, then pcr must be the only column
        if (pcrs->FMember(pcr) && (!fExclusive || 1 == pcrs->CElements()))
        {
            pcnstr->AddRef();
            pdrgpcnstrSubset->Append(pcnstr);
        }
    }

    return pdrgpcnstrSubset;
}
开发者ID:hsyuan,项目名称:gporca,代码行数:37,代码来源:CConstraint.cpp

示例6: CConstraint

//---------------------------------------------------------------------------
//	@function:
//		CConstraintConjunction::CConstraintConjunction
//
//	@doc:
//		Ctor
//
//---------------------------------------------------------------------------
CConstraintConjunction::CConstraintConjunction
	(
	IMemoryPool *mp,
	CConstraintArray *pdrgpcnstr
	)
	:
	CConstraint(mp),
	m_pdrgpcnstr(NULL)
{
	GPOS_ASSERT(NULL != pdrgpcnstr);
	m_pdrgpcnstr = PdrgpcnstrFlatten(mp, pdrgpcnstr, EctConjunction);

	const ULONG length = m_pdrgpcnstr->Size();
	GPOS_ASSERT(0 < length);

	m_pcrsUsed = GPOS_NEW(mp) CColRefSet(mp);

	for (ULONG ul = 0; ul < length; ul++)
	{
		CConstraint *pcnstr = (*m_pdrgpcnstr)[ul];
		m_pcrsUsed->Include(pcnstr->PcrsUsed());
	}

	m_phmcolconstr = Phmcolconstr(mp, m_pcrsUsed, m_pdrgpcnstr);
}
开发者ID:b-xiang,项目名称:gporca,代码行数:33,代码来源:CConstraintConjunction.cpp

示例7: GPOS_ASSERT

//---------------------------------------------------------------------------
//	@function:
//		CLogicalSetOp::PcnstrColumn
//
//	@doc:
//		Get constraint for a given output column from a given children
//
//---------------------------------------------------------------------------
CConstraint *
CLogicalSetOp::PcnstrColumn
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl,
	ULONG ulColIndex,
	ULONG ulChild
	)
	const
{
	GPOS_ASSERT(ulChild < exprhdl.UlArity());

	// constraint from child
	CConstraint *pcnstrChild = exprhdl.Pdprel(ulChild)->Ppc()->Pcnstr();
	if (NULL == pcnstrChild)
	{
		return NULL;
	}

	// part of constraint on the current input column
	CConstraint *pcnstrCol = pcnstrChild->Pcnstr(pmp, (*(*m_pdrgpdrgpcrInput)[ulChild])[ulColIndex]);
	if (NULL == pcnstrCol)
	{
		return NULL;
	}

	// make a copy of this constraint but for the output column instead
	CConstraint *pcnstrOutput = pcnstrCol->PcnstrRemapForColumn(pmp, (*m_pdrgpcrOutput)[ulColIndex]);
	pcnstrCol->Release();
	return pcnstrOutput;
}
开发者ID:MoZhonghua,项目名称:gporca,代码行数:39,代码来源:CLogicalSetOp.cpp

示例8: GPOS_ASSERT

//---------------------------------------------------------------------------
//	@function:
//		CConstraint::PcnstrConjDisj
//
//	@doc:
//		Create conjunction/disjunction from array of constraints
//
//---------------------------------------------------------------------------
CConstraint *
CConstraint::PcnstrConjDisj
(
    IMemoryPool *pmp,
    DrgPcnstr *pdrgpcnstr,
    BOOL fConj
)
{
    GPOS_ASSERT(NULL != pdrgpcnstr);

    CConstraint *pcnstr = NULL;

    const ULONG ulLen = pdrgpcnstr->UlLength();

    switch (ulLen)
    {
    case 0:
    {
        pdrgpcnstr->Release();
        break;
    }

    case 1:
    {
        pcnstr = (*pdrgpcnstr)[0];
        pcnstr->AddRef();
        pdrgpcnstr->Release();
        break;
    }

    default:
    {
        if (fConj)
        {
            pcnstr = GPOS_NEW(pmp) CConstraintConjunction(pmp, pdrgpcnstr);
        }
        else
        {
            pcnstr = GPOS_NEW(pmp) CConstraintDisjunction(pmp, pdrgpcnstr);
        }
    }
    }

    return pcnstr;
}
开发者ID:hsyuan,项目名称:gporca,代码行数:53,代码来源:CConstraint.cpp

示例9: applyAllPositionConstraints

void CSimuEntity::applyAllPositionConstraints(const double &current_tm, const double &dt)
{
	{//apply collision constraints, which has the lowest priority
		CCollisionConstraint *p = m_pCollisionConstraint;
		if (p && p->isEnabled() && (!p->isExpired(current_tm))){
			p->applyConstraint(this, current_tm, dt);
		}
	}

	//other constraints, user specified
	for (int i=0; i<CONSTRAINT_BUFF_LENGTH; i++){
		CConstraint *p = m_pConstraints[i];
		if (p){
			if (p->isEnabled() && (!p->isExpired(current_tm)))
				p->applyConstraint(this, current_tm, dt);
		}
	}
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:18,代码来源:simu_entity.cpp

示例10: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CLogical::PpcDeriveConstraintFromTableWithPredicates
//
//	@doc:
//		Derive constraint property from a table/index get with predicates
//
//---------------------------------------------------------------------------
CPropConstraint *
CLogical::PpcDeriveConstraintFromTableWithPredicates
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl,
	const CTableDescriptor *ptabdesc,
	const DrgPcr *pdrgpcrOutput
	)
{
	DrgPcnstr *pdrgpcnstr = GPOS_NEW(pmp) DrgPcnstr(pmp);
	CPropConstraint *ppcTable = PpcDeriveConstraintFromTable(pmp, ptabdesc, pdrgpcrOutput);
	CConstraint *pcnstrTable = ppcTable->Pcnstr();
	if (NULL != pcnstrTable)
	{
		pcnstrTable->AddRef();
		pdrgpcnstr->Append(pcnstrTable);
	}
	DrgPcrs *pdrgpcrsEquivClassesTable = ppcTable->PdrgpcrsEquivClasses();

	CPropConstraint *ppcnstrCond = PpcDeriveConstraintFromPredicates(pmp, exprhdl);
	CConstraint *pcnstrCond = ppcnstrCond->Pcnstr();

	if (NULL != pcnstrCond)
	{
		pcnstrCond->AddRef();
		pdrgpcnstr->Append(pcnstrCond);
	}
	else if (NULL == pcnstrTable)
	{
		ppcTable->Release();
		pdrgpcnstr->Release();

		return ppcnstrCond;
	}

	DrgPcrs *pdrgpcrsCond = ppcnstrCond->PdrgpcrsEquivClasses();
	DrgPcrs *pdrgpcrs = CUtils::PdrgpcrsMergeEquivClasses(pmp, pdrgpcrsEquivClassesTable, pdrgpcrsCond);
	CPropConstraint *ppc = GPOS_NEW(pmp) CPropConstraint(pmp, pdrgpcrs, CConstraint::PcnstrConjunction(pmp, pdrgpcnstr));

	ppcnstrCond->Release();
	ppcTable->Release();

	return ppc;
}
开发者ID:HanumathRao,项目名称:gporca,代码行数:52,代码来源:CLogical.cpp

示例11: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CPartConstraint::PcnstrBuildCombined
//
//	@doc:
//		Construct the combined constraint
//
//---------------------------------------------------------------------------
CConstraint *
CPartConstraint::PcnstrBuildCombined
	(
	IMemoryPool *mp
	)
{
	CConstraintArray *pdrgpcnstr = GPOS_NEW(mp) CConstraintArray(mp);
	for (ULONG ul = 0; ul < m_num_of_part_levels; ul++)
	{
		CConstraint *pcnstr = m_phmulcnstr->Find(&ul);
		if (NULL != pcnstr)
		{
			pcnstr->AddRef();
			pdrgpcnstr->Append(pcnstr);
		}
	}

	return CConstraint::PcnstrConjunction(mp, pdrgpcnstr);
}
开发者ID:b-xiang,项目名称:gporca,代码行数:27,代码来源:CPartConstraint.cpp

示例12: Pcnstr

//---------------------------------------------------------------------------
//	@function:
//		CPartConstraint::FCanNegate
//
//	@doc:
//		Check whether or not the current part constraint can be negated. A part
//		constraint can be negated only if it has constraints on the first level
//
//---------------------------------------------------------------------------
BOOL
CPartConstraint::FCanNegate() const
{
	// first level cannot be NULL
	if (NULL == Pcnstr(0))
	{
		return false;
	}

	// all levels after the first must be unconstrained
	for (ULONG ul = 1; ul < m_num_of_part_levels; ul++)
	{
		CConstraint *pcnstr = Pcnstr(ul);
		if (NULL == pcnstr || !pcnstr->IsConstraintUnbounded())
		{
			return false;
		}
	}

	return true;
}
开发者ID:b-xiang,项目名称:gporca,代码行数:30,代码来源:CPartConstraint.cpp

示例13: addConstraint

void CSimuEntity::addConstraint(const CConstraint *pconstraint)
{
	int i, j;
	//find the right position using linear search
	const int nprior = pconstraint->getPrior();
	for (i=0; i<CONSTRAINT_BUFF_LENGTH-1; i++){
		CConstraint *p = m_pConstraints[i];	
		if (p){
			const int n1 = p->getPrior();
			if (n1>nprior) break;
		}
		else{
			m_pConstraints[i] = (CConstraint *)pconstraint;
			return;
		}
	}
	//insert and move 
	for (j=CONSTRAINT_BUFF_LENGTH-1; j>i; j--)
		m_pConstraints[j] = m_pConstraints[j-1];	
	m_pConstraints[i] = (CConstraint *)pconstraint;
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:21,代码来源:simu_entity.cpp

示例14: VerifyConstraint

DLL_DECL bool 
VerifyConstraint(const char *constraint)
{
	bool ret = true;
    if (!CManager::theInstance->HasConstraints())
		return ret;

	CDynConstraintSetList & setlist = CManager::theInstance->GetConstraintSets();

	POSITION sl_pos = setlist.GetHeadPosition();
	bool found=false;
	while (sl_pos && !found)
	{
		CDynConstraintSet * setlist_i = setlist.GetNext(sl_pos);
		CDynConstraintList& list = setlist_i->GetConstraints();
		POSITION pos1 = list.GetHeadPosition();
		while(pos1)
		{
			CDynConstraint *cur = list.GetNext(pos1);
			const CString& nm  = cur->GetName();

			if (nm==CString(constraint))
			{
				CConstraint *con = (CConstraint *)cur->GetCore();
				CString err_str, what;
				bool isvalid = con->Verify(err_str, what);
				if(!isvalid)
				{
					CCSetErrDialog cse_dialog;
					cse_dialog.AddError(NULL,*cur, *(cur->GetContext()), (LPCTSTR)err_str,  what);
				}
				found = true;
				break;
			}
		}
	}

	return ret;
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:39,代码来源:desert.cpp

示例15: crsi

//---------------------------------------------------------------------------
//	@function:
//		CConstraint::FContains
//
//	@doc:
//		Does the current constraint contain the given one?
//
//---------------------------------------------------------------------------
BOOL
CConstraint::FContains
(
    CConstraint *pcnstr
)
{
    if (FUnbounded())
    {
        return true;
    }

    if (NULL == pcnstr || pcnstr->FUnbounded())
    {
        return false;
    }

    if (this == pcnstr)
    {
        // a constraint always contains itself
        return true;
    }

    // check if we have computed this containment query before
    BOOL *pfContains = m_phmcontain->PtLookup(pcnstr);
    if (NULL != pfContains)
    {
        return *pfContains;
    }

    BOOL fContains = true;

    // for each column used by the current constraint, we have to make sure that
    // the constraint on this column contains the corresponding given constraint
    CColRefSetIter crsi(*m_pcrsUsed);
    while (fContains && crsi.FAdvance())
    {
        CColRef *pcr = crsi.Pcr();
        CConstraint *pcnstrColThis = Pcnstr(m_pmp, pcr);
        GPOS_ASSERT (NULL != pcnstrColThis);
        CConstraint *pcnstrColOther = pcnstr->Pcnstr(m_pmp, pcr);

        // convert each of them to interval (if they are not already)
        CConstraintInterval *pciThis = CConstraintInterval::PciIntervalFromConstraint(m_pmp, pcnstrColThis, pcr);
        CConstraintInterval *pciOther = CConstraintInterval::PciIntervalFromConstraint(m_pmp, pcnstrColOther, pcr);

        fContains = pciThis->FContainsInterval(m_pmp, pciOther);
        pciThis->Release();
        pciOther->Release();
        pcnstrColThis->Release();
        CRefCount::SafeRelease(pcnstrColOther);
    }

    // insert containment query into the local map
#ifdef GPOS_DEBUG
    BOOL fSuccess =
#endif // GPOS_DEBUG
        m_phmcontain->FInsert(pcnstr, PfVal(fContains));
    GPOS_ASSERT(fSuccess);

    return fContains;
}
开发者ID:hsyuan,项目名称:gporca,代码行数:69,代码来源:CConstraint.cpp


注:本文中的CConstraint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。