Beispiel #1
0
void CGridLocus::XferDisabled(int nCol, COARallele *pAllele)
{
    s = GetCellValue(ROW_DISABLE,nCol);
    bool b = IsTrue(s.c_str());
    pAllele->SetDisabled(b);
}
bool Condition::SafeIsTrue(Side side)
{
	return IsTrue(side);
}
Beispiel #3
0
/**
 * @brief Creates logical tile from tile group and applies scan predicate.
 * @return true on success, false otherwise.
 */
bool SeqScanExecutor::DExecute() {

  // Scanning over a logical tile.
  if (children_.size() == 1 &&
      // There will be a child node on the create index scenario,
      // but we don't want to use this execution flow
      !(GetRawNode()->GetChildren().size() > 0 &&
        GetRawNode()->GetChildren()[0].get()->GetPlanNodeType() ==
            PlanNodeType::CREATE &&
        ((planner::CreatePlan *)GetRawNode()->GetChildren()[0].get())
                ->GetCreateType() == CreateType::INDEX)) {
    // FIXME Check all requirements for children_.size() == 0 case.
    LOG_TRACE("Seq Scan executor :: 1 child ");

    PELOTON_ASSERT(target_table_ == nullptr);
    PELOTON_ASSERT(column_ids_.size() == 0);

    while (children_[0]->Execute()) {
      std::unique_ptr<LogicalTile> tile(children_[0]->GetOutput());

      if (predicate_ != nullptr) {
        // Invalidate tuples that don't satisfy the predicate.
        for (oid_t tuple_id : *tile) {
          ContainerTuple<LogicalTile> tuple(tile.get(), tuple_id);
          auto eval = predicate_->Evaluate(&tuple, nullptr, executor_context_);
          if (eval.IsFalse()) {
            // if (predicate_->Evaluate(&tuple, nullptr, executor_context_)
            //        .IsFalse()) {
            tile->RemoveVisibility(tuple_id);
          }
        }
      }

      if (0 == tile->GetTupleCount()) {  // Avoid returning empty tiles
        continue;
      }

      /* Hopefully we needn't do projections here */
      SetOutput(tile.release());
      return true;
    }
    return false;
  }
  // Scanning a table
  else if (children_.size() == 0 ||
           // If we are creating an index, there will be a child
           (children_.size() == 1 &&
            // This check is only needed to pass seq_scan_test
            // unless it is possible to add a executor child
            // without a corresponding plan.
            GetRawNode()->GetChildren().size() > 0 &&
            // Check if the plan is what we actually expect.
            GetRawNode()->GetChildren()[0].get()->GetPlanNodeType() ==
                PlanNodeType::CREATE &&
            // If it is, confirm it is for indexes
            ((planner::CreatePlan *)GetRawNode()->GetChildren()[0].get())
                    ->GetCreateType() == CreateType::INDEX)) {
    LOG_TRACE("Seq Scan executor :: 0 child ");

    PELOTON_ASSERT(target_table_ != nullptr);
    PELOTON_ASSERT(column_ids_.size() > 0);
    if (children_.size() > 0 && !index_done_) {
      children_[0]->Execute();
      // This stops continuous executions due to
      // a parent and avoids multiple creations
      // of the same index.
      index_done_ = true;
    }
    
    concurrency::TransactionManager &transaction_manager =
        concurrency::TransactionManagerFactory::GetInstance();

    bool acquire_owner = GetPlanNode<planner::AbstractScan>().IsForUpdate();
    auto current_txn = executor_context_->GetTransaction();

    // Retrieve next tile group.
    while (current_tile_group_offset_ < table_tile_group_count_) {
      auto tile_group =
          target_table_->GetTileGroup(current_tile_group_offset_++);
      auto tile_group_header = tile_group->GetHeader();

      oid_t active_tuple_count = tile_group->GetNextTupleSlot();

      // Construct position list by looping through tile group
      // and applying the predicate.
      std::vector<oid_t> position_list;
      for (oid_t tuple_id = 0; tuple_id < active_tuple_count; tuple_id++) {
        ItemPointer location(tile_group->GetTileGroupId(), tuple_id);

        auto visibility = transaction_manager.IsVisible(
            current_txn, tile_group_header, tuple_id);

        // check transaction visibility
        if (visibility == VisibilityType::OK) {
          // if the tuple is visible, then perform predicate evaluation.
          if (predicate_ == nullptr) {
            position_list.push_back(tuple_id);
            auto res = transaction_manager.PerformRead(current_txn, location,
                                                       acquire_owner);
            if (!res) {
              transaction_manager.SetTransactionResult(current_txn,
                                                       ResultType::FAILURE);
              return res;
            }
          } else {
            ContainerTuple<storage::TileGroup> tuple(tile_group.get(),
                                                     tuple_id);
            LOG_TRACE("Evaluate predicate for a tuple");
            auto eval =
                predicate_->Evaluate(&tuple, nullptr, executor_context_);
            LOG_TRACE("Evaluation result: %s", eval.GetInfo().c_str());
            if (eval.IsTrue()) {
              position_list.push_back(tuple_id);
              auto res = transaction_manager.PerformRead(current_txn, location,
                                                         acquire_owner);
              if (!res) {
                transaction_manager.SetTransactionResult(current_txn,
                                                         ResultType::FAILURE);
                return res;
              } else {
                LOG_TRACE("Sequential Scan Predicate Satisfied");
              }
            }
          }
        }
      }

      // Don't return empty tiles
      if (position_list.size() == 0) {
        continue;
      }

      // Construct logical tile.
      std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
      logical_tile->AddColumns(tile_group, column_ids_);
      logical_tile->AddPositionList(std::move(position_list));

      LOG_TRACE("Information %s", logical_tile->GetInfo().c_str());
      SetOutput(logical_tile.release());
      return true;
    }
  }

  return false;
}
Beispiel #4
0
Datei: svg.cpp Projekt: ogdf/ogdf
describe("SVG", []() {
	std::unique_ptr<Graph> graph;
	int numberOfNodes = 42;

	before_each([&](){
		graph.reset(new Graph);
		randomBiconnectedGraph(*graph, numberOfNodes, 3*numberOfNodes);
	});

	it("is well-formed", [&]() {
		GraphAttributes attr(*graph);
		pugi::xml_document doc;
		createDocument(attr, doc);

		pugi::xml_node svg = doc.child("svg");
		AssertThat((bool) svg, IsTrue());
		AssertThat(svg.attribute("viewBox").empty(), IsFalse());

		AssertThat(static_cast<int>(svg.select_nodes("//rect").size()), Equals(graph->numberOfNodes()));
		AssertThat(static_cast<int>(svg.select_nodes("//path").size()), Equals(graph->numberOfEdges()));
	});

	it("supports 3D", [&]() {
		GraphAttributes attr(*graph,
				GraphAttributes::nodeGraphics |
				GraphAttributes::nodeStyle |
				GraphAttributes::edgeGraphics |
				GraphAttributes::threeD |
				GraphAttributes::nodeLabel |
				GraphAttributes::nodeLabelPosition);
		List<node> nodes;
Beispiel #5
0
AVES_API NATIVE_FUNCTION(aves_Utf16Encoding_new)
{
	Utf16Encoding *encoding = THISV.Get<Utf16Encoding>();
	encoding->bigEndian = IsTrue(args + 1);
	RETURN_SUCCESS;
}
Beispiel #6
0
				perms.calcAll(&P,&allPerms);

				for (int i = 1; i < 10; i++){
					Graph G;
					randomSimpleGraph(G,N,1*N);

					//make an instance for the MAOs
					MaxAdjOrdering m;

					//make structures for saving all MAOs of G
					ListPure<ListPure<node>> MAOs;

					//calculate them
					m.calcAll(&G,&MAOs);

					AssertThat(m.testIfAllMAOs(&G,&MAOs,&allPerms), IsTrue());
				}
			}
		});
		it("should calculate MAOs with correct lex-bfs tie breaking", [](){
			for (int N = 10; N <= 20; N++){
				std::cout << "    " << "Busy with graphs that have " << N << " nodes." << std::endl;

				for (int i = 1; i < 10; i++){
					Graph G;
					randomSimpleGraph(G, N, (N*(N-4))/2);

					//make an instance for the MAOs
					MaxAdjOrdering m;

					//make structures for saving all MAOs of G
Beispiel #7
0
bool GetOptFlag(EscEscape& e) {
	if(!e.GetCount())
		return true;
	return IsTrue(e[0]);
}
Beispiel #8
0
void NativePlayerWnd::ProcessFSCommand( char* cmd, char* args )
{
    if ( StrEqual(cmd, "quit") )
    {
        // Quit
        ExitApp();
    }
    else if ( StrEqual(cmd, "fullscreen") )
    {
        SetFullScreen( IsTrue(args) != 0 );
    }
    else if ( StrEqual(cmd, "allowscale") )
    {
        SetScaleMode( IsTrue(args) );
    }
    else if ( StrEqual(cmd, "exec") )
    {
        // make sure we don't pass any parameters
        // to the app we want to spawn. We don't want
        // anybody to do "del *.*"
        int     len = strlen(args) + 1;
        char    *tmpString = new char[len];

        if ( tmpString == 0 )
            return;

        for ( int i = 0; i < len; i++ )
        {
            tmpString[i] = args[i];
            if ( tmpString[i] == ' ' )
            {
                tmpString[i] = 0;
                break;
            }
        }
        ExecSystem( tmpString );
        delete [] tmpString;
    }
    else if ( StrEqual(cmd, "showmenu") )
    {
        // Toggle the full screen flags
        /*
        showMenu = IsTrue(args);
        HMENU hMenu = GetMenu( hwnd );

        if (!showMenu)
        {
        	if (hMenu)
        	{
        		// Save and clear the menu bar
        		savedMenu = hMenu;
        		SetMenu( hwnd, 0);
        	}
        }
        else
        {
        	SetMenu( hwnd, savedMenu );
        }
        */
    }
    else
    {
        flash->command(cmd, args);
    }
}