📄 main.c
字号:
/*************************************************************** * * * Copyright (c) 2001-2006 McObject LLC. All Right Reserved. * * * ***************************************************************//* * This sample demonstrates the use of VECTORS and vector-based * indexes. It is based on the schema described in vectors.mco */#include "platform.h"#include <stdio.h>#include <stdlib.h>#include "vectors.h"#include "demo.h"#define DB_MEM_SIZE 1024 * 10000 /* bytes to be used by database */#ifndef MCO_PLATFORM_X64#define DB_PAGESIZE 120 /* page size */#else#define DB_PAGESIZE 240 /* page size */#endifconst int MAP_ADDRESS = 0x20000000;void _SH_(void) { char text[] = { "\nThis sample demonstrates the use of VECTOR declaration, vector-based\n" "operations and vector-based indexes.\n" }; char text1[] = { "Copyright (c) 2001-2006 McObject LLC. All Right Reserved.\n\n" }; printf("%s\neXtremeDB runtime version %d.%d, build %d\n%s\n\nPress Enter to start", text, MCO_COMP_VER_MAJOR, MCO_COMP_VER_MINOR, MCO_COMP_BUILD_NUM,text1); getchar();}int main( void ) { MCO_RET rc; mco_db_h db = 0; const char *instance_name = "demoDb"; void *db_mem; mco_runtime_info_t info; _SH_(); mco_get_runtime_info( &info); if ( info.mco_shm_supported ) { db_mem = (void*)MAP_ADDRESS; } else { db_mem = (void*)malloc(DB_MEM_SIZE); if (!db_mem) { printf("Couldn't allocated memory\n"); exit (1); } }; rc = mco_runtime_start(); rc = mco_db_open( instance_name, vectors_get_dictionary(), db_mem, DB_MEM_SIZE, DB_PAGESIZE ); if ( rc ) { printf( "\nerror creating database" ); if ( !info.mco_shm_supported ) free( db_mem ); exit( 1 ); } mco_db_connect( instance_name, &db ); demo( db ); mco_db_disconnect( db ); mco_db_close( instance_name ); mco_runtime_stop(); if ( !info.mco_shm_supported ) free( db_mem ); printf( "\nPress Enter to exit" ); getchar(); PROG_EXIT(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -