示例#1
0
TEST_F(OperatorsTableScanStringTest, ScanLikeOnSpecialChars) {
  std::shared_ptr<Table> expected_result_1 =
      load_table("resources/test_data/tbl/int_string_like_special_chars_1.tbl", 1);
  std::shared_ptr<Table> expected_result_2 =
      load_table("resources/test_data/tbl/int_string_like_special_chars_2.tbl", 1);
  std::shared_ptr<Table> expected_result_4 =
      load_table("resources/test_data/tbl/int_string_like_special_chars_3.tbl", 1);

  auto scan1 = create_table_scan(_gt_special_chars, ColumnID{1}, PredicateCondition::Like, "%2^2%");
  scan1->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan1->get_output(), expected_result_1);

  auto scan2 = create_table_scan(_gt_special_chars, ColumnID{1}, PredicateCondition::Like, "%$%$%");
  scan2->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan2->get_output(), expected_result_1);

  std::shared_ptr<Table> expected_result2 =
      load_table("resources/test_data/tbl/int_string_like_special_chars_2.tbl", 1);
  auto scan3 = create_table_scan(_gt_special_chars, ColumnID{1}, PredicateCondition::Like, "%(%)%");
  scan3->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan3->get_output(), expected_result_2);

  auto scan4 = create_table_scan(_gt_special_chars, ColumnID{1}, PredicateCondition::Like, "%la\\.^$+?)({}.*__bl%");
  scan4->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan4->get_output(), expected_result_4);
}
示例#2
0
  void SetUp() override {
    std::shared_ptr<Table> test_table = load_table("resources/test_data/tbl/int_float.tbl", 2);
    StorageManager::get().add_table("table_a", std::move(test_table));
    _gt = std::make_shared<GetTable>("table_a");
    _gt->execute();

    // load string table
    std::shared_ptr<Table> test_table_string = load_table("resources/test_data/tbl/int_string_like.tbl", 2);
    StorageManager::get().add_table("table_string", std::move(test_table_string));
    _gt_string = std::make_shared<GetTable>("table_string");
    _gt_string->execute();

    // load special chars table
    std::shared_ptr<Table> test_table_special_chars =
        load_table("resources/test_data/tbl/int_string_like_special_chars.tbl", 2);
    StorageManager::get().add_table("table_special_chars", std::move(test_table_special_chars));
    _gt_special_chars = std::make_shared<GetTable>("table_special_chars");
    _gt_special_chars->execute();

    // load and compress string table
    if (::testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
      // Not all tests are parameterized - only those using compressed segments are. We have to ask the testing
      // framework if a parameter is set. Otherwise, GetParam would fail.
      auto test_table_string_compressed = load_table("resources/test_data/tbl/int_string_like.tbl", 5);
      std::vector<ChunkEncodingSpec> spec = {{EncodingType::Unencoded, GetParam()},
                                             {EncodingType::Unencoded, GetParam()}};
      ChunkEncoder::encode_all_chunks(test_table_string_compressed, spec);

      StorageManager::get().add_table("table_string_compressed", test_table_string_compressed);

      _gt_string_compressed = std::make_shared<GetTable>("table_string_compressed");
      _gt_string_compressed->execute();
    }
  }
示例#3
0
  void SetUp() override {
    _encoding_type = GetParam();

    _table_wrapper = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float.tbl", 2));
    _table_wrapper_null =
        std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float_with_null.tbl", 2));

    auto table = load_table("resources/test_data/tbl/int_float.tbl", 2);
    ChunkEncoder::encode_all_chunks(table, _encoding_type);

    auto table_dict = load_table("resources/test_data/tbl/int_float_with_null.tbl", 2);
    ChunkEncoder::encode_all_chunks(table_dict, _encoding_type);

    _table_wrapper_dict = std::make_shared<TableWrapper>(std::move(table));
    _table_wrapper_dict->execute();

    _table_wrapper_null_dict = std::make_shared<TableWrapper>(std::move(table_dict));
    _table_wrapper_null_dict->execute();

    _table_wrapper_outer_join = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float2.tbl", 2));
    _table_wrapper_outer_join->execute();

    _table_wrapper->execute();
    _table_wrapper_null->execute();
  }
