RddResultCode SsbQ1_1Transformer::transform(TransformerContext* ctx, const BaseRddPartition* input, PairRddPartition* output) {
  auto param = ctx->getParamRdds().at(0);
  if (input->empty() || param->empty()) {
    return RRC_SUCCESS;
  }

  auto op = ctx->getRddOperator();
  auto paramOp = op->paramOperators.at(0);
  auto exprCtx = ctx->getExpressionContext();

  auto keyTemplate = param->getKeyTemplate();
  auto valueTemplate = param->getValueTemplate();
  auto dateDes = keyTemplate->GetDescriptor();
  auto dateRef = keyTemplate->GetReflection();
  auto dateField = dateDes->FindFieldByName("d_datekey");

  set<uint64_t> marchedDate;

  param->foreach([&marchedDate, paramOp, &exprCtx, dateRef, dateField] (const PbMessagePtr& key, const PbMessagePtr& value) {
    idgs::actor::PbMessagePtr outkey, outvalue;
    exprCtx->setKeyValue(&key, &value);
    exprCtx->setOutputKeyValue(&outkey, &outvalue);

    if (paramOp->evaluate(exprCtx)) {
      marchedDate.insert(dateRef->GetUInt64(* key, dateField));
    }
  });

  valueTemplate = input->getValueTemplate();
  auto orderDes = valueTemplate->GetDescriptor();
  auto orderRef = valueTemplate->GetReflection();
  auto orderDateField = orderDes->FindFieldByName("lo_orderdate");

  input->foreach([marchedDate, output, op, &exprCtx, orderRef, orderDateField] (const PbMessagePtr& key, const PbMessagePtr& value) {
    idgs::actor::PbMessagePtr outkey, outvalue;
    exprCtx->setKeyValue(&key, &value);
    exprCtx->setOutputKeyValue(&outkey, &outvalue);

    if (op->evaluate(exprCtx)) {
      uint64_t orderdate = orderRef->GetUInt64(* value, orderDateField);

      if(marchedDate.find(orderdate) != marchedDate.end()) {
        output->put(key, value);
      }
    }
  });

  return RRC_SUCCESS;
}
Exemplo n.º 2
0
RddResultCode SsbQ1_1Transformer::transform(const ActorMessagePtr& msg, const std::vector<BaseRddPartition*>& input,
    RddPartition* output) {
  if (input.size() != 2) {
    return RRC_INVALID_RDD_INPUT;
  }

  if (input[0]->empty() || input[1]->empty()) {
    return RRC_SUCCESS;
  }

  auto orderExp = output->getFilterExpression(0);
  auto dateExp = output->getFilterExpression(1);

  auto valueTemplate = input[0]->getValueTemplate();
  auto orderDes = valueTemplate->GetDescriptor();
  auto orderRef = valueTemplate->GetReflection();
  auto orderDateField = orderDes->FindFieldByName("lo_orderdate");

  auto keyTemplate = input[1]->getKeyTemplate();
  valueTemplate = input[1]->getValueTemplate();
  auto dateDes = keyTemplate->GetDescriptor();
  auto dateRef = keyTemplate->GetReflection();
  auto dateField = dateDes->FindFieldByName("d_datekey");

  set<uint64_t> marchedDate;
  ExpressionContext ctx;
  input[1]->foreach(
      [&marchedDate, dateExp, dateRef, dateField, &ctx] (const PbMessagePtr& key, const PbMessagePtr& value) {
        ctx.setKeyValue(&key, &value);
        if ((bool) dateExp->evaluate(&ctx)) {
          marchedDate.insert(dateRef->GetUInt64(*key, dateField));
        }
      });

  input[0]->foreach(
      [marchedDate, output, orderExp, orderRef, orderDateField, dateRef, dateField, &ctx] (const PbMessagePtr& key, const PbMessagePtr& value) {
        ctx.setKeyValue(&key, &value);
        if ((bool) orderExp->evaluate(&ctx)) {
          uint64_t orderdate = orderRef->GetUInt64(* value, orderDateField);

          if(marchedDate.find(orderdate) != marchedDate.end()) {
            output->putLocal(key, value);
          }
        }
      });

  return RRC_SUCCESS;
}
Exemplo n.º 3
0
Color<real> BlinnPhongShader<real>::Shade()
{
    Color<real> finalColor( 0, 0, 0, 1 );
    const LightVector& lights = mScene.GetLights();

    ////////////////////////////////////////////
    //////////////////IFT 3355//////////////////
    ////////////////////////////////////////////
    //Ici, vous assemblerez toutes les
    //composantes (ambient, diffus, spéculaire,
    //réflexion, réfraction). Vous ferez
    //également en sorte de déterminer
    //l'ombrage du point.
    //N.B.
    //Lisez d'abord les méthodes qui suivent avant
    //de commencer le codage.
    ////////////////////////////////////////////
    //////////////////IFT 3355//////////////////
    ////////////////////////////////////////////

    // Clamp the color to white
    for (uint i = 0; i < lights.size(); ++i) {
       finalColor += GetAmbient(*lights[i]);
       finalColor += GetDiffuseAndSpecular(*lights[i]);
    }
    if (!mMaterial.GetReflection().IsBlack())
        finalColor += GetReflection();
    if (!mMaterial.GetRefraction().IsBlack())
        finalColor += GetRefraction();

    finalColor.Clamp( Color<real>( 1, 1, 1, 1 ) );
    return finalColor;
}
Exemplo n.º 4
0
  void test_serde() {
    // dynamic create message.
    MessageHelper helper;
    FileDescriptorProto file_proto;
    file_proto.set_name("test.proo");
    DescriptorProto *message_proto = file_proto.add_message_type();
    message_proto->set_name("Pair");
    auto field = message_proto->add_field();
    field->set_name("key");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_STRING);
    field->set_number(1);

    field = message_proto->add_field();
    field->set_name("value");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_BYTES);
    field->set_number(2);
    helper.registerDynamicMessage(file_proto);
    auto src = helper.createMessage("Pair");
    auto ref = src->GetReflection();
    string key("scott");
    string value("tiger");
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("key"), key);
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("value"), value);

    // test serde
    check_serde_str(src.get(), helper.createMessage("Pair").get());
    check_serde_array(src.get(), helper.createMessage("Pair").get());
    check_serstr_dearray(src.get(), helper.createMessage("Pair").get());
    check_serarray_destr(src.get(), helper.createMessage("Pair").get());
  }
