当前位置: 首页>>代码示例>>C++>>正文


C++ create_table函数代码示例

本文整理汇总了C++中create_table函数的典型用法代码示例。如果您正苦于以下问题:C++ create_table函数的具体用法?C++ create_table怎么用?C++ create_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
     
     SymbolTable* symtbl = create_table(SYMTBL_UNIQUE_NAME);
     SymbolTable* reltbl = create_table(SYMTBL_UNIQUE_NAME);

     FILE* input1  = fopen("myinstr.txt", "r");
     FILE* output1 = fopen("res.txt", "w");
     pass_one(input1, output1, symtbl);

     fclose(input1);
     fclose(output1);
     FILE* input2 = fopen("res.txt", "r");
     FILE* output2 = fopen("final.txt", "w");
     
     pass_two(input2, output2,  symtbl, reltbl);
     
     // int ret = translate_inst(stdout, "addu", args,  3 , 0,  tb1, tb2);
     
     printf("symtbl:\n");
     write_table(symtbl, stdout);
     printf("reltbl:\n");
     write_table(reltbl, stdout);

     free_table(symtbl);
     free_table(reltbl);
     
     fclose(input2);
     fclose(output2);
     return 0;
}
开发者ID:rstallman,项目名称:sdust,代码行数:31,代码来源:assembler_unitTest.c

示例2:

static const char *create_table_set(struct subdbinfo *info,
				    const char *suffix,
				    int do_mlog)
{
  const char *r;

  /* Address table */
  if ((r = create_table(info,suffix,"",sql_sub_table_defn)) != 0)
    return r;
  /* Subscription log table. */
  if ((r = create_table(info,suffix,"_slog",sql_slog_table_defn)) != 0)
    return r;

  if (do_mlog) {
    /* main list inserts a cookie here. Sublists check it */
    if ((r = create_table(info,suffix,"_cookie",sql_cookie_table_defn)) != 0)
      return r;

    /* main and sublist log here when the message is done done=0 for
     * arrived, done=4 for sent, 5 for receit. */
    if ((r = create_table(info,suffix,"_mlog",sql_mlog_table_defn)) != 0)
      return r;
  }

  return 0;
}
开发者ID:bruceg,项目名称:ezmlm-idx,代码行数:26,代码来源:sub_sql.c

示例3: main

int main(int argc, char *argv[]) {

  /*
  cube *c0 = cube_edges1(init_cube());
  hash_cube_t h = hash_cube(c0);
  cube *c1 = reconstruct_edges1(&h);
  print_cube(c0);
  print_cube(c1);
  return 0;
  */

  if (argc != 2) {
    fprintf(stderr, "Usage: ./create_table {corners, edges1, edges2}\n");
    return 0;
  }
  if (!strcmp(argv[1], "corners")) {
    create_table(cube_corners, hash_cube, reconstruct_corners, CORNER_NODES);
  } else if (!strcmp(argv[1], "edges1")) {
    create_table(cube_edges1, hash_cube, reconstruct_edges1, EDGE_NODES);
  } else if (!strcmp(argv[1], "edges2")) {
    create_table(cube_edges2, hash_cube, reconstruct_edges2, EDGE_NODES);
  } else {
    fprintf(stderr, "Usage: ./create_table {corners, edge1, edge2}\n");
    return 0;
  }
}
开发者ID:temclaugh,项目名称:rubiks-solver,代码行数:26,代码来源:create_tables.c

示例4: dbCreate