示例#4
0
  void SetUp() override {
    table_wrapper_a = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float.tbl", 2));
    table_wrapper_a->execute();
    table_wrapper_b = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float.tbl", 2));
    table_wrapper_b->execute();

    a_a = PQPColumnExpression::from_table(*table_wrapper_a->get_output(), "a");
    a_b = PQPColumnExpression::from_table(*table_wrapper_a->get_output(), "b");
  }
示例#5
0
  void SetUp() override {
    StorageManager::get().add_table("t_a", load_table("resources/test_data/tbl/int_float.tbl", 1));
    StorageManager::get().add_table("t_b", load_table("resources/test_data/tbl/int_float.tbl", 1));

    _stored_table_node = StoredTableNode::make("t_a");
    _a = LQPColumnReference(_stored_table_node, ColumnID{0});
    _b = LQPColumnReference(_stored_table_node, ColumnID{1});

    _stored_table_node->set_pruned_chunk_ids({ChunkID{2}});
  }
示例#6
0
TEST_P(OperatorsSortTest, AscendingSortOFilteredColumn) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_float_filtered_sorted.tbl", 2);

  auto input = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float.tbl", 1));
  input->execute();

  auto scan = create_table_scan(input, ColumnID{0}, PredicateCondition::NotEquals, 123);
  scan->execute();

  auto sort = std::make_shared<Sort>(scan, ColumnID{0}, OrderByMode::Ascending, 2u);
  sort->execute();

  EXPECT_TABLE_EQ_ORDERED(sort->get_output(), expected_result);
}
int64_t
execute (int   argc,
         char *argv[])
{
    int64_t count = 0;
    const char *uristr = MONGODB_DEFAULT_URI;
    const char *database_name;
    mongoc_uri_t *uri;
    mongoc_client_t *client;
    mongoc_database_t *db;

    bson_t bson_schema;
    bson_error_t error;
    int argi;

    uristr = getenv ("MONGODB_URI");
    uri = mongoc_uri_new (uristr);
    client = mongoc_client_new (uristr);
    database_name = mongoc_uri_get_database (uri);
    db = mongoc_client_get_database (client, database_name);

    bson_init_from_json_file (&bson_schema, schema_file) || WARN_ERROR;
    for (argi = 0; argi < argc; argi++) {
        fprintf (stderr, "[%d/%d] %s\n", argi + 1, argc, argv[argi]);
        count += load_table (db, argv[argi], &bson_schema);
    }
    bson_destroy (&bson_schema);

    mongoc_database_destroy (db);
    mongoc_client_destroy (client);
    mongoc_uri_destroy (uri);
    return count;
}
示例#8
0
TEST_P(OperatorsTableScanStringTest, ScanLessThan) {
  auto scan = create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::LessThan, "Schiff");
  scan->execute();
  EXPECT_EQ(scan->get_output()->row_count(), 5u);
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_less_than.tbl", 1);
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
示例#9
0
TEST_P(OperatorsTableScanStringTest, ScanNotLikeUnderscoreWildcardOnDict) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_not_starting.tbl", 1);
  // wildcard has to be placed at front and/or back of search
  auto scan = create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::NotLike, "D_m_f%");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
示例#10
0
TEST_F(OperatorsTableScanStringTest, ScanNotLikeAllRows) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_without_null.tbl", 1);
  // wildcard has to be placed at front and/or back of search string
  auto scan = create_table_scan(_gt_string, ColumnID{1}, PredicateCondition::NotLike, "%foo%");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
示例#11
0
/*!
  \brief get_table() gets a valid filehandle of the lookuptable from 
  get_file and passes it to load_table(void)
  \see load_table
  \see get_File
  \param table_name is the textual name of the table to use as the key
  to the lookuptables hashtable
  \param fname is the textual name of the filename to load
  \param user_data is unused
  */
