/* { "type": "record", "name": "FinishRequest", "fields": [ {"name": "succeed", "type": "boolean"}, {"name": "diagnostics", "type": "string"} ] } */ static void parse_finish_request(avro_slice_t *slice, bool *succeed, char **diag) { char filename[FILE_NAME_LEN]; avro_schema_t schema; avro_value_iface_t *iface; avro_value_t record, succeed_value, diag_value; size_t index; avro_reader_t reader; size_t size; sprintf(filename, "%s/%s", SCHEMA_PATH, "FinishRequestRecordAvro.avsc"); init_schema(filename, &schema); iface = avro_generic_class_from_schema(schema); avro_generic_value_new(iface, &record); reader = avro_reader_memory(slice->buffer, slice->len); if (avro_value_read(reader, &record)) { fprintf(stderr, "Unable to read record from memory buffer\n"); fprintf(stderr, "Error: %s\n", avro_strerror()); exit(1); } avro_value_get_by_name(&record, "succeed", &succeed_value, &index); avro_value_get_boolean(&succeed_value, succeed); avro_value_get_by_name(&record, "diagnostics", &diag_value, &index); avro_value_get_string(&diag_value, diag, &size); //avro_generic_value_free(&record); avro_value_iface_decref(iface); avro_schema_decref(schema); }
/* typedef struct { int jobid; int vpid; } process_name_t; typedef struct { char *en_vars; char *args; char *host_name; process_name_t proc_name; } launch_context_t; typedef struct { bool is_successful; process_name_t proc_name; } launch_response_t; */ static void build_launch_response(launch_response_t *launch_response_array, int array_size, avro_slice_t **slice) { char filename[FILE_NAME_LEN]; char buf[BUFFER_SIZE]; long len = 0; avro_schema_t schema; avro_value_iface_t *iface; avro_value_t record; avro_value_t results_value, LaunchResult_value, is_successful_value, name_value, jobid_value, vpid_value; size_t index; int i; avro_writer_t writer; sprintf(filename, "%s/%s", SCHEMA_PATH, "LaunchResponseRecordAvro.avsc"); init_schema(filename, &schema); iface = avro_generic_class_from_schema(schema); avro_generic_value_new(iface, &record); avro_value_get_by_name(&record, "results", &results_value, &index); for (i = 0; i < array_size; i++) { avro_value_append(&results_value, &LaunchResult_value, &index); avro_value_get_by_name(&LaunchResult_value, "is_successful", &is_successful_value, &index); avro_value_set_boolean(&is_successful_value, launch_response_array[i].is_successful); avro_value_get_by_name(&LaunchResult_value, "name", &name_value, &index); avro_value_get_by_name(&name_value, "jobid", &jobid_value, &index); avro_value_set_int(&jobid_value, launch_response_array[i].proc_name.jobid); avro_value_get_by_name(&name_value, "vpid", &vpid_value, &index); avro_value_set_int(&vpid_value, launch_response_array[i].proc_name.vpid); } /* create a writer with memory buffer */ writer = avro_writer_memory(buf, sizeof(buf)); /* write record to writer (buffer) */ if (avro_value_write(writer, &record)) { fprintf(stderr, "Unable to write record to memory buffer\n"); fprintf(stderr, "Error: %s\n", avro_strerror()); exit(1); } avro_writer_flush(writer); len = avro_writer_tell(writer); //avro_generic_value_free(&record); avro_value_iface_decref(iface); avro_schema_decref(schema); *slice = xmalloc(sizeof(avro_slice_t)); (*slice)->buffer = xmalloc(len); (*slice)->len = len; memcpy((*slice)->buffer, buf, len); }
RC tpcc_wl::init() { workload::init(); string path = "./benchmarks/"; #if TPCC_SMALL path += "TPCC_short_schema.txt"; #else path += "TPCC_full_schema.txt"; #endif cout << "reading schema file: " << path << endl; init_schema( path.c_str() ); cout << "TPCC schema initialized" << endl; init_table(); next_tid = 0; return RCOK; }
/* run */ static rc_t run ( const vtblcp_parms *pb ) { VDBManager *mgr; rc_t rc = init_mgr ( pb, & mgr ); if ( rc == 0 ) { VSchema *schema; rc = init_schema ( pb, mgr, & schema ); if ( rc == 0 ) { const VTable *stbl; rc = open_src_table ( pb, mgr, schema, & stbl ); if ( rc == 0 ) { VTable *dtbl; rc = open_dst_table ( pb, mgr, schema, & dtbl ); if ( rc == 0 ) { /* determine columns */ Vector v; rc = get_column_specs ( pb, & v, stbl, dtbl ); /* perform the copy */ if ( rc == 0 ) { rc = vtblcp ( pb, stbl, dtbl, & v ); VectorWhack ( & v, free_column_spec, NULL ); } /* cleanup */ rc = close_dst_table ( pb, dtbl, rc ); } VTableRelease ( stbl ); } VSchemaRelease ( schema ); } VDBManagerRelease ( mgr ); } return rc; }
extern int parse_heartbeat_request(avro_slice_t *slice) { char filename[FILE_NAME_LEN]; avro_schema_t schema; avro_value_iface_t *iface; avro_value_t record; size_t index; avro_reader_t reader; size_t size = 0; sprintf(filename, "%s/%s", SCHEMA_PATH, "HeartBeatRequestRecordAvro.avsc"); init_schema(filename, &schema); iface = avro_generic_class_from_schema(schema); avro_generic_value_new(iface, &record); reader = avro_reader_memory(slice->buffer, slice->len); if (avro_value_read(reader, &record)) { fprintf(stderr, "Unable to read record from memory buffer\n"); fprintf(stderr, "Error: %s\n", avro_strerror()); exit(1); } avro_value_get_size(&record, &size); avro_value_iface_decref(iface); avro_schema_decref(schema); // printf("slice->len = %d\n", slice->len); // printf("size = %ld\n", size); // // if (size > 0) { // return 0; // } else { // return -1; // } if (size == 0) { return 0; } else { return -1; } }
int osux_beatmap_db_init( osux_beatmap_db *db, char const *file_path, char const *song_dir, bool populate) { int err; memset(db, 0, sizeof*db); if ((err = osux_database_init(&db->base, file_path)) < 0) return err; db->song_dir = g_strdup(song_dir); db->song_dir_length = strlen(song_dir); db->insert_prepared = false; if (populate || !beatmap_table_is_present(db)) { if ((err = init_schema(db)) < 0) return err; if (populate) { parse_beatmap_directory(db, song_dir); printf("parsed %lu beatmap%s.\n", db->parsed_beatmap_count, db->parsed_beatmap_count ? "s":""); } } return 0; }
RC PPSWorkload::init() { Workload::init(); char * cpath = getenv("SCHEMA_PATH"); string path; if (cpath == NULL) path = "./benchmarks/"; else { path = string(cpath); } path += "PPS_schema.txt"; cout << "reading schema file: " << path << endl; printf("Initializing schema... "); fflush(stdout); init_schema( path.c_str() ); printf("Done\n"); printf("Initializing table... "); fflush(stdout); init_table(); printf("Done\n"); fflush(stdout); return RCOK; }
RC tpcc_wl::init() { workload::init(); char * cpath = getenv("GRAPHITE_HOME"); string path; if (cpath == NULL) path = "./benchmarks/"; else { path = string(cpath); path += "/tests/apps/dbms/"; } #if TPCC_SMALL path += "TPCC_short_schema.txt"; #else path += "TPCC_full_schema.txt"; #endif cout << "reading schema file: " << path << endl; delivering = new bool * [g_num_wh + 1]; for (UInt32 wid = 1; wid <= g_num_wh; wid ++) delivering[wid] = (bool *) mem_allocator.alloc(CL_SIZE, wid); init_schema( path.c_str() ); init_table(); return RCOK; }
static void build_heartbeat_response(completed_proc_t *completed_proc_array, int array_size, avro_slice_t **slice) { char filename[FILE_NAME_LEN]; char buf[BUFFER_SIZE]; long len = 0; avro_schema_t schema; avro_value_iface_t *iface; avro_value_t record; avro_value_t completed_processes_value, ProcessStatus_value; avro_value_t name_value, ProcessName_value, jobid_value, vpid_value; avro_value_t state_value; avro_value_t exit_value_value; size_t index; int i; avro_writer_t writer; sprintf(filename, "%s/%s", SCHEMA_PATH, "HeartBeatResponseRecordAvro.avsc"); init_schema(filename, &schema); iface = avro_generic_class_from_schema(schema); avro_generic_value_new(iface, &record); avro_value_get_by_name(&record, "completed_processes", &completed_processes_value, &index); for (i = 0; i < array_size; i++) { avro_value_append(&completed_processes_value, &ProcessStatus_value, &index); avro_value_get_by_name(&ProcessStatus_value, "name", &name_value, &index); avro_value_get_by_name(&name_value, "jobid", &jobid_value, &index); avro_value_set_int(&jobid_value, completed_proc_array[i].proc_name.jobid); avro_value_get_by_name(&name_value, "vpid", &vpid_value, &index); avro_value_set_int(&vpid_value, completed_proc_array[i].proc_name.vpid); avro_value_get_by_name(&ProcessStatus_value, "state", &state_value, &index); avro_value_set_enum(&state_value, completed_proc_array[i].proc_state); avro_value_get_by_name(&ProcessStatus_value, "exit_value", &exit_value_value, &index); avro_value_set_int(&exit_value_value, completed_proc_array[i].exit_value); } /* create a writer with memory buffer */ writer = avro_writer_memory(buf, sizeof(buf)); /* write record to writer (buffer) */ if (avro_value_write(writer, &record)) { fprintf(stderr, "Unable to write record to memory buffer\n"); fprintf(stderr, "Error: %s\n", avro_strerror()); exit(1); } avro_writer_flush(writer); len = avro_writer_tell(writer); //avro_generic_value_free(&record); avro_value_iface_decref(iface); avro_schema_decref(schema); *slice = xmalloc(sizeof(avro_slice_t)); (*slice)->buffer = xmalloc(len); (*slice)->len = len; memcpy((*slice)->buffer, buf, len); }