static int dbCreate(Ndb * pNdb)
{
  create_table(SUBSCRIBER_TABLE, create_table_subscriber, pNdb);
  create_table(GROUP_TABLE     , create_table_group, pNdb);
  create_table(SESSION_TABLE   , create_table_session, pNdb);
  create_table(SERVER_TABLE    , create_table_server, pNdb);
  return 0;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:8,代码来源:userInterface.cpp

示例5: VARCHAR

static const char *create_table_set(struct subdbinfo *info,
                                    const char *suffix,
                                    int do_mlog)
{
    const char *r;

    /* Address table */
    /* Need varchar. Domain = 3 chars => fixed length, as opposed to
     * varchar Always select on domain and hash, so that one index should
     * do primary key(address) is very inefficient for MySQL.  MySQL
     * tables do not need a primary key. Other RDBMS require one. For the
     * log tables, just add an INT AUTO_INCREMENT. For the address table,
     * do that or use address as a primary key. */
    if ((r = create_table(info,suffix,""," ("
                          "  hash    INT4 NOT NULL,"
                          "  address VARCHAR(255) NOT NULL PRIMARY KEY"
                          ")")) != 0)
        return r;
    /* Subscription log table. No addr idx to make insertion fast, since
     * that is almost the only thing we do with this table */
    if ((r = create_table(info,suffix,"_slog","("
                          "  tai		INTEGER,"
                          "  address	VARCHAR(255) NOT NULL,"
                          "  fromline	VARCHAR(255) NOT NULL,"
                          "  edir		CHAR NOT NULL,"
                          "  etype	CHAR NOT NULL"
                          ")")) != 0)
        return r;

    if (do_mlog) {
        /* main list inserts a cookie here. Sublists check it */
        if ((r = create_table(info,suffix,"_cookie","("
                              "  msgnum		INT4 NOT NULL PRIMARY KEY,"
                              "  tai		INTEGER NOT NULL,"
                              "  cookie		CHAR(20) NOT NULL,"
                              "  chunk		INT4 NOT NULL DEFAULT 0,"
                              "  bodysize	INT4 NOT NULL DEFAULT 0"
                              ")")) != 0)
            return r;

        /* main and sublist log here when the message is done done=0 for
         * arrived, done=4 for sent, 5 for receit.  tai reflects last
         * change */
        if ((r = create_table(info,suffix,"_mlog","("
                              "msgnum	INT4 NOT NULL,"
                              "listno	INT4 NOT NULL,"
                              "tai		TIMESTAMP,"
                              "subs		INT4 NOT NULL DEFAULT 0,"
                              "done		INT4 NOT NULL DEFAULT 0,"
                              "PRIMARY KEY (listno,msgnum,done)"
                              ")")) != 0)
            return r;
    }

    return 0;
}
开发者ID:abh,项目名称:ezmlm-idx,代码行数:56,代码来源:sub-sqlite3.c

示例6: test_db

void test_db() {
  // Create a database with the default options.
  auto db = grnxx::open_db("");
  assert(db->num_tables() == 0);

  // Create a table named "Table_1".
  auto table = db->create_table("Table_1");
  assert(table->name() == "Table_1");
  assert(db->num_tables() == 1);
  assert(db->get_table(0) == table);

  assert(db->find_table("Table_1") == table);
  assert(!db->find_table("Table_X"));

  // The following create_table() must fail because "Table_1" already exists.
  try {
    db->create_table("Table_1");
    assert(false);
  } catch (...) {
  }

  // Create tables named "Table_2" and "Table_3".
  assert(db->create_table("Table_2"));
  assert(db->create_table("Table_3"));
  assert(db->num_tables() == 3);
  assert(db->get_table(0)->name() == "Table_1");
  assert(db->get_table(1)->name() == "Table_2");
  assert(db->get_table(2)->name() == "Table_3");

  // Remove "Table_2".
  db->remove_table("Table_2");
  assert(db->num_tables() == 2);
  assert(db->get_table(0)->name() == "Table_1");
  assert(db->get_table(1)->name() == "Table_3");

  // Recreate "Table_2".
  assert(db->create_table("Table_2"));

  // Move "Table_3" to the next to "Table_2".
  db->reorder_table("Table_3", "Table_2");
  assert(db->get_table(0)->name() == "Table_1");
  assert(db->get_table(1)->name() == "Table_2");
  assert(db->get_table(2)->name() == "Table_3");

  // Move "Table_3" to the head.
  db->reorder_table("Table_3", "");
  assert(db->get_table(0)->name() == "Table_3");
  assert(db->get_table(1)->name() == "Table_1");
  assert(db->get_table(2)->name() == "Table_2");

  // Move "Table_2" to the next to "Table_3".
  db->reorder_table("Table_2", "Table_3");
  assert(db->get_table(0)->name() == "Table_3");
  assert(db->get_table(1)->name() == "Table_2");
  assert(db->get_table(2)->name() == "Table_1");
}
开发者ID:groonga,项目名称:grnxx,代码行数:56,代码来源:test_db.cpp

示例7: test_reference

void test_reference() {
  // Create tables.
  auto db = grnxx::open_db("");
  auto to_table = db->create_table("To");
  auto from_table = db->create_table("From");

  // Create a column named "Ref".
  grnxx::ColumnOptions options;
  options.reference_table_name = "To";
  auto ref_column = from_table->create_column("Ref", GRNXX_INT, options);

  // Append rows.
  to_table->insert_row();
  to_table->insert_row();
  to_table->insert_row();
  from_table->insert_row();
  from_table->insert_row();
  from_table->insert_row();

  ref_column->set(grnxx::Int(0), grnxx::Int(0));
  ref_column->set(grnxx::Int(1), grnxx::Int(1));
  ref_column->set(grnxx::Int(2), grnxx::Int(1));

  // TODO: "from_table" may be updated in "to_table->remove_row()".

  to_table->remove_row(grnxx::Int(0));

  grnxx::Datum datum;
  ref_column->get(grnxx::Int(0), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 0);
  ref_column->get(grnxx::Int(1), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 1);
  ref_column->get(grnxx::Int(2), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 1);

  to_table->remove_row(grnxx::Int(1));

  ref_column->get(grnxx::Int(0), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 0);
  ref_column->get(grnxx::Int(1), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 1);
  ref_column->get(grnxx::Int(2), &datum);
  assert(datum.type() == GRNXX_INT);
  assert(datum.as_int().raw() == 1);
}
开发者ID:groonga,项目名称:grnxx,代码行数:50,代码来源:test_table.cpp

示例8: convert_table

void convert_table(char *in,char *out)
{
  TABLE src,dst;
  int i;

  if (open_table(&src,in,"I")<0) {
    print_error("Cannot open input file %s",in);
    exit_session(ERR_OPEN);
  }
  else
    handle_select_flag(&src,'Q',NULL);

  if (create_table(&dst,out,src.row,src.col,'W',src.ident)<0) {
    close_table(&src);
    print_error("Cannot create output file %s",out);
    exit_session(ERR_CREAT);
  }
  else {
    reset_print_progress();
    for (i=1;i<=src.col;i++) {
      print_progress("Convert table: ", (int)((100*i)/src.col),1);
      copy_col(&src,&dst,i);
    }
	
    CP_non_std_desc(&src,&dst);
	
    close_table(&dst);
    close_table(&src);
  }
}
开发者ID:snfactory,项目名称:ifuio,代码行数:30,代码来源:convert.c

示例9: main

int main()
{
    struct Table* tbl = create_table();
    insert(tbl,"value0",0);
    insert(tbl,"value1",1);
    insert(tbl,"value2",2);
    print_table(tbl);
    printf("Removing value1\n");
    {
        int val = erase(tbl,"value1");
        printf("value1 had value %d\n",val);
    }
    print_table(tbl);
    {
        int val = find(tbl,"value2");
        printf("value2 has value %d\n",val);
        val = find(tbl,"valuex");
        if (val == -99999)
            printf("can't find valuex\n");
        val = erase(tbl,"valuex");
        if (val == -99999)
            printf("can't erase valuex\n");
    }
    destroy(tbl);
}
开发者ID:AndrewFrauens,项目名称:stroustrup_ppp,代码行数:25,代码来源:chapter27_ex12.c

示例10: expand_table

// dynamically expand hash table
void expand_table(hash_table *h)
{
	int i, index, new_size;
	
	new_size = next_prime(h->capacity * 2 + 1);

	// create new, expanded hash table
	hash_table *new_table = create_table(new_size);
	
	printf("Hash table before expansion to size %d:\n", new_size);
	print_table(h);
	
	// rehash elements from the old table into the new table
	for (i = 0; i < h->capacity; i++)
	{
		if (h->table[i] != NULL)
		{
			index = get_pos(new_table, *h->table[i]);
			new_table->table[index] = h->table[i];
		
			new_table->size++;
		}
	}
	
	free(h->table);
	
	h->table    = new_table->table;
	h->size     = new_table->size;
	h->capacity = new_table->capacity;
	
	free(new_table);
	
	printf("Hash table after expansion:\n");
	print_table(h);
}
开发者ID:ShowLove,项目名称:perfectMySkills,代码行数:36,代码来源:hash_table_int_null.c

示例11: run_application

static void run_application(MYSQL &mysql,
			    Ndb_cluster_connection &cluster_connection,
			    const char* table,
			    const char* db)
{
  /********************************************
   * Connect to database via mysql-c          *
   ********************************************/
 char db_stmt[256];
 sprintf(db_stmt, "CREATE DATABASE %s\n", db);
  mysql_query(&mysql, db_stmt);
 sprintf(db_stmt, "USE %s", db);
  if (mysql_query(&mysql, db_stmt) != 0) MYSQLERROR(mysql);
  create_table(mysql, table);

  /********************************************
   * Connect to database via NdbApi           *
   ********************************************/
  // Object representing the database
  Ndb myNdb( &cluster_connection, db );
  if (myNdb.init()) APIERROR(myNdb.getNdbError());

  /*
   * Do different operations on database
   */
  do_insert(myNdb, table);
  do_update(myNdb, table);
  do_delete(myNdb, table);
  do_read(myNdb, table);
  /*
   * Drop the table
   */
  mysql_query(&mysql, db_stmt);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:34,代码来源:main.cpp

示例12: state

microscopes::lda::state::state(const model_definition &defn,
      float alpha,
      float beta,
      float gamma,
      const microscopes::lda::nested_vector &dish_assignments,
      const microscopes::lda::nested_vector &table_assignments,
      const microscopes::lda::nested_vector &docs)
    : state(defn, alpha, beta, gamma, docs) {
        // Explicit initialization constructor for state used for
        // deserialization and testing
        // table_assignment maps words to tables (and should be the same
        //  shape as docs)
        // dish_assignment maps tables to dishes (its outer length should
        //  be the the same as docs. Its inner length one plus the maximum
        //  table index value for the given entity/doc.)

        // Create all the dishes we will need.
        for(auto dish: lda_util::unique_members(dish_assignments)) {
            create_dish(dish);
        }
        for (size_t eid = 0; eid < nentities(); ++eid) {
            create_entity(eid);
            // Create all the tables we will need and assign them to their dish.
            for(auto did: dish_assignments[eid]){
                create_table(eid, did);
            }
            // Assign words to tables.
            for(size_t word_index = 0; word_index < table_assignments[eid].size(); word_index++){
                auto tid  = table_assignments[eid][word_index];
                add_table(eid, tid, word_index);
            }
        }
}
开发者ID:mrG7,项目名称:lda,代码行数:33,代码来源:model.cpp

示例13: test_set_and_get

void test_set_and_get() {
  constexpr size_t NUM_ROWS = 1 << 16;

  // Create a table and insert the first row.
  auto db = grnxx::open_db("");
  auto table = db->create_table("Table");
  auto column = table->create_column("Column", T::type());
  grnxx::Array<T> values;
  values.resize(NUM_ROWS);
  for (size_t i = 0; i < NUM_ROWS; ++i) {
    generate_random_value(&values[i]);
    grnxx::Int row_id = table->insert_row();
    column->set(row_id, values[i]);
    grnxx::Datum datum;
    column->get(row_id, &datum);

    T stored_value;
    datum.force(&stored_value);
    assert(stored_value.match(values[i]));
  }

  // Test all the values again.
  for (size_t i = 0; i < NUM_ROWS; ++i) {
    grnxx::Int row_id = grnxx::Int(i);
    grnxx::Datum datum;
    column->get(row_id, &datum);
    T stored_value;
    datum.force(&stored_value);
    assert(stored_value.match(values[i]));
  }
}
开发者ID:groonga,项目名称:grnxx,代码行数:31,代码来源:test_column.cpp

示例14: test_dbd_generic

static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, 
                             const apr_dbd_driver_t* driver)
{
    void* native;
    apr_pool_t *pool = p;
    apr_status_t rv;

    native = apr_dbd_native_handle(driver, handle);
    ABTS_PTR_NOTNULL(tc, native);

    rv = apr_dbd_check_conn(driver, pool, handle);

    create_table(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    insert_data(tc, handle, driver, 5);
    select_rows(tc, handle, driver, 5);
    delete_rows(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    drop_table(tc, handle, driver);

    test_escape(tc, handle, driver);

    rv = apr_dbd_close(driver, handle);
    ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS);
}
开发者ID:cookrn,项目名称:openamq,代码行数:25,代码来源:testdbd.c

示例15: start_workers

/*
 * start_workers --
 *     Setup the configuration for the tables being populated, then start
 *     the worker thread(s) and wait for them to finish.
 */
int
start_workers(table_type type)
{
	WT_SESSION *session;
	struct timeval start, stop;
	double seconds;
	pthread_t *tids;
	int i, ret;
	void *thread_ret;

	ret = 0;

	/* Create statistics and thread structures. */
	if ((tids = calloc((size_t)(g.nworkers), sizeof(*tids))) == NULL)
		return (log_print_err("calloc", errno, 1));

	if ((ret = g.conn->open_session(g.conn, NULL, NULL, &session)) != 0) {
		(void)log_print_err("conn.open_session", ret, 1);
		goto err;
	}
	/* Setup the cookies */
	for (i = 0; i < g.ntables; ++i) {
		g.cookies[i].id = i;
		if (type == MIX)
			g.cookies[i].type =
			    (table_type)((i % MAX_TABLE_TYPE) + 1);
		else
			g.cookies[i].type = type;
		(void)snprintf(g.cookies[i].uri, 128,
		    "%s%04d", URI_BASE, g.cookies[i].id);

		/* Should probably be atomic to avoid races. */
		if ((ret = create_table(session, &g.cookies[i])) != 0)
			goto err;
	}

	(void)gettimeofday(&start, NULL);

	/* Create threads. */
	for (i = 0; i < g.nworkers; ++i) {
		if ((ret = pthread_create(
		    &tids[i], NULL, worker, &g.cookies[i])) != 0) {
			(void)log_print_err("pthread_create", ret, 1);
			goto err;
		}
	}

	/* Wait for the threads. */
	for (i = 0; i < g.nworkers; ++i)
		(void)pthread_join(tids[i], &thread_ret);

	(void)gettimeofday(&stop, NULL);
	seconds = (stop.tv_sec - start.tv_sec) +
	    (stop.tv_usec - start.tv_usec) * 1e-6;
	printf("Ran workers for: %f seconds\n", seconds);

err:	free(tids);

	return (ret);
}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:65,代码来源:workers.c


注:本文中的create_table函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。