Exemplo n.º 5
0
// Save():
const char * IllumiSurf_Instance::Save( const LWSaveState *saver ) {
  char cvalue;

  // Version
  LWSAVE_BEGIN( saver, &illumisurf_io_isfv[0], 0 );
  cvalue = 1;
  LWSAVE_I1( saver, &cvalue, 1 );

  // Blending Mode
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_BLND ], 1 );
  cvalue = GetBlendMode();
  LWSAVE_I1( saver, &cvalue, 1 );
  LWSAVE_END( saver );

  // Base Intensity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_BINT ], 1 );
  vparam_funcs->save( GetBaseIntensity(), saver );
  LWSAVE_END( saver );

  // Alternate Intensity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_AINT ], 1 );
  vparam_funcs->save( GetAltIntensity(), saver );
  LWSAVE_END( saver );

  // Color
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_COLR ], 1 );
  cvalue = GetUseColor() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetColor(), saver );
  LWSAVE_END( saver );

  // Luminosity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_LUMI ], 1 );
  cvalue = GetUseLuminosity() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetLuminosity(), saver );
  LWSAVE_END( saver );

  // Diffusion
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_DIFF ], 1 );
  cvalue = GetUseDiffusion() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetDiffusion(), saver );
  LWSAVE_END( saver );

  // Specular
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_SPEC ], 1 );
  cvalue = GetUseSpecular() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetSpecular(), saver );
  LWSAVE_END( saver );

  // Glossiness
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_GLOS ], 1 );
  cvalue = GetUseGlossiness() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetGlossiness(), saver );
  LWSAVE_END( saver );

  // Reflection
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_REFL ], 1 );
  cvalue = GetUseReflection() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetReflection(), saver );
  LWSAVE_END( saver );

  // Transparency
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_TRNP ], 1 );
  cvalue = GetUseTransparency() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetTransparency(), saver );
  LWSAVE_END( saver );

  // Refraction
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_REFR ], 1 );
  cvalue = GetUseRefraction() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetRefraction(), saver );
  LWSAVE_END( saver );

  // Translucency
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_TRNC ], 1 );
  cvalue = GetUseTranslucency() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetTranslucency(), saver );
  LWSAVE_END( saver );

  LWSAVE_END( saver );

  return NULL;
}
Exemplo n.º 6
0
// Load():
const char * IllumiSurf_Instance::Load( const LWLoadState *loader ) {
  char cvalue;

  if( ISIOPRE_ISFV == LWLOAD_FIND( loader, illumisurf_io_isfv ) ) {
    LWLOAD_I1( loader, &cvalue, 1 );
    if( cvalue != 1 )
      return "IllumiSurf Error:  Unsupported version found, aborting load";

    while( int id = LWLOAD_FIND( loader, illumisurf_io_root ) ) {
      switch( id ) {
        case ISIOPRE_BLND:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetBlendMode( (IllumiSurf_BlendModes)cvalue );
          break;

        case ISIOPRE_BINT:
          vparam_funcs->load( GetBaseIntensity(), loader );
          break;

        case ISIOPRE_AINT:
          vparam_funcs->load( GetAltIntensity(), loader );
          break;

        case ISIOPRE_COLR:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseColor( cvalue != 0 );
          vparam_funcs->load( GetColor(), loader );
          break;

        case ISIOPRE_LUMI:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseLuminosity( cvalue != 0 );
          vparam_funcs->load( GetLuminosity(), loader );
          break;

        case ISIOPRE_DIFF:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseDiffusion( cvalue != 0 );
          vparam_funcs->load( GetDiffusion(), loader );
          break;

        case ISIOPRE_SPEC:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseSpecular( cvalue != 0 );
          vparam_funcs->load( GetSpecular(), loader );
          break;

        case ISIOPRE_GLOS:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseGlossiness( cvalue != 0 );
          vparam_funcs->load( GetGlossiness(), loader );
          break;

        case ISIOPRE_REFL:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseReflection( cvalue != 0 );
          vparam_funcs->load( GetReflection(), loader );
          break;

        case ISIOPRE_TRNP:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseTransparency( cvalue != 0 );
          vparam_funcs->load( GetTransparency(), loader );
          break;

        case ISIOPRE_REFR:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseRefraction( cvalue != 0 );
          vparam_funcs->load( GetRefraction(), loader );
          break;

        case ISIOPRE_TRNC:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseTranslucency( cvalue != 0 );
          vparam_funcs->load( GetTranslucency(), loader );
          break;
      }

      LWLOAD_END( loader );            // End Keyword
    }

    LWLOAD_END( loader );            // End Keyword
  }

  return NULL;
}