void SortedAggExecStream::open(bool restart)
{
    ConduitExecStream::open(restart);
    clearAccumulator();

    /*
      When accumulating, the first tuple in a group always updates the
      accumulator result field. Compare the group by key fields only for
      subsequent tuples. We use prevTupleValid to mark if the first tuple
      was seen.
      Need to set this in open() so that when the same stream is re-executed,
      e.g. when two identical group by statements are issued, the state when
      receiving the first input tuple of the first group is correct.
      Ignore prevTupleValid field when not doing groupby's.
    */
    prevTupleValid = (groupByKeyCount > 0) ? false : true;

    state = STATE_ACCUMULATING;
}
Beispiel #2
0
void Particle::integrate(float duration)
{
	if (getInverseMass() <= 0.0f)
	{
		return;
	}

	assert(duration > 0.0f);

	mPosition.addScaledVector(mVelocity, duration);

	Vector3 resultingAcc = mAcceleration;
	resultingAcc.addScaledVector(mForceAccumulation, getInverseMass());

	mVelocity.addScaledVector(resultingAcc, duration);

	//mVelocity =  mVelocity * powf(mDamping, duration);
	
	clearAccumulator();
}
inline ExecStreamResult SortedAggExecStream::produce()
{
    assert(state == STATE_PRODUCING);

    // attempt to write output
    bool success = pOutAccessor->produceTuple(outputTuple);
    if (success) {
        clearAccumulator();
        state = STATE_ACCUMULATING;
        /*
          Succeeded in outputting result for the previous group.
          Record new group by key and update accumulator result fields.
        */
        copyPrevGroupByKey();
        updateAccumulator();
        pInAccessor->consumeTuple();
        return EXECRC_YIELD;
    } else {
        return EXECRC_BUF_OVERFLOW;
    }
}
Beispiel #4
0
void Particle::integrate(float duration)
{
   // We don't integrate things with zero mass.
   if (m_inverseMass <= 0.0f) 
      return;

   assert(duration > 0.0);

   // Update linear position.
   m_position.addScaledVector(m_velocity, duration);

   // Work out the acceleration from the force
   Vector3 resultingAcc = m_acceleration;
   resultingAcc.addScaledVector(m_forceAccum, m_inverseMass);

   // Update linear velocity from the acceleration.
   m_velocity.addScaledVector(resultingAcc, duration);

   // Impose drag.
   m_velocity *= powf(m_damping, duration);

   // Clear the forces.
   clearAccumulator();
}