void UK2Node_EaseFunction::RefreshPinVisibility() { const auto EaseFuncPin = GetEaseFuncPin(); UEnum * Enum = FindObject<UEnum>(ANY_PACKAGE, TEXT("EEasingFunc"), true); check(Enum != NULL); const int32 NewEasingFunc = CanCustomizeCurve() ? Enum->GetValueByName(*EaseFuncPin->DefaultValue) : -1; // Early exit in case no changes are required const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema()); UEdGraphPin* BlendExpPin = FindPinChecked(FEaseFunctionNodeHelper::GetBlendExpPinName()); if (NewEasingFunc == EEasingFunc::EaseIn || NewEasingFunc == EEasingFunc::EaseOut || NewEasingFunc == EEasingFunc::EaseInOut) { // Show the BlendExpPin BlendExpPin->bHidden = false; } else { // Hide the BlendExpPin: BlendExpPin->BreakAllPinLinks(); BlendExpPin->bHidden = true; } UEdGraphPin* StepsPin = FindPinChecked(FEaseFunctionNodeHelper::GetStepsPinName()); if (NewEasingFunc == EEasingFunc::Step) { // Show the Steps pin: StepsPin->bHidden = false; } else { // Hide the Steps pin: StepsPin->BreakAllPinLinks(); StepsPin->bHidden = true; } }
TAG_METHOD_IMPL(CSchemaParser, OnComplexType) { TRACE_PARSE_ENTRY(); CSchema * pCurr = GetSchema(); if (pCurr != NULL) { CAutoPtr<CComplexType> spElem; spElem.Attach( new CComplexType ); if (spElem != NULL) { SetXSDElementInfo(spElem, pCurr, GetLocator()); spElem->SetParentSchema(pCurr); CAutoPtr<CComplexTypeParser> p( new CComplexTypeParser(GetReader(), this, GetLevel(), spElem) ); if (p != NULL) { if (g_ParserList.AddHead(p) != NULL) { if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes))) { if (spElem->GetName().GetLength() != 0) { if (pCurr->AddComplexType(spElem) != NULL) { spElem.Detach(); return S_OK; } } EmitNamedElementError("complexType"); } } } } } EmitErrorHr(E_OUTOFMEMORY); return E_FAIL; }
/** * GetTupleSamples - Query tuple samples by db_id and table_id. */ std::unique_ptr<std::vector<std::unique_ptr<executor::LogicalTile>>> TupleSamplesStorage::GetTupleSamples(oid_t database_id, oid_t table_id) { auto catalog = catalog::Catalog::GetInstance(); std::string samples_table_name = GenerateSamplesTableName(database_id, table_id); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); auto data_table = catalog->GetTableWithName(std::string(SAMPLES_DB_NAME), std::string(DEFAULT_SCHEMA_NAME), samples_table_name, txn); auto col_count = data_table->GetSchema()->GetColumnCount(); std::vector<oid_t> column_ids; for (size_t col_id = 0; col_id < col_count; ++col_id) { column_ids.push_back(col_id); } auto result_tiles = GetTuplesWithSeqScan(data_table, column_ids, txn); txn_manager.CommitTransaction(txn); return result_tiles; }
void UK2Node_FormatText::PinConnectionListChanged(UEdGraphPin* Pin) { // Clear all pins. if(Pin == FormatPin && !FormatPin->DefaultTextValue.IsEmpty()) { PinNames.Empty(); GetSchema()->TrySetDefaultText(*FormatPin, FText::GetEmpty()); for(auto It = Pins.CreateConstIterator(); It; ++It) { UEdGraphPin* CheckPin = *It; if(CheckPin != FormatPin && CheckPin->Direction == EGPD_Input) { CheckPin->BreakAllPinLinks(); Pins.Remove(CheckPin); --It; } } FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint()); } }
void UK2Node_ClassDynamicCast::AllocateDefaultPins() { // Check to track down possible BP comms corruption //@TODO: Move this somewhere more sensible ensure((TargetType == NULL) || (!TargetType->HasAnyClassFlags(CLASS_NewerVersionExists))); const UEdGraphSchema_K2* K2Schema = Cast<UEdGraphSchema_K2>(GetSchema()); check(K2Schema != nullptr); if (!K2Schema->DoesGraphSupportImpureFunctions(GetGraph())) { bIsPureCast = true; } if (!bIsPureCast) { // Input - Execution Pin CreatePin(EGPD_Input, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_Execute); // Output - Execution Pins CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_CastSucceeded); CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_CastFailed); } // Input - Source type Pin CreatePin(EGPD_Input, K2Schema->PC_Class, TEXT(""), UObject::StaticClass(), false, false, FClassDynamicCastHelper::GetClassToCastName()); // Output - Data Pin if (TargetType != NULL) { const FString CastResultPinName = K2Schema->PN_CastedValuePrefix + TargetType->GetDisplayNameText().ToString(); CreatePin(EGPD_Output, K2Schema->PC_Class, TEXT(""), *TargetType, false, false, CastResultPinName); } UEdGraphPin* BoolSuccessPin = CreatePin(EGPD_Output, K2Schema->PC_Boolean, TEXT(""), nullptr, /*bIsArray =*/false, /*bIsReference =*/false, FClassDynamicCastHelper::CastSuccessPinName); BoolSuccessPin->bHidden = !bIsPureCast; UK2Node::AllocateDefaultPins(); }
void USoundCueGraphNode_Base::AutowireNewNode(UEdGraphPin* FromPin) { if (FromPin != NULL) { const USoundCueGraphSchema* Schema = CastChecked<USoundCueGraphSchema>(GetSchema()); TSet<UEdGraphNode*> NodeList; // auto-connect from dragged pin to first compatible pin on the new node for (int32 i=0; i<Pins.Num(); i++) { UEdGraphPin* Pin = Pins[i]; check(Pin); FPinConnectionResponse Response = Schema->CanCreateConnection(FromPin, Pin); if (ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE == Response.Response) { if (Schema->TryCreateConnection(FromPin, Pin)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } break; } else if(ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A == Response.Response) { InsertNewNode(FromPin, Pin, NodeList); break; } } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } } }
void UK2Node_Select::AutowireNewNode(UEdGraphPin* FromPin) { if (FromPin) { // Attempt to autowire to the index pin as users generally drag off of something intending to use // it as an index in a select statement rather than an arbitrary entry: const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema()); UEdGraphPin* IndexPin = GetIndexPin(); ECanCreateConnectionResponse ConnectResponse = K2Schema->CanCreateConnection(FromPin, IndexPin).Response; if (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE) { if (K2Schema->TryCreateConnection(FromPin, IndexPin)) { FromPin->GetOwningNode()->NodeConnectionListChanged(); this->NodeConnectionListChanged(); return; } } } // No connection made, just use default autowire logic: Super::AutowireNewNode(FromPin); }
void UNiagaraNodeInput::Compile(class INiagaraCompiler* Compiler, TArray<FNiagaraNodeResult>& Outputs) { //Input nodes in scripts being used as functions by other scripts will actually never get this far. //The compiler will find them and replace them with direct links between the pins going in and the nodes connected to the corresponding input. const UEdGraphSchema_Niagara* Schema = CastChecked<UEdGraphSchema_Niagara>(GetSchema()); if (IsConstant()) { if (IsExposedConstant() || Schema->IsSystemConstant(Input)) { //treat this input as an external constant. switch (Input.Type) { case ENiagaraDataType::Scalar: Outputs.Add(FNiagaraNodeResult(Compiler->GetExternalConstant(Input, FloatDefault), Pins[0])); break; case ENiagaraDataType::Vector: Outputs.Add(FNiagaraNodeResult(Compiler->GetExternalConstant(Input, VectorDefault), Pins[0])); break; case ENiagaraDataType::Matrix: Outputs.Add(FNiagaraNodeResult(Compiler->GetExternalConstant(Input, MatrixDefault), Pins[0])); break; case ENiagaraDataType::Curve: Outputs.Add(FNiagaraNodeResult(Compiler->GetExternalConstant(Input, DataObjectDefault), Pins[0])); break; } } else { //treat this input as an internal constant. switch (Input.Type) { case ENiagaraDataType::Scalar: Outputs.Add(FNiagaraNodeResult(Compiler->GetInternalConstant(Input, FloatDefault), Pins[0])); break; case ENiagaraDataType::Vector: Outputs.Add(FNiagaraNodeResult(Compiler->GetInternalConstant(Input, VectorDefault), Pins[0])); break; case ENiagaraDataType::Matrix: Outputs.Add(FNiagaraNodeResult(Compiler->GetInternalConstant(Input, MatrixDefault), Pins[0])); break; case ENiagaraDataType::Curve: Outputs.Add(FNiagaraNodeResult(Compiler->GetInternalConstant(Input, DataObjectDefault), Pins[0])); break;//Internal curve Constant? } } } else { //This input is an attribute. Outputs.Add(FNiagaraNodeResult(Compiler->GetAttribute(Input), Pins[0])); } }
TfType SdfPropertySpec::GetValueType() const { // The value type of an attribute is specified by the user when it is // constructed, while the value type of a relationship is always SdfPath. // Normally, one would use virtual functions to encapsulate this difference; // however we don't want to use virtuals as SdfSpec and its subclasses are // intended to be simple value types that are merely wrappers around // a layer. So, we have this hacky 'virtual' function. switch (GetSpecType()) { case SdfSpecTypeAttribute: return GetSchema().FindType(_GetAttributeValueTypeName()).GetType(); case SdfSpecTypeRelationship: { static const TfType type = TfType::Find<SdfPath>(); return type; } default: TF_CODING_ERROR("Unrecognized subclass of SdfPropertySpec on <%s>", GetPath().GetText()); return TfType(); } }
bool LogicalQueryPlanRoot::GetOptimalPhysicalPlan( Requirement requirement, PhysicalPlanDescriptor& final_physical_plan_desc, const unsigned& block_size) { std::vector<PhysicalPlanDescriptor> candidate_physical_plan; Requirement current_req; current_req.setRequiredLocations(std::vector<NodeID>(1, collecter_node)); Requirement merged_req; bool requirement_merged = current_req.tryMerge(requirement, merged_req); if (requirement_merged) { current_req = merged_req; } PhysicalPlanDescriptor physical_plan; /** no requirement**/ if (child_->GetOptimalPhysicalPlan(Requirement(), physical_plan, block_size)) { NetworkTransfer transfer = current_req.requireNetworkTransfer(physical_plan.plan_context_); if (transfer == NONE) { candidate_physical_plan.push_back(physical_plan); } else if ((transfer == OneToOne) || (transfer == Shuffle)) { // why transfer is compared with OneToOne, whose type is binding_mode? // ---Yu /* the input PlanContext should be transfered in the network to meet the * requirement * TODO: implement OneToOne Exchange * */ physical_plan.cost += physical_plan.plan_context_.GetAggregatedDatasize(); ExchangeMerger::State state; state.block_size_ = block_size; state.child_ = physical_plan.plan; // child_iterator; state.exchange_id_ = IDsGenerator::getInstance()->generateUniqueExchangeID(); state.schema_ = GetSchema(physical_plan.plan_context_.attribute_list_); state.upper_id_list_.push_back(collecter_node); state.partition_schema_ = partition_schema::set_hash_partition(0); state.lower_id_list_ = GetInvolvedNodeID(physical_plan.plan_context_.plan_partitioner_); PhysicalOperatorBase* exchange = new ExchangeMerger(state); physical_plan.plan = exchange; } } /** with requirement**/ if (child_->GetOptimalPhysicalPlan(current_req, physical_plan, block_size)) { candidate_physical_plan.push_back(physical_plan); } PhysicalPlanDescriptor best_plan = GetBestPhysicalPlanDescriptor(candidate_physical_plan); PhysicalPlan final_plan; switch (style_) { case kPrint: { ResultPrinter::State print_state( GetSchema(best_plan.plan_context_.attribute_list_), best_plan.plan, block_size, GetAttributeName(physical_plan.plan_context_)); final_plan = new ResultPrinter(print_state); break; } case kPerformance: { PerformanceMonitor::State performance_state( GetSchema(best_plan.plan_context_.attribute_list_), best_plan.plan, block_size); final_plan = new PerformanceMonitor(performance_state); } } if (requirement_merged) { final_physical_plan_desc.cost = best_plan.cost; final_physical_plan_desc.plan_context_ = best_plan.plan_context_; final_physical_plan_desc.plan = final_plan; } else { NetworkTransfer transfer = current_req.requireNetworkTransfer(best_plan.plan_context_); if (transfer == NONE) { final_physical_plan_desc.cost = best_plan.cost; final_physical_plan_desc.plan_context_ = best_plan.plan_context_; final_physical_plan_desc.plan = final_plan; } else if ((transfer == OneToOne) || (transfer == Shuffle)) { /* the input PlanContext should be transfered in the network to meet the * requirement * TODO: implement OneToOne Exchange * */ ExchangeMerger::State state; state.block_size_ = block_size; state.child_ = best_plan.plan; // child_iterator; state.exchange_id_ = IDsGenerator::getInstance()->generateUniqueExchangeID(); state.schema_ = GetSchema(best_plan.plan_context_.attribute_list_); std::vector<NodeID> upper_id_list; if (requirement.hasRequiredLocations()) { upper_id_list = requirement.getRequiredLocations(); } else { if (requirement.hasRequiredPartitionFunction()) { /* partition function contains the number of partitions*/ PartitionFunction* partitoin_function = requirement.getPartitionFunction(); upper_id_list = std::vector<NodeID>( NodeTracker::GetInstance()->GetNodeIDList().begin(), NodeTracker::GetInstance()->GetNodeIDList().begin() + partitoin_function->getNumberOfPartitions() - 1); } else { // TODO(wangli): decide the degree of parallelism upper_id_list = NodeTracker::GetInstance()->GetNodeIDList(); } } state.upper_id_list_ = upper_id_list; assert(requirement.hasReuiredPartitionKey()); state.partition_schema_ = partition_schema::set_hash_partition( this->GetIdInAttributeList(best_plan.plan_context_.attribute_list_, requirement.getPartitionKey())); assert(state.partition_schema_.partition_key_index >= 0); std::vector<NodeID> lower_id_list = GetInvolvedNodeID(best_plan.plan_context_.plan_partitioner_); state.lower_id_list_ = lower_id_list; PhysicalOperatorBase* exchange = new ExchangeMerger(state); best_plan.plan = exchange; best_plan.cost += best_plan.plan_context_.GetAggregatedDatasize(); final_physical_plan_desc.cost = best_plan.cost; final_physical_plan_desc.plan_context_ = best_plan.plan_context_; final_physical_plan_desc.plan = exchange; } } if (requirement.passLimits(final_physical_plan_desc.cost)) return true; else return false; }
/** * get PlanContext and child physical plan from child , * consider PlanContext's partitioner's location and collector, * decide whether add expander and exchange operator in physical plan. * * choose one of three top physical operators depend on fashion_, * return complete physical plan */ PhysicalOperatorBase* LogicalQueryPlanRoot::GetPhysicalPlan( const unsigned& block_size) { PlanContext child_plan_context = GetPlanContext(); /////////// LogicalLimit* limit = NULL; PhysicalOperatorBase* child_iterator = NULL; if (child_->get_operator_type() == OperatorType::kLogicalLimit) { limit = reinterpret_cast<LogicalLimit*>(child_); child_iterator = limit->child_->GetPhysicalPlan(block_size); } else { child_iterator = child_->GetPhysicalPlan(block_size); } ///////////// NodeTracker* node_tracker = NodeTracker::GetInstance(); bool is_exchange_need = false; /** * If the number of partitions in the child PlanContext is 1 and the the * location is right in the collector, * then exchange is not necessary. */ if (!(1 == child_plan_context.plan_partitioner_.GetNumberOfPartitions() && child_plan_context.plan_partitioner_.get_partition_list()[0] .get_location() == collecter_node)) { is_exchange_need = true; // add BlockStreamExpander iterator into physical plan Expander::State expander_state_lower; expander_state_lower.block_count_in_buffer_ = 10; expander_state_lower.block_size_ = block_size; expander_state_lower.init_thread_count_ = Config::initial_degree_of_parallelism; expander_state_lower.child_ = child_iterator; expander_state_lower.schema_ = GetSchema(child_plan_context.attribute_list_); PhysicalOperatorBase* expander_lower = new Expander(expander_state_lower); // add ExchangeEpoll iterator into physical plan ExchangeMerger::State state; state.block_size_ = block_size; state.child_ = expander_lower; // child_iterator; state.exchange_id_ = IDsGenerator::getInstance()->generateUniqueExchangeID(); state.schema_ = GetSchema(child_plan_context.attribute_list_); state.upper_id_list_.push_back(collecter_node); state.partition_schema_ = partition_schema::set_hash_partition(0); std::vector<NodeID> lower_id_list = GetInvolvedNodeID(child_plan_context.plan_partitioner_); state.lower_id_list_ = lower_id_list; child_iterator = new ExchangeMerger(state); } Expander::State expander_state; expander_state.block_count_in_buffer_ = 10; expander_state.block_size_ = block_size; if (is_exchange_need) // if data exchange is used, only one expanded thread is enough. expander_state.init_thread_count_ = 1; else expander_state.init_thread_count_ = Config::initial_degree_of_parallelism; expander_state.child_ = child_iterator; expander_state.schema_ = GetSchema(child_plan_context.attribute_list_); PhysicalOperatorBase* expander = new Expander(expander_state); if (child_->get_operator_type() == OperatorType::kLogicalLimit) { expander = limit->GetPhysicalPlan(block_size, expander); } PhysicalOperatorBase* ret; switch (style_) { case kPrint: { ResultPrinter::State print_state( GetSchema(child_plan_context.attribute_list_), expander, block_size, GetAttributeName(child_plan_context)); ret = new ResultPrinter(print_state); break; } case kPerformance: { PerformanceMonitor::State performance_state( GetSchema(child_plan_context.attribute_list_), expander, block_size); ret = new PerformanceMonitor(performance_state); break; } case kResultCollector: { std::vector<std::string> column_header; GetColumnHeader(column_header, child_plan_context.attribute_list_); physical_operator::ResultCollector::State result_state( GetSchema(child_plan_context.attribute_list_), expander, block_size, column_header); ret = new physical_operator::ResultCollector(result_state); break; } } return ret; }
ViewAccess GetView ( uint32_t p_idx ) { return ViewAccess ( static_cast < const SView* > ( VectorGet ( & GetSchema () -> view, p_idx ) ) ); }
// Get a string representation for debugging const std::string Database::GetInfo() const { std::ostringstream os; os << "=====================================================\n"; os << "DATABASE(" << GetOid() << ") : \n"; oid_t table_count = GetTableCount(); os << "Table Count : " << table_count << "\n"; oid_t table_itr = 0; for (auto table : tables) { if (table != nullptr) { os << "(" << ++table_itr << "/" << table_count << ") " << "Table Name(" << table->GetOid() << ") : " << table->GetName() << "\n" << *(table->GetSchema()) << std::endl; oid_t index_count = table->GetIndexCount(); if (index_count > 0) { os << "Index Count : " << index_count << std::endl; for (oid_t index_itr = 0; index_itr < index_count; index_itr++) { index::Index *index = table->GetIndex(index_itr); switch (index->GetIndexType()) { case INDEX_CONSTRAINT_TYPE_PRIMARY_KEY: os << "primary key index \n"; break; case INDEX_CONSTRAINT_TYPE_UNIQUE: os << "unique index \n"; break; default: os << "default index \n"; break; } os << *index << std::endl; } } if (table->HasForeignKeys()) { os << "foreign tables \n"; oid_t foreign_key_count = table->GetForeignKeyCount(); for (oid_t foreign_key_itr = 0; foreign_key_itr < foreign_key_count; foreign_key_itr++) { auto foreign_key = table->GetForeignKey(foreign_key_itr); auto sink_table_oid = foreign_key->GetSinkTableOid(); auto sink_table = GetTableWithOid(sink_table_oid); auto sink_table_schema = sink_table->GetSchema(); os << "table name : " << sink_table->GetName() << " " << *sink_table_schema << std::endl; } } } } os << "=====================================================\n"; return os.str(); }
/** * Note: if group_by_attribute_list_ is empty, the partition key is * ATTRIBUTE_NULL */ PhysicalOperatorBase* LogicalAggregation::GetPhysicalPlan( const unsigned& block_size) { if (NULL == plan_context_) { GetPlanContext(); } PhysicalOperatorBase* ret; const PlanContext child_plan_context = child_->GetPlanContext(); PhysicalAggregation::State local_agg_state; local_agg_state.group_by_attrs_ = group_by_attrs_; local_agg_state.aggregation_attrs_ = aggregation_attrs_; local_agg_state.block_size_ = block_size; local_agg_state.num_of_buckets_ = EstimateGroupByCardinality(child_plan_context); local_agg_state.bucket_size_ = 64; local_agg_state.input_schema_ = GetSchema(child_plan_context.attribute_list_); local_agg_state.output_schema_ = GetSchema(plan_context_->attribute_list_); local_agg_state.child_ = child_->GetPhysicalPlan(block_size); local_agg_state.avg_index_ = avg_id_in_agg_; local_agg_state.count_column_id_ = count_column_id_; local_agg_state.hash_schema_ = local_agg_state.output_schema_->duplicateSchema(); switch (aggregation_style_) { case kLocalAgg: { local_agg_state.agg_node_type_ = PhysicalAggregation::State::kNotHybridAgg; ret = new PhysicalAggregation(local_agg_state); break; } case kLocalAggReparGlobalAgg: { local_agg_state.agg_node_type_ = PhysicalAggregation::State::kHybridAggLocal; PhysicalAggregation* local_aggregation = new PhysicalAggregation(local_agg_state); Expander::State expander_state; expander_state.block_count_in_buffer_ = EXPANDER_BUFFER_SIZE; expander_state.block_size_ = block_size; expander_state.init_thread_count_ = Config::initial_degree_of_parallelism; expander_state.child_ = local_aggregation; expander_state.schema_ = local_agg_state.hash_schema_->duplicateSchema(); PhysicalOperatorBase* expander_lower = new Expander(expander_state); ExchangeMerger::State exchange_state; exchange_state.block_size_ = block_size; exchange_state.child_ = expander_lower; exchange_state.exchange_id_ = IDsGenerator::getInstance()->generateUniqueExchangeID(); exchange_state.lower_id_list_ = GetInvolvedNodeID(child_->GetPlanContext().plan_partitioner_); exchange_state.upper_id_list_ = GetInvolvedNodeID(plan_context_->plan_partitioner_); exchange_state.partition_schema_ = partition_schema::set_hash_partition(0); exchange_state.schema_ = local_agg_state.hash_schema_->duplicateSchema(); PhysicalOperatorBase* exchange = new ExchangeMerger(exchange_state); PhysicalAggregation::State global_agg_state; global_agg_state.agg_node_type_ = PhysicalAggregation::State::kHybridAggGlobal; global_agg_state.input_schema_ = GetSchema(plan_context_->attribute_list_); global_agg_state.output_schema_ = GetSchema(plan_context_->attribute_list_); global_agg_state.hash_schema_ = global_agg_state.output_schema_->duplicateSchema(); // change each aggregation expression and group by expression to one // attribute SetGroupbyAndAggAttrsForGlobalAgg(global_agg_state.group_by_attrs_, global_agg_state.aggregation_attrs_, global_agg_state.input_schema_); global_agg_state.block_size_ = block_size; global_agg_state.bucket_size_ = 64; global_agg_state.child_ = exchange; global_agg_state.num_of_buckets_ = local_agg_state.num_of_buckets_; global_agg_state.avg_index_ = avg_id_in_agg_; global_agg_state.count_column_id_ = count_column_id_; PhysicalOperatorBase* global_aggregation = new PhysicalAggregation(global_agg_state); ret = global_aggregation; break; } case kReparGlobalAgg: { assert(false); } } return ret; }
bool LogicalFilter::GetOptimalPhysicalPlan( Requirement requirement, PhysicalPlanDescriptor& physical_plan_descriptor, const unsigned& block_size) { PhysicalPlanDescriptor physical_plan; std::vector<PhysicalPlanDescriptor> candidate_physical_plans; /* no requirement to the child*/ if (child_->GetOptimalPhysicalPlan(Requirement(), physical_plan)) { NetworkTransfer transfer = requirement.requireNetworkTransfer(physical_plan.plan_context_); if (NONE == transfer) { PhysicalFilter::State state; state.block_size_ = block_size; state.child_ = physical_plan.plan; state.qual_ = condi_; state.column_id_ = column_id_; PlanContext plan_context = GetPlanContext(); state.schema_ = GetSchema(plan_context.attribute_list_); PhysicalOperatorBase* filter = new PhysicalFilter(state); physical_plan.plan = filter; candidate_physical_plans.push_back(physical_plan); } else if ((OneToOne == transfer) || (Shuffle == transfer)) { /** * The input plan context should be transfered in the network to meet the * requirement. * TODO(wangli): Implement OneToOne Exchange * */ PhysicalFilter::State state_f; state_f.block_size_ = block_size; state_f.child_ = physical_plan.plan; state_f.qual_ = condi_; state_f.column_id_ = column_id_; PlanContext plan_context = GetPlanContext(); state_f.schema_ = GetSchema(plan_context.attribute_list_); PhysicalOperatorBase* filter = new PhysicalFilter(state_f); physical_plan.plan = filter; physical_plan.cost += physical_plan.plan_context_.GetAggregatedDatasize(); ExchangeMerger::State state; state.block_size_ = block_size; state.child_ = physical_plan.plan; // child_iterator; state.exchange_id_ = IDsGenerator::getInstance()->generateUniqueExchangeID(); state.schema_ = GetSchema(physical_plan.plan_context_.attribute_list_); std::vector<NodeID> upper_id_list; if (requirement.hasRequiredLocations()) { upper_id_list = requirement.getRequiredLocations(); } else { if (requirement.hasRequiredPartitionFunction()) { // Partition function contains the number of partitions. PartitionFunction* partitoin_function = requirement.getPartitionFunction(); upper_id_list = std::vector<NodeID>( NodeTracker::GetInstance()->GetNodeIDList().begin(), NodeTracker::GetInstance()->GetNodeIDList().begin() + partitoin_function->getNumberOfPartitions() - 1); } else { // TODO(wangli): decide the degree of parallelism upper_id_list = NodeTracker::GetInstance()->GetNodeIDList(); } } state.upper_id_list_ = upper_id_list; assert(requirement.hasReuiredPartitionKey()); state.partition_schema_ = partition_schema::set_hash_partition(this->GetIdInAttributeList( physical_plan.plan_context_.attribute_list_, requirement.getPartitionKey())); assert(state.partition_schema_.partition_key_index >= 0); std::vector<NodeID> lower_id_list = GetInvolvedNodeID(physical_plan.plan_context_.plan_partitioner_); state.lower_id_list_ = lower_id_list; PhysicalOperatorBase* exchange = new ExchangeMerger(state); physical_plan.plan = exchange; } candidate_physical_plans.push_back(physical_plan); } if (child_->GetOptimalPhysicalPlan(requirement, physical_plan)) { PhysicalFilter::State state; state.block_size_ = block_size; state.child_ = physical_plan.plan; state.column_id_ = column_id_; PlanContext plan_context = GetPlanContext(); state.schema_ = GetSchema(plan_context.attribute_list_); PhysicalOperatorBase* filter = new PhysicalFilter(state); physical_plan.plan = filter; candidate_physical_plans.push_back(physical_plan); } physical_plan_descriptor = GetBestPhysicalPlanDescriptor(candidate_physical_plans); if (requirement.passLimits(physical_plan_descriptor.cost)) return true; else return false; }
void UK2Node::GetPinHoverText(const UEdGraphPin& Pin, FString& HoverTextOut) const { // start with the default hover text (from the pin's tool-tip) Super::GetPinHoverText(Pin, HoverTextOut); // if the Pin wasn't initialized with a tool-tip of its own if (HoverTextOut.IsEmpty()) { UEdGraphSchema const* Schema = GetSchema(); check(Schema != NULL); Schema->ConstructBasicPinTooltip(Pin, FText::GetEmpty(), HoverTextOut); } UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForNodeChecked(this); check(Blueprint != NULL); // If this resides in an intermediate graph, show the UObject name for debug purposes if(Blueprint->IntermediateGeneratedGraphs.Contains(GetGraph())) { HoverTextOut = FString::Printf(TEXT("%s\n\n%s"), *Pin.GetName(), *HoverTextOut); } UObject* ActiveObject = Blueprint->GetObjectBeingDebugged(); // if there is no object being debugged, then we don't need to tack on any of the following data if (ActiveObject == NULL) { return; } // Switch the blueprint to the one that generated the object being debugged (e.g. in case we're inside a Macro BP while debugging) Blueprint = Cast<UBlueprint>(ActiveObject->GetClass()->ClassGeneratedBy); if (Blueprint == NULL) { return; } // if the blueprint doesn't have debug data, notify the user /*if (!FKismetDebugUtilities::HasDebuggingData(Blueprint)) { HoverTextOut += TEXT("\n(NO DEBUGGING INFORMATION GENERATED, NEED TO RECOMPILE THE BLUEPRINT)"); }*/ //@TODO: For exec pins, show when they were last executed // grab the debug value of the pin FString WatchText; const FKismetDebugUtilities::EWatchTextResult WatchStatus = FKismetDebugUtilities::GetWatchText(/*inout*/ WatchText, Blueprint, ActiveObject, &Pin); // if this is an array pin, then we possibly have too many lines (too many entries) if (Pin.PinType.bIsArray) { int32 LineCounter = 0; int32 OriginalWatchTextLen = WatchText.Len(); // walk the string, finding line breaks (counting lines) for (int32 NewWatchTextLen = 0; NewWatchTextLen < OriginalWatchTextLen; ) { ++LineCounter; int32 NewLineIndex = WatchText.Find("\n", ESearchCase::IgnoreCase, ESearchDir::FromStart, NewWatchTextLen); // if we've reached the end of the string (it's not to long) if (NewLineIndex == INDEX_NONE) { break; } NewWatchTextLen = NewLineIndex + 1; // if we're at the end of the string (but it ends with a newline) if (NewWatchTextLen >= OriginalWatchTextLen) { break; } // if we've hit the max number of lines allowed in a tooltip if (LineCounter >= MaxArrayPinTooltipLineCount) { // truncate WatchText so it contains a finite number of lines WatchText = WatchText.Left(NewWatchTextLen); WatchText += "..."; // WatchText should already have a trailing newline (no need to prepend this with one) break; } } } // if Pin.PinType.bIsArray... switch (WatchStatus) { case FKismetDebugUtilities::EWTR_Valid: HoverTextOut += FString::Printf(TEXT("\nCurrent value = %s"), *WatchText); //@TODO: Print out object being debugged name? break; case FKismetDebugUtilities::EWTR_NotInScope: HoverTextOut += TEXT("\n(Variable is not in scope)"); break; default: case FKismetDebugUtilities::EWTR_NoDebugObject: case FKismetDebugUtilities::EWTR_NoProperty: break; } }
void UEdGraphNode::AddSearchMetaDataInfo(TArray<struct FSearchTagDataPair>& OutTaggedMetaData) const { // Searchable - Primary label for the item in the search results OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_Name, GetNodeTitle(ENodeTitleType::ListView))); // Searchable - As well as being searchable, this displays in the tooltip for the node OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_ClassName, FText::FromString(GetClass()->GetName()))); // Non-searchable - Used to lookup the node when attempting to jump to it OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_NodeGuid, FText::FromString(NodeGuid.ToString(EGuidFormats::Digits)))); // Non-searchable - Important for matching pin types with icons and colors, stored here so that each pin does not store it OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_SchemaName, FText::FromString(GetSchema()->GetClass()->GetName()))); // Non-Searchable - Used to display the icon and color for this node for better visual identification. FLinearColor GlyphColor = FLinearColor::White; OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_Glyph, FText::FromString(GetPaletteIcon(GlyphColor).ToString()))); OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_GlyphColor, FText::FromString(GlyphColor.ToString()))); OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_Comment, FText::FromString(NodeComment))); }
void LogicalTile::MaterializeRowAtAtATime( const std::unordered_map<oid_t, oid_t> &old_to_new_cols, const std::unordered_map<storage::Tile *, std::vector<oid_t>> &tile_to_cols, storage::Tile *dest_tile) { /////////////////////////// // EACH PHYSICAL TILE /////////////////////////// // Copy over all data from each base tile. for (const auto &kv : tile_to_cols) { const std::vector<oid_t> &old_column_ids = kv.second; auto &schema = GetSchema(); oid_t new_tuple_id = 0; auto &column_position_lists = GetPositionLists(); // Get old column information std::vector<oid_t> old_column_position_idxs; std::vector<size_t> old_column_offsets; std::vector<ValueType> old_column_types; std::vector<bool> old_is_inlineds; std::vector<storage::Tile *> old_tiles; // Get new column information std::vector<size_t> new_column_offsets; std::vector<bool> new_is_inlineds; std::vector<size_t> new_column_lengths; // Amortize schema lookups once per column for (oid_t old_col_id : old_column_ids) { auto &column_info = schema[old_col_id]; // Get the position list old_column_position_idxs.push_back(column_info.position_list_idx); // Get old column information storage::Tile *old_tile = column_info.base_tile.get(); old_tiles.push_back(old_tile); auto old_schema = old_tile->GetSchema(); oid_t old_column_id = column_info.origin_column_id; const size_t old_column_offset = old_schema->GetOffset(old_column_id); old_column_offsets.push_back(old_column_offset); const ValueType old_column_type = old_schema->GetType(old_column_id); old_column_types.push_back(old_column_type); const bool old_is_inlined = old_schema->IsInlined(old_column_id); old_is_inlineds.push_back(old_is_inlined); // Old to new column mapping auto it = old_to_new_cols.find(old_col_id); assert(it != old_to_new_cols.end()); // Get new column information oid_t new_column_id = it->second; auto new_schema = dest_tile->GetSchema(); const size_t new_column_offset = new_schema->GetOffset(new_column_id); new_column_offsets.push_back(new_column_offset); const bool new_is_inlined = new_schema->IsInlined(new_column_id); new_is_inlineds.push_back(new_is_inlined); const size_t new_column_length = new_schema->GetAppropriateLength(new_column_id); new_column_lengths.push_back(new_column_length); } assert(new_column_offsets.size() == old_column_ids.size()); /////////////////////////// // EACH TUPLE /////////////////////////// // Copy all values in the tuple to the physical tile // This uses fast getter and setter functions for (oid_t old_tuple_id : *this) { /////////////////////////// // EACH COLUMN /////////////////////////// // Go over each column in given base physical tile oid_t col_itr = 0; for (oid_t old_col_id : old_column_position_idxs) { auto &column_position_list = column_position_lists[old_col_id]; oid_t base_tuple_id = column_position_list[old_tuple_id]; auto value = old_tiles[col_itr]->GetValueFast( base_tuple_id, old_column_offsets[col_itr], old_column_types[col_itr], old_is_inlineds[col_itr]); LOG_TRACE("Old Tuple : %u Column : %u ", old_tuple_id, old_col_id); LOG_TRACE("New Tuple : %u Column : %lu ", new_tuple_id, new_column_offsets[col_itr]); dest_tile->SetValueFast( value, new_tuple_id, new_column_offsets[col_itr], new_is_inlineds[col_itr], new_column_lengths[col_itr]); // Go to next column col_itr++; } // Go to next tuple new_tuple_id++; } } }
FText UEdGraphNode::GetPinDisplayName(const UEdGraphPin* Pin) const { return GetSchema()->GetPinDisplayName(Pin); }
void UEdGraphPin::CopyPersistentDataFromOldPin(const UEdGraphPin& SourcePin) { // The name matches already, doesn't get copied here // The PinType, Direction, and bNotConnectable are properties generated from the schema // Only move the default value if it was modified; inherit the new default value otherwise if (SourcePin.DefaultValue != SourcePin.AutogeneratedDefaultValue || SourcePin.DefaultObject != NULL) { DefaultObject = SourcePin.DefaultObject; DefaultValue = SourcePin.DefaultValue; } const bool bTextValueWasModified = (SourcePin.DefaultTextValue.ToString() != SourcePin.AutogeneratedDefaultValue); if (bTextValueWasModified) { DefaultTextValue = SourcePin.DefaultTextValue; } // In K2 schemas the wildcard pins need to have their type copied before we get to pin splitting // TODO: Better less hacky way of this? if (PinType.PinCategory == TEXT("wildcard")) { PinType = SourcePin.PinType; } // Copy the links for (int32 LinkIndex = 0; LinkIndex < SourcePin.LinkedTo.Num(); ++LinkIndex) { UEdGraphPin* OtherPin = SourcePin.LinkedTo[LinkIndex]; check(NULL != OtherPin); Modify(); OtherPin->Modify(); LinkedTo.Add(OtherPin); // Unlike MakeLinkTo(), we attempt to ensure that the new pin (this) is inserted at the same position as the old pin (source) // in the OtherPin's LinkedTo array. This is necessary to ensure that the node's position in the execution order will remain // unchanged after nodes are reconstructed, because OtherPin may be connected to more than just this node. int32 Index = OtherPin->LinkedTo.Find(const_cast<UEdGraphPin*>(&SourcePin)); if(Index != INDEX_NONE) { OtherPin->LinkedTo.Insert(this, Index); } else { // Fallback to "normal" add, just in case the old pin doesn't exist in the other pin's LinkedTo array for some reason. OtherPin->LinkedTo.Add(this); } } // If the source pin is split, then split the new one if (SourcePin.SubPins.Num() > 0) { GetSchema()->SplitPin(this); } #if WITH_EDITORONLY_DATA // Copy advanced visibility property, since it can be changed by user bAdvancedView = SourcePin.bAdvancedView; #endif // WITH_EDITORONLY_DATA }
const FString& UK2Node_LoadAssetClass::GetOutputCategory() const { const UEdGraphSchema_K2* K2Schema = CastChecked<const UEdGraphSchema_K2>(GetSchema()); return K2Schema->PC_Class; }
PlanContext LogicalAggregation::GetPlanContext() { lock_->acquire(); if (NULL != plan_context_) { lock_->release(); return *plan_context_; } PlanContext ret; const PlanContext child_context = child_->GetPlanContext(); ChangeAggAttrsForAVG(); // initialize expression of group_by_attrs and aggregation_attrs Schema* input_schema = GetSchema(child_context.attribute_list_); map<string, int> column_to_id; GetColumnToId(child_context.attribute_list_, column_to_id); for (int i = 0; i < group_by_attrs_.size(); ++i) { group_by_attrs_[i]->InitExprAtLogicalPlan(group_by_attrs_[i]->actual_type_, column_to_id, input_schema); } for (int i = 0; i < aggregation_attrs_.size(); ++i) { aggregation_attrs_[i]->InitExprAtLogicalPlan( aggregation_attrs_[i]->actual_type_, column_to_id, input_schema); } if (CanOmitHashRepartition(child_context)) { aggregation_style_ = kLocalAgg; LOG(INFO) << "Aggregation style: kLocalAgg" << std::endl; } else { // as for the kLocalAggReparGlobalAgg style is optimal // to kReparAndGlobalAgg so it's set to be default. aggregation_style_ = kLocalAggReparGlobalAgg; LOG(INFO) << "Aggregation style: kLocalAggReparGlobalAgg" << std::endl; } switch (aggregation_style_) { case kLocalAgg: { ret.attribute_list_ = GetAttrsAfterAgg(); ret.commu_cost_ = child_context.commu_cost_; ret.plan_partitioner_ = child_context.plan_partitioner_; Attribute partition_key = child_context.plan_partitioner_.get_partition_key(); partition_key.table_id_ = INTERMEIDATE_TABLEID; ret.plan_partitioner_.set_partition_key(partition_key); for (unsigned i = 0; i < ret.plan_partitioner_.GetNumberOfPartitions(); i++) { const unsigned cardinality = ret.plan_partitioner_.GetPartition(i)->get_cardinality(); ret.plan_partitioner_.GetPartition(i) ->set_cardinality(EstimateGroupByCardinality(child_context) / ret.plan_partitioner_.GetNumberOfPartitions()); } break; } default: { /** * repartition aggregation is currently simplified. */ // TODO(FZH): ideally, the partition properties (especially the the number // of partitions and partition style) after repartition aggregation should // be decided by the partition property enforcement. ret.attribute_list_ = GetAttrsAfterAgg(); ret.commu_cost_ = child_context.commu_cost_ + child_context.GetAggregatedDatasize(); ret.plan_partitioner_.set_partition_func( child_context.plan_partitioner_.get_partition_func()); // set partition key if (group_by_attrs_.empty()) { ret.plan_partitioner_.set_partition_key(Attribute()); } else { int id = 0; // if there is column in groupby attributes, so move it to the front, in // order to get partition by one column not one expression for (int i = 0; i < group_by_attrs_.size(); ++i) { if (group_by_attrs_[i]->expr_node_type_ == t_qcolcumns) { id = i; break; } } std::swap(group_by_attrs_[0], group_by_attrs_[id]); ret.plan_partitioner_.set_partition_key( group_by_attrs_[0]->ExprNodeToAttr(0)); } NodeID location = 0; int64_t data_cardinality = EstimateGroupByCardinality(child_context); PartitionOffset offset = 0; PlanPartitionInfo par(offset, data_cardinality, location); std::vector<PlanPartitionInfo> partition_list; partition_list.push_back(par); ret.plan_partitioner_.set_partition_list(partition_list); break; } } plan_context_ = new PlanContext(); *plan_context_ = ret; lock_->release(); return ret; }
void pgOperatorClass::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; pgSet *set; if (!GetConnection()->BackendMinimumVersion(8, 3)) { set = ExecuteSet( wxT("SELECT amopstrategy, amopreqcheck, oprname, lt.typname as lefttype, rt.typname as righttype\n") wxT(" FROM pg_amop am\n") wxT(" JOIN pg_operator op ON amopopr=op.oid\n") wxT(" LEFT OUTER JOIN pg_type lt ON lt.oid=oprleft\n") wxT(" LEFT OUTER JOIN pg_type rt ON rt.oid=oprright\n") wxT(" WHERE amopclaid=") + GetOidStr() + wxT("\n") wxT(" ORDER BY amopstrategy")); } else if (!GetConnection()->BackendMinimumVersion(8, 4)) { set = ExecuteSet( wxT("SELECT amopstrategy, amopreqcheck, oprname, lt.typname as lefttype, rt.typname as righttype\n") wxT(" FROM pg_amop am\n") wxT(" JOIN pg_operator op ON amopopr=op.oid\n") wxT(" JOIN pg_opfamily opf ON amopfamily = opf.oid\n") wxT(" JOIN pg_opclass opc ON opf.oid = opcfamily\n") wxT(" LEFT OUTER JOIN pg_type lt ON lt.oid=oprleft\n") wxT(" LEFT OUTER JOIN pg_type rt ON rt.oid=oprright\n") wxT(" WHERE opc.oid=") + GetOidStr() + wxT("\n") wxT(" AND amopmethod = opf.opfmethod\n") wxT(" AND amoplefttype = op.oprleft AND amoprighttype = op.oprright\n") wxT(" ORDER BY amopstrategy")); } else { set = ExecuteSet( wxT("SELECT amopstrategy, oprname, lt.typname as lefttype, rt.typname as righttype\n") wxT(" FROM pg_amop am\n") wxT(" JOIN pg_operator op ON amopopr=op.oid\n") wxT(" JOIN pg_opfamily opf ON amopfamily = opf.oid\n") wxT(" JOIN pg_opclass opc ON opf.oid = opcfamily\n") wxT(" LEFT OUTER JOIN pg_type lt ON lt.oid=oprleft\n") wxT(" LEFT OUTER JOIN pg_type rt ON rt.oid=oprright\n") wxT(" WHERE opc.oid=") + GetOidStr() + wxT("\n") wxT(" AND amopmethod = opf.opfmethod\n") wxT(" AND amoplefttype = op.oprleft AND amoprighttype = op.oprright\n") wxT(" ORDER BY amopstrategy")); } if (set) { while (!set->Eof()) { wxString str = set->GetVal(wxT("amopstrategy")) + wxT(" ") + set->GetVal(wxT("oprname")); wxString lt = set->GetVal(wxT("lefttype")); wxString rt = set->GetVal(wxT("righttype")); if (lt == GetInType() && (rt.IsEmpty() || rt == GetInType())) lt = wxEmptyString; if (rt == GetInType() && lt.IsEmpty()) rt = wxEmptyString; if (!lt.IsEmpty() || !rt.IsEmpty()) { str += wxT("("); if (!lt.IsEmpty()) { str += lt; if (!rt.IsEmpty()) str += wxT(", "); } if (!rt.IsEmpty()) str += rt; str += wxT(")"); } if (!GetConnection()->BackendMinimumVersion(8, 4)) { if (set->GetBool(wxT("amopreqcheck"))) str += wxT(" RECHECK"); } operators.Add(str); set->MoveNext(); } delete set; } if (!GetConnection()->BackendMinimumVersion(8, 3)) { set = ExecuteSet( wxT("SELECT amprocnum, amproc::oid\n") wxT(" FROM pg_amproc am\n") wxT(" WHERE amopclaid=") + GetOidStr() + wxT("\n") wxT(" ORDER BY amprocnum")); } else { set = ExecuteSet( wxT("SELECT amprocnum, amproc::oid\n") wxT(" FROM pg_amproc am\n") wxT(" JOIN pg_opfamily opf ON amprocfamily = opf.oid\n") wxT(" JOIN pg_opclass opc ON opf.oid = opcfamily\n") wxT(" WHERE opc.oid=") + GetOidStr() + wxT("\n") wxT(" AND amproclefttype = opc.opcintype AND amprocrighttype = opc.opcintype\n") wxT(" ORDER BY amprocnum")); } if (set) { while (!set->Eof()) { wxString amproc = set->GetVal(wxT("amproc")); functionOids.Add(amproc); // We won't build a PG_FUNCTIONS collection under OperatorClass, so we create // temporary function items pgFunction *function = functionFactory.AppendFunctions(this, GetSchema(), 0, wxT(" WHERE pr.oid=") + amproc); if (function) { functions.Add(set->GetVal(wxT("amprocnum")) + wxT(" ") + function->GetFullName()); quotedFunctions.Add(set->GetVal(wxT("amprocnum")) + wxT(" ") + function->GetQuotedFullIdentifier() + wxT("(") + function->GetArgSigList() + wxT(")")); delete function; } set->MoveNext(); } delete set; } } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendYesNoItem(_("Default?"), GetOpcDefault()); properties->AppendItem(_("For type"), GetInType()); properties->AppendItem(_("Access method"), GetAccessMethod()); if (GetConnection()->BackendMinimumVersion(8, 3)) properties->AppendItem(_("Family"), GetFamily()); if (!GetKeyType().IsEmpty()) properties->AppendItem(_("Storage"), GetKeyType()); unsigned int i; for (i = 0 ; i < operators.Count() ; i++) properties->AppendItem(wxT("OPERATOR"), operators.Item(i)); for (i = 0 ; i < functions.Count() ; i++) properties->AppendItem(wxT("FUNCTION"), functions.Item(i)); properties->AppendYesNoItem(_("System operator class?"), GetSystemObject()); if (GetConnection()->BackendMinimumVersion(7, 5)) properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void UK2Node::AutowireNewNode(UEdGraphPin* FromPin) { const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema()); // Do some auto-connection if (FromPin != NULL) { TSet<UEdGraphNode*> NodeList; // sometimes we don't always find an ideal connection, but we want to exhaust // all our options first... this stores a secondary less-ideal pin to connect to, if nothing better was found UEdGraphPin* BackupConnection = NULL; // If not dragging an exec pin, auto-connect from dragged pin to first compatible pin on the new node for (int32 i=0; i<Pins.Num(); i++) { UEdGraphPin* Pin = Pins[i]; check(Pin); ECanCreateConnectionResponse ConnectResponse = K2Schema->CanCreateConnection(FromPin, Pin).Response; if (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE) { if (K2Schema->TryCreateConnection(FromPin, Pin)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } // null out the backup connection (so we don't attempt to make it // once we exit the loop... we successfully made this connection!) BackupConnection = NULL; break; } else if((FromPin->PinType.PinCategory == K2Schema->PC_Exec) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A)) { InsertNewNode(FromPin, Pin, NodeList); // null out the backup connection (so we don't attempt to make it // once we exit the loop... we successfully made this connection!) BackupConnection = NULL; break; } else if ((BackupConnection == NULL) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE_WITH_CONVERSION_NODE)) { // save this off, in-case we don't make any connection at all BackupConnection = Pin; } } // if we didn't find an ideal connection, then lets connect this pin to // the BackupConnection (something, like a connection that requires a conversion node, etc.) if ((BackupConnection != NULL) && K2Schema->TryCreateConnection(FromPin, BackupConnection)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } // If we were not dragging an exec pin, but it was an output pin, try and connect the Then and Execute pins if ((FromPin->PinType.PinCategory != K2Schema->PC_Exec && FromPin->Direction == EGPD_Output)) { UEdGraphNode* FromPinNode = FromPin->GetOwningNode(); UEdGraphPin* FromThenPin = FromPinNode->FindPin(K2Schema->PN_Then); UEdGraphPin* ToExecutePin = FindPin(K2Schema->PN_Execute); if ((FromThenPin != NULL) && (FromThenPin->LinkedTo.Num() == 0) && (ToExecutePin != NULL) && K2Schema->ArePinsCompatible(FromThenPin, ToExecutePin, NULL)) { if (K2Schema->TryCreateConnection(FromThenPin, ToExecutePin)) { NodeList.Add(FromPinNode); NodeList.Add(this); } } } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } } }
FLinearColor UNiagaraNodeOutput::GetNodeTitleColor() const { return CastChecked<UEdGraphSchema_Niagara>(GetSchema())->NodeTitleColor_Attribute; }
UK2Node::ERedirectType UK2Node::DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const { ERedirectType RedirectType = ERedirectType_None; // if the pin names do match if (FCString::Stricmp(*(NewPin->PinName), *(OldPin->PinName)) == 0) { // Make sure we're not dealing with a menu node UEdGraph* OuterGraph = GetGraph(); if( OuterGraph && OuterGraph->Schema ) { const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema()); if( !K2Schema || K2Schema->IsSelfPin(*NewPin) || K2Schema->ArePinTypesCompatible(OldPin->PinType, NewPin->PinType) ) { RedirectType = ERedirectType_Name; } else { RedirectType = ERedirectType_None; } } } else { // try looking for a redirect if it's a K2 node if (UK2Node* Node = Cast<UK2Node>(NewPin->GetOwningNode())) { if (OldPin->ParentPin == NULL) { // if you don't have matching pin, now check if there is any redirect param set TArray<FString> OldPinNames; GetRedirectPinNames(*OldPin, OldPinNames); FName NewPinName; RedirectType = ShouldRedirectParam(OldPinNames, /*out*/ NewPinName, Node); // make sure they match if ((RedirectType != ERedirectType_None) && FCString::Stricmp(*(NewPin->PinName), *(NewPinName.ToString())) != 0) { RedirectType = ERedirectType_None; } } else { struct FPropertyDetails { const UEdGraphPin* Pin; FString PropertyName; FPropertyDetails(const UEdGraphPin* InPin, const FString& InPropertyName) : Pin(InPin), PropertyName(InPropertyName) { } }; TArray<FPropertyDetails> ParentHierarchy; FString NewPinNameStr; { const UEdGraphPin* CurPin = OldPin; do { ParentHierarchy.Add(FPropertyDetails(CurPin, CurPin->PinName.RightChop(CurPin->ParentPin->PinName.Len() + 1))); CurPin = CurPin->ParentPin; } while (CurPin->ParentPin); // if you don't have matching pin, now check if there is any redirect param set TArray<FString> OldPinNames; GetRedirectPinNames(*CurPin, OldPinNames); FName NewPinName; RedirectType = ShouldRedirectParam(OldPinNames, /*out*/ NewPinName, Node); NewPinNameStr = (RedirectType == ERedirectType_None ? CurPin->PinName : NewPinName.ToString()); } for (int32 ParentIndex = ParentHierarchy.Num() - 1; ParentIndex >= 0; --ParentIndex) { const UEdGraphPin* CurPin = ParentHierarchy[ParentIndex].Pin; const UEdGraphPin* ParentPin = CurPin ? CurPin->ParentPin : nullptr; const UObject* SubCategoryObject = ParentPin ? ParentPin->PinType.PinSubCategoryObject.Get() : nullptr; TMap<FName, FName>* StructRedirects = SubCategoryObject ? UStruct::TaggedPropertyRedirects.Find(SubCategoryObject->GetFName()) : nullptr; if (StructRedirects) { FName* PropertyRedirect = StructRedirects->Find(FName(*ParentHierarchy[ParentIndex].PropertyName)); if (PropertyRedirect) { NewPinNameStr += FString("_") + PropertyRedirect->ToString(); } else { NewPinNameStr += FString("_") + ParentHierarchy[ParentIndex].PropertyName; } } else { NewPinNameStr += FString("_") + ParentHierarchy[ParentIndex].PropertyName; } } // make sure they match RedirectType = ((FCString::Stricmp(*(NewPin->PinName), *NewPinNameStr) != 0) ? ERedirectType_None : ERedirectType_Name); } } } return RedirectType; }
TEST_F(LayoutTunerTests, BasicTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; std::string db_name = "test_db"; TestingExecutorUtil::InitializeDatabase(db_name); auto data_table = TestingExecutorUtil::CreateTableUpdateCatalog(tuple_count, db_name); // Create a table and populate it auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); TestingExecutorUtil::PopulateTable(data_table, tuple_count, false, false, true, txn); txn_manager.CommitTransaction(txn); // Check column count oid_t column_count = data_table->GetSchema()->GetColumnCount(); EXPECT_EQ(column_count, 4); // Layout tuner tuning::LayoutTuner &layout_tuner = tuning::LayoutTuner::GetInstance(); // Attach table to index tuner layout_tuner.AddTable(data_table); // Check old default tile group layout auto old_default_layout = data_table->GetDefaultLayout(); LOG_INFO("Layout: %s", old_default_layout->GetColumnMapInfo().c_str()); // Start layout tuner layout_tuner.Start(); std::vector<double> columns_accessed(column_count, 0); double sample_weight; // initialize a uniform distribution between 0 and 1 UniformGenerator generator; for (int sample_itr = 0; sample_itr < 10000; sample_itr++) { auto rng_val = generator.GetSample(); if (rng_val < 0.9) { columns_accessed = {0, 1, 2}; sample_weight = 100; } else { columns_accessed = {3}; sample_weight = 10; } // Create a table access sample // Indicates the columns accessed (bitmap), and query weight tuning::Sample sample(columns_accessed, sample_weight); // Collect layout sample in table data_table->RecordLayoutSample(sample); // Periodically sleep a bit // Layout tuner thread will process the layout samples periodically, // derive the new table layout, and // transform the layout of existing tile groups in the table if(sample_itr % 100 == 0 ){ std::this_thread::sleep_for(std::chrono::microseconds(1000)); } } // Stop layout tuner layout_tuner.Stop(); // Detach all tables from layout tuner layout_tuner.ClearTables(); // Check new default tile group layout auto new_default_layout = data_table->GetDefaultLayout(); LOG_INFO("Layout: %s", new_default_layout->GetColumnMapInfo().c_str()); // Ensure that the layout has been changed EXPECT_NE(*new_default_layout, *old_default_layout); // Check the new default table layout column_count = new_default_layout->GetColumnCount(); EXPECT_EQ(column_count, 4); // Check the tile corresponding to each column. EXPECT_EQ(new_default_layout->GetTileIdFromColumnId(0), 0); EXPECT_EQ(new_default_layout->GetTileIdFromColumnId(1), 0); EXPECT_EQ(new_default_layout->GetTileIdFromColumnId(2), 0); EXPECT_EQ(new_default_layout->GetTileIdFromColumnId(3), 1); // Check the per tile stats of the new layout // The layout must contain 2 tiles with the following stats // 0 -> 3 // 1 -> 1 auto layout_stats = new_default_layout->GetLayoutStats(); EXPECT_EQ(layout_stats[0], 3); EXPECT_EQ(layout_stats[1], 1); TestingExecutorUtil::DeleteDatabase(db_name); }
void UK2Node_ConvertAsset::AllocateDefaultPins() { const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema()); CreatePin(EGPD_Input, K2Schema->PC_Wildcard, TEXT(""), nullptr, false, false, UK2Node_ConvertAssetImpl::InputPinName); CreatePin(EGPD_Output, K2Schema->PC_Wildcard, TEXT(""), nullptr, false, false, UK2Node_ConvertAssetImpl::OutputPinName); }
/** * @brief read tuple record from log file and add them tuples to recovery txn * @param recovery txn */ void AriesFrontendLogger::UpdateTuple(concurrency::Transaction *recovery_txn) { TupleRecord tuple_record(LOGRECORD_TYPE_ARIES_TUPLE_UPDATE); // Check for torn log write if (ReadTupleRecordHeader(tuple_record, log_file, log_file_size) == false) { return; } auto txn_id = tuple_record.GetTransactionId(); if (recovery_txn_table.find(txn_id) == recovery_txn_table.end()) { LOG_TRACE("Update txd id %d not found in recovery txn table", (int)txn_id); return; } auto txn = recovery_txn_table.at(txn_id); auto table = GetTable(tuple_record); auto tuple = ReadTupleRecordBody(table->GetSchema(), recovery_pool, log_file, log_file_size); // Check for torn log write if (tuple == nullptr) { return; } // First, redo the delete ItemPointer delete_location = tuple_record.GetDeleteLocation(); bool status = table->DeleteTuple(recovery_txn, delete_location); if (status == false) { recovery_txn->SetResult(Result::RESULT_FAILURE); } else { txn->RecordDelete(delete_location); auto target_location = tuple_record.GetInsertLocation(); auto tile_group_id = target_location.block; auto tuple_slot = target_location.offset; auto &manager = catalog::Manager::GetInstance(); auto tile_group = manager.GetTileGroup(tile_group_id); // Create new tile group if table doesn't already have that tile group if (tile_group == nullptr) { table->AddTileGroupWithOid(tile_group_id); tile_group = manager.GetTileGroup(tile_group_id); if (max_oid < tile_group_id) { max_oid = tile_group_id; } } // Do the insert ! auto inserted_tuple_slot = tile_group->InsertTuple( recovery_txn->GetTransactionId(), tuple_slot, tuple); if (inserted_tuple_slot == INVALID_OID) { recovery_txn->SetResult(Result::RESULT_FAILURE); } else { txn->RecordInsert(target_location); } } delete tuple; }
FLinearColor UNiagaraNodeWriteDataSet::GetNodeTitleColor() const { check(DataSet.Type == ENiagaraDataSetType::Event);//Implement other datasets return CastChecked<UEdGraphSchema_Niagara>(GetSchema())->NodeTitleColor_Event; }