G_MODULE_EXPORT void get_table(gpointer table_name, gpointer fname, gpointer user_data)
{
	gboolean status = FALSE;
	gchar * filename = NULL;
	gchar ** vector = NULL;
	gchar *pathstub = NULL;
	
	ENTER();
	vector = g_strsplit((gchar *)fname,".",2);

	pathstub = g_build_filename(LOOKUPTABLES_DATA_DIR,vector[0],NULL);
	filename = get_file((const gchar *)DATA_GET(global_data,"project_name"),pathstub,vector[1]);
	g_free(pathstub);
	g_strfreev(vector);

	if (filename)
	{
		status = load_table((gchar *)table_name,filename);
		g_free(filename);
	}
	if (!status)
	{
		MTXDBG(CRITICAL,_("FAILURE loading \"%s\" lookuptable, EXITING!!\n"),(gchar *)table_name);
		exit (-2);
	}

	EXIT();
	return;
}
示例#12
0
  void test_output(const std::shared_ptr<AbstractOperator> in, const std::vector<AggregateColumnDefinition>& aggregates,
                   const std::vector<ColumnID>& groupby_column_ids, const std::string& file_name, size_t chunk_size,
                   bool test_aggregate_on_reference_table = true) {
    // load expected results from file
    std::shared_ptr<Table> expected_result = load_table(file_name, chunk_size);
    EXPECT_NE(expected_result, nullptr) << "Could not load expected result table";

    {
      // Test the Aggregate on stored table data
      auto aggregate = std::make_shared<T>(in, aggregates, groupby_column_ids);
      aggregate->execute();
      EXPECT_TABLE_EQ_UNORDERED(aggregate->get_output(), expected_result);
    }

    if (test_aggregate_on_reference_table) {
      // Perform a TableScan to create a reference table
      const auto table_scan = std::make_shared<TableScan>(in, greater_than_(get_column_expression(in, ColumnID{0}), 0));
      table_scan->execute();

      // Perform the Aggregate on a reference table
      const auto aggregate = std::make_shared<T>(table_scan, aggregates, groupby_column_ids);
      aggregate->execute();
      EXPECT_TABLE_EQ_UNORDERED(aggregate->get_output(), expected_result);
    }
  }
示例#13
0
static void
load_form_element(const xmlNode *cur_node, form_element_t *parent)
{
    if (is_oftype(cur_node, "Group")) {
        const xmlNode *p = find_by_path(cur_node, "Properties/Type")->children;

        if (xstrcmp(p->content, "UsualGroup") == 0)
            load_usual_group(cur_node, parent);
    }

    if (is_oftype(cur_node, "Text")) {
        load_text_entry(cur_node, parent, false);
    }

    if (is_oftype(cur_node, "Input")) {
        load_input(cur_node, parent);
    }

    if (is_oftype(cur_node, "CheckBox")) {
        load_check_box(cur_node, parent);
    }

    if (is_oftype(cur_node, "Pages")) {
        load_pages(cur_node, parent);
    }

    if (is_oftype(cur_node, "Table")) {
        load_table(cur_node, parent);
    }

    if (is_oftype(cur_node, "CommandBar")) {
        load_command_bar(cur_node, parent);
    }

}
示例#14
0
TEST_P(OperatorsTableScanStringTest, ScanLikeContainingOnDictSegment) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_containing.tbl", 1);
  auto scan =
      create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::Like, "%schifffahrtsgesellschaft%");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
示例#15
0
TEST_P(OperatorsSortTest, MultipleColumnSortIsStableMixedOrder) {
  auto table_wrapper = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float4.tbl", 2));
  table_wrapper->execute();

  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_float2_sorted_mixed.tbl", 2);

  // we want the output to be sorted after column a and in second place after column b.
  // So first we sort after column b and then after column a.
  auto sort_after_b = std::make_shared<Sort>(table_wrapper, ColumnID{1}, OrderByMode::Descending, 2u);
  sort_after_b->execute();

  auto sort_after_a = std::make_shared<Sort>(sort_after_b, ColumnID{0}, OrderByMode::Ascending, 2u);
  sort_after_a->execute();

  EXPECT_TABLE_EQ_ORDERED(sort_after_a->get_output(), expected_result);
}
示例#16
0
int main (void) 
{
	if (!load_table())
	{
		// table didn't load properly
		printf("table didn't load properly\n");
		return 1;
	}
	
	while (true)
	{
		printf("1. Find a word in the dictionary\n");
		printf("2. Quit\n");

		int user_choice;
		do 
		{
			user_choice = GetInt();
		} while (user_choice != 1 && user_choice != 2);
		
		switch (user_choice)
		{
			case 1:
				printf("Please enter a word: ");
                char* word_to_find = GetString();
                char* success = find(word_to_find) ? "is" : "is not";
                printf("%s %s in the dictionary.\n",word_to_find, success);
                break;
            case 2:
            	return 0;
            	break;
		}
	}
	return 0;
}
示例#17
0
// PredicateCondition::Like - Containing Wildcard
TEST_F(OperatorsTableScanStringTest, ScanLikeContainingWildcard) {
  std::shared_ptr<Table> expected_result =
      load_table("resources/test_data/tbl/int_string_like_containing_wildcard.tbl", 1);
  auto scan = create_table_scan(_gt_string, ColumnID{1}, PredicateCondition::Like, "Schiff%schaft");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
示例#18
0
void SolveCube2::make_table_prun_template(int n1,int n2, int table1[][9], int table2[][9],char *table_deep,char*table_pre_move)
{
/*
	if(load_table("cube2_depth.dat",table_deep,n1*n2))
	{
		int max_depth=0;
		for(int i=0;i<n1*n2;i++)
		{
			if(table_deep[i]>max_depth)
			{
				max_depth=table_deep[i];
			}
		}
		std::cout<<"cube 2 max depth:"<<max_depth<<std::endl;
		if(load_table("cube2_pre_move.dat",table_pre_move,n1*n2))
		{
			return;
		}
	}
	*/
	if(load_table("cube2_pre_move.dat",table_pre_move,n1*n2))
	{
		return;
	}
	std::deque<int> temp;
	//temp.reserve(n1*n2);
	int count;
	int x,x1,x2;
	int y,y1,y2;
	int deep;
	memset(table_deep,-1,n1*n2);
	table_deep[0]=0;
	table_pre_move[0]=-1;
	count=1;
	temp.push_back(0);
	while(temp.empty()==false)
	{
		x=temp.front();
		temp.pop_front();
		x1= x/n2;
		x2= x%n2;
		deep= table_deep[x];
		for(int i=0;i<9;i++)
		{
			y1=table1[x1][i];
			y2=table2[x2][i];
			y=y1*n2+y2;
			if(table_deep[y]==-1)
			{
				temp.push_back(y);
				table_deep[y]=deep+1;
				table_pre_move[y]=i;
				count++;
			}
		}
	}
	assert(count==n1*n2);
	//save_table("cube2_depth.dat",table_deep,n1*n2);
	save_table("cube2_pre_move.dat",table_pre_move,n1*n2);
}
static int    unpack_long   (grib_accessor* a, long* val, size_t *len)
{
  grib_accessor_codetable* self = (grib_accessor_codetable*)a;
  unsigned long rlen = grib_value_count(a);
  unsigned long i = 0;
  long pos = a->offset*8;

  if(!self->table) self->table = load_table(self);

  if(*len < rlen)
  {
    grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen);
    *len = 0;
    return GRIB_ARRAY_TOO_SMALL;
  }

  if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) {
    *val=a->vvalue->lval;
    *len=1;
    return GRIB_SUCCESS;
  }

  for(i=0; i< rlen;i++){
    val[i] = (long)grib_decode_unsigned_long(a->parent->h->buffer->data , &pos, self->nbytes*8);
  }

  *len = rlen;
  return GRIB_SUCCESS;
}
示例#20
0
TEST_P(OperatorsSortTest, AscendingSortOfOneColumnWithoutChunkSize) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_float_sorted.tbl", 2);

  auto sort = std::make_shared<Sort>(_table_wrapper, ColumnID{0}, OrderByMode::Ascending);
  sort->execute();

  EXPECT_TABLE_EQ_ORDERED(sort->get_output(), expected_result);
}
示例#21
0
TEST_P(OperatorsSortTest, DescendingSortOfOneDictSegment) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_float_reverse.tbl", 2);

  auto sort = std::make_shared<Sort>(_table_wrapper_dict, ColumnID{0}, OrderByMode::Descending, 2u);
  sort->execute();

  EXPECT_TABLE_EQ_ORDERED(sort->get_output(), expected_result);
}
示例#22
0
TEST_P(OperatorsTableScanStringTest, ScanLikeEndingOnReferencedDictSegment) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_ending.tbl", 1);
  auto scan1 = create_table_scan(_gt_string_compressed, ColumnID{0}, PredicateCondition::GreaterThan, 0);
  scan1->execute();
  auto scan2 = create_table_scan(scan1, ColumnID{1}, PredicateCondition::Like, "%gesellschaft");
  scan2->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan2->get_output(), expected_result);
}
示例#23
0
TEST_P(OperatorsSortTest, DescendingSortOfOneColumnWithNullsLast) {
  std::shared_ptr<Table> expected_result =
      load_table("resources/test_data/tbl/int_float_null_sorted_desc_nulls_last.tbl", 2);

  auto sort = std::make_shared<Sort>(_table_wrapper_null, ColumnID{0}, OrderByMode::DescendingNullsLast, 2u);
  sort->execute();

  EXPECT_TABLE_EQ_ORDERED(sort->get_output(), expected_result);
}
示例#24
0
int add_file_table(int index, char *file) {
  char file2[XPP_MAX_NAME];
  clean_path(file2, sizeof(file2), file);
  if (load_table(file2, index) == 0) {
    plintf("Problem with creating table !!\n");
    return (1);
  }

  return (0);
}
示例#25
0
  void SetUp() override {
    const auto table_wrapper =
        std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_int_float.tbl", 1));
    table_wrapper->execute();

    auto column_ids = std::vector<ColumnID>({ColumnID{2}, ColumnID{0}, ColumnID{1}});
    auto aliases = std::vector<std::string>({"z", "x", "y"});

    alias_operator = std::make_shared<AliasOperator>(table_wrapper, column_ids, aliases);
  }
示例#26
0
rc_t load_passes( VDatabase * database, KDirectory * hdf5_src, ld_context *lctx )
{
    rc_t rc = 0;
    if ( lctx->check_src_obj )
        rc = check_src_objects( hdf5_src, passes_groups_to_check, 
                                passes_tables_to_check, false );
    if ( rc == 0 )
        rc = load_table( database, hdf5_src, lctx, passes_schema_template, 
                         passes_table_to_create, passes_loader );
    return rc;
}
示例#27
0
rc_t load_seq( VDatabase * database, KDirectory * hdf5_src, ld_context *lctx )
{
    rc_t rc = 0;
    if ( lctx->check_src_obj )
        rc = check_src_objects( hdf5_src, seq_groups_to_check, seq_tables_to_check, true );
    if ( rc == 0 )
        /* in pl-tools.c */
        rc = load_table( database, hdf5_src, lctx, seq_schema_template, 
                         seq_table_to_create, seq_loader );
    return rc;
}
示例#28
0
rc_t load_consensus( ld_context *lctx, bool cache_content, bool check_src_obj )
{
    rc_t rc = 0;
    if ( check_src_obj )
        rc = check_src_objects( lctx->hdf5_dir, consensus_groups_to_check, 
                                consensus_tables_to_check, false );
    if ( rc == 0 )
        rc = load_table( lctx, consensus_schema_template, 
                         consensus_table_to_create, consensus_loader, cache_content );
    return rc;
}
示例#29
0
TEST_P(OperatorsSortTest, SortAfterOuterJoin) {
  auto join =
      std::make_shared<JoinNestedLoop>(_table_wrapper, _table_wrapper_outer_join, JoinMode::FullOuter,
                                       OperatorJoinPredicate{{ColumnID{0}, ColumnID{0}}, PredicateCondition::Equals});
  join->execute();

  auto sort = std::make_shared<Sort>(join, ColumnID{0}, OrderByMode::Ascending);
  sort->execute();

  std::shared_ptr<Table> expected_result =
      load_table("resources/test_data/tbl/join_operators/int_outer_join_sorted_asc.tbl", 2);
  EXPECT_TABLE_EQ_ORDERED(sort->get_output(), expected_result);
}
示例#30
0
TEST_F(OperatorsExportCsvTest, ExportNullValuesMeta) {
  auto table_wrapper = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float_with_null.tbl", 4));
  table_wrapper->execute();

  auto ex = std::make_shared<ExportCsv>(table_wrapper, test_filename);
  ex->execute();

  EXPECT_TRUE(file_exists(test_filename));
  EXPECT_TRUE(file_exists(test_meta_filename));

  auto meta_information = process_csv_meta_file(test_meta_filename);
  EXPECT_TRUE(meta_information.columns.at(0).nullable);
  EXPECT_TRUE(meta_information.columns.at(1).nullable);
}