void disassemble(struct code *stream) { struct instruction *ins = stream->stream; while (1) { printf(" %p %02x ", ins, ins->op); switch (ins->op) { case PUSH: printf("PUSH\t %p ", ins->arg); print_obj(ins->arg); printf("\n"); break; case POP: printf("POP\n"); break; case LOOKUP: printf("LOOKUP\t %p ", ins->arg); print_obj(ins->arg); printf("\n"); break; case CALL: printf("CALL\n"); break; case TAILCALL: printf("TAILCALL\n"); break; case RET: printf("RET\n"); return; break; case DEFINE: printf("DEFINE\t %p ", ins->arg); print_obj(ins->arg); printf("\n"); break; case SET: printf("SET\t %p ", ins->arg); print_obj(ins->arg); printf("\n"); break; case LAMBDA: printf("LAMBDA\t %p\n", ins->arg); break; case IF: printf("IF\n"); break; case TAILIF: printf("TAILIF\n"); break; default: printf("\nUnknown opcode: %d\n", ins->op); exit(1); } ++ins; } }
void ObTabletJoinTest::test_get_next_row(ObTabletJoin &tablet_join) { tablet_join.set_table_join_info(tablet_join_info_); ObFakeUpsMultiGet fake_ups_multi_get("tablet_join_test_data/fetch_ups_row_ups_row.ini"); ObFakeSSTableScan sstable("tablet_join_test_data/fetch_ups_row_fused_row.ini"); ObFakeUpsScan ups_scan("tablet_join_test_data/none_ups.ini"); ObTabletScanFuse tablet_fuse; OK(tablet_fuse.set_sstable_scan(&sstable)); OK(tablet_fuse.set_incremental_scan(&ups_scan)); tablet_join.set_child(0, tablet_fuse); tablet_join.set_batch_count(30000); tablet_join.set_ups_multi_get(&fake_ups_multi_get); tablet_join.add_column_id(1); tablet_join.add_column_id(4); tablet_join.add_column_id(5); tablet_join.add_column_id(6); const ObRow *row = NULL; const ObRow *result_row = NULL; const ObObj *cell = NULL; const ObObj *result_cell = NULL; uint64_t table_id = OB_INVALID_ID; uint64_t column_id = OB_INVALID_ID; ObFileTable result("tablet_join_test_data/fetch_ups_row_result.ini"); OK(result.open()); OK(tablet_join.open()); for(int i=0;i<7;i++) { OK(tablet_join.get_next_row(row)) << "row:" << i << std::endl; OK(result.get_next_row(result_row)); for(int j=1;j<4;j++) { OK(row->raw_get_cell(j, cell, table_id, column_id)); OK(result_row->raw_get_cell(j, result_cell, table_id, column_id)); bool eq = (*cell) == (*result_cell); if(!eq) { TBSYS_LOG(WARN, "================row idx[%d] column idx[%d]", i, j); TBSYS_LOG(WARN, "cell:%s", print_obj(*cell)); TBSYS_LOG(WARN, "result_cell:%s", print_obj(*result_cell)); } ASSERT_TRUE(eq); } } OK(result.close()); OK(tablet_join.close()); }
/* Allocates memory */ void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) { data_root<object> arg1(arg1_, this); data_root<object> arg2(arg2_, this); faulting_p = true; /* If we had an underflow or overflow, data or retain stack pointers might be out of bounds, so fix them before allocating anything */ ctx->fix_stacks(); /* If error was thrown during heap scan, we re-enable the GC */ gc_off = false; /* If the error handler is set, we rewind any C stack frames and pass the error to user-space. */ if (!current_gc && to_boolean(special_objects[ERROR_HANDLER_QUOT])) { #ifdef FACTOR_DEBUG /* Doing a GC here triggers all kinds of funny errors */ primitive_compact_gc(); #endif /* Now its safe to allocate and GC */ cell error_object = allot_array_4(tag_fixnum(KERNEL_ERROR), tag_fixnum(error), arg1.value(), arg2.value()); ctx->push(error_object); /* Clear the data roots since arg1 and arg2's destructors won't be called. */ data_roots.clear(); /* The unwind-native-frames subprimitive will clear faulting_p if it was successfully reached. */ unwind_native_frames(special_objects[ERROR_HANDLER_QUOT], ctx->callstack_top); } /* Error was thrown in early startup before error handler is set, so just crash. */ else { std::cout << "You have triggered a bug in Factor. Please report.\n"; std::cout << "error: " << error << std::endl; std::cout << "arg 1: "; print_obj(std::cout, arg1.value()); std::cout << std::endl; std::cout << "arg 2: "; print_obj(std::cout, arg2.value()); std::cout << std::endl; factorbug(); abort(); } }
const char *print_cellinfo(const ObCellInfo *ci, const char *ext_info/* = NULL*/) { static const int64_t BUFFER_SIZE = 128 * 1024; static __thread char buffers[2][BUFFER_SIZE]; static __thread int64_t i = 0; char *buffer = buffers[i++ % 2]; buffer[0] = '\0'; if (NULL != ci) { int32_t rowkey_len = 0; const char *rowkey_str = NULL; if (NULL != ci->row_key_.ptr() && 0 != ci->row_key_.length() && !str_isprint(ci->row_key_.ptr(), ci->row_key_.length())) { char hex_buffer[BUFFER_SIZE] = "0x "; common::hex_to_str(ci->row_key_.ptr(), ci->row_key_.length(), hex_buffer + strlen(hex_buffer), static_cast<int32_t>(BUFFER_SIZE - strlen(hex_buffer))); rowkey_str = hex_buffer; rowkey_len = static_cast<int32_t>(strlen(hex_buffer)); } else { rowkey_str = ci->row_key_.ptr(); rowkey_len = ci->row_key_.length(); } if (NULL == ext_info) { snprintf(buffer, BUFFER_SIZE, "table_id=%lu table_name=[%.*s] table_name_ptr=%p table_name_length=%d " "row_key=[%.*s] row_key_ptr=%p row_key_length=%d " "column_id=%lu column_name=[%.*s] column_name_ptr=%p column_name_length=%d " "%s", ci->table_id_, ci->table_name_.length(), ci->table_name_.ptr(), ci->table_name_.ptr(), ci->table_name_.length(), rowkey_len, rowkey_str, ci->row_key_.ptr(), ci->row_key_.length(), ci->column_id_, ci->column_name_.length(), ci->column_name_.ptr(), ci->column_name_.ptr(), ci->column_name_.length(), print_obj(ci->value_)); } else { snprintf(buffer, BUFFER_SIZE, "%s table_id=%lu table_name=[%.*s] table_name_ptr=%p table_name_length=%d " "row_key=[%.*s] row_key_ptr=%p row_key_length=%d " "column_id=%lu column_name=[%.*s] column_name_ptr=%p column_name_length=%d " "%s", ext_info, ci->table_id_, ci->table_name_.length(), ci->table_name_.ptr(), ci->table_name_.ptr(), ci->table_name_.length(), rowkey_len, rowkey_str, ci->row_key_.ptr(), ci->row_key_.length(), ci->column_id_, ci->column_name_.length(), ci->column_name_.ptr(), ci->column_name_.ptr(), ci->column_name_.length(), print_obj(ci->value_)); } } return buffer; }
void print_stack(state_t *st) { obj_t **p; for (p = st->tos-1; p >= st->stack; p--) { fprintf(stderr, " %3ld: ", st->tos-p-1); print_obj(stderr, *p); } }
void load_obj(t_object *obj, char *filename) { int fd; char *line; ft_exit((fd = open(filename, O_RDONLY)) < 0, "Can't read file"); obj->vertex_buffer_size = obj->index_buffer_size = obj->normal_buffer_size = obj->tex_buffer_size = 0; while (get_next_line(fd, &line) > 0) { if (ft_strlen(line) < 3 || line[0] == '#') ; else if (line[0] == 'o') ft_strcpy((char *)obj->name, line + 2); else if (line[0] == 'v' && line[1] == ' ') load_vertex(obj, line + 1); else if (line[0] == 'v' && line[1] == 'n') load_normal(obj, line + 2); else if (line[0] == 'v' && line[1] == 't') load_tex(obj, line + 2); else if (line[0] == 'f' && line[1] == ' ') load_index(obj, line + 1); ft_memdel((void **)&line); } close(fd); print_obj(obj); }
void print_layer(int n) /* show contents of a single layer (maybe a draft layer) */ { obj *p; for (p = objhead->o_next; p!= objtail; p = p->o_next) p = print_obj(n, p); }
void print_buf(void) { int n; obj *p; if (++objcount > objbuf) { p = objhead->o_next; if (p->o_type != BLOCK) print_obj(p->o_layer, p); else if (p->o_val[N_VAL].o == (obj *)0) return; else for (n = draftlayer; n <= top_layer; n++) print_obj(n,p); freenode(p); } }
int main(void) { char* cmd = "(* 2 3 5 7 (+ 1 (* 3 5 2 3 5)))"; //"(* 3 5)"; //"(define (square x) (* x x))"; char** toks = lex(cmd); /* int i = 0; char* tok; while ((tok = toks[i++])) { printf("%s\n", tok); } */ obj* syn = read_toks(toks); print_obj(syn); obj* result = eval(syn); print_obj(result); //desymbolize_tree(syn); //print_tree(syn); }
void print_vars(obj_t *vars[], int global) { char startc = global ? 'A' : 'a'; int i; for (i = 0; i < 26; i++) { if (vars[i] != NULL && vars[i]->type == number) { fprintf(stderr, " %c = ", startc + i); print_obj(stderr, vars[i]); } } }
unsigned int simplex(const int m, const int n, lp_t * p) { // init DFE max_file_t * maxfile = Simplex_init(); max_engine_t * engine = max_load(maxfile, "*"); // align for streaming int align_m, align_n; lp_t * align_p = copy_aligned(m, n, p, &align_m, &align_n); if (trace > 0) printf("aligned: %dx%d -> %dx%d\n", m, n, align_m, align_n); // reserve buffers lp_t * pivcol = (lp_t *) malloc(align_m * sizeof(lp_t)); lp_t * pivrow = (lp_t *) malloc(align_n * sizeof(lp_t)); // Simplex action to call DFE Simplex_actions_t act; act.param_m = align_m; act.param_n = align_n; act.instream_pivcol = pivcol; act.instream_pivrow = pivrow; act.instream_x = align_p; act.outstream_y = align_p; // main loop unsigned int count = 0; while (count < max_iterations || max_iterations == 0) { // column int col = pivot_rule == 0 ? find_pivot_column_first(align_n, align_p) : find_pivot_column_max(align_n, align_p); if (col < 0) break; // optimum found // row int row = find_pivot_row(align_m, align_n, align_p, col); if (row < 0) { align_p[0] = NAN; break; } // unbounded // pivoting count++; lp_t pivot = align_p[row * align_n + col]; if (trace > 0) printf("%d: pivoting on %d, %d: %"lp_t_fmt1"\n", count, row, col, pivot); // store pivcol & pivrow for DFE streaming for (int i = 0; i < align_m; i++) pivcol[i] = align_p[i * align_n + col]; for (int j = 0; j < align_n; j++) pivrow[j] = align_p[row * align_n + j]; // call DFE for pivoting act.param_row = row; act.param_col = col; act.param_pivot = 1 / pivot; Simplex_run(engine, &act); // tracing if (trace >= 9) write_bg(stdout, m, n, p); if (trace >= 2) print_obj(n, p); if (trace >= 3) print_bounds(m, n, p); } // unload DFE max_unload(engine); // free buffers free(pivcol); free(pivrow); p[0] = align_p[0]; return count; }
void delete_obj(void *obj){ if(obj==NULL) return; object* o=(object*)obj; printf("delete obj="); print_obj(o); println(); if(o->type==CONS){ del_objs(o->obj,2); }else if(o->type==PROC){ del_objs(o->obj,3); }else{ // del_objs(o->obj,1); } del_obj(o); }
void throw_error(cell error, stack_frame *callstack_top) { /* If the error handler is set, we rewind any C stack frames and pass the error to user-space. */ if(userenv[BREAK_ENV] != F) { /* If error was thrown during heap scan, we re-enable the GC */ gc_off = false; /* Reset local roots */ gc_locals = gc_locals_region->start - sizeof(cell); gc_bignums = gc_bignums_region->start - sizeof(cell); /* If we had an underflow or overflow, stack pointers might be out of bounds */ fix_stacks(); dpush(error); /* Errors thrown from C code pass NULL for this parameter. Errors thrown from Factor code, or signal handlers, pass the actual stack pointer at the time, since the saved pointer is not necessarily up to date at that point. */ if(callstack_top) { callstack_top = fix_callstack_top(callstack_top, stack_chain->callstack_bottom); } else callstack_top = stack_chain->callstack_top; throw_impl(userenv[BREAK_ENV],callstack_top); } /* Error was thrown in early startup before error handler is set, just crash. */ else { print_string("You have triggered a bug in Factor. Please report.\n"); print_string("early_error: "); print_obj(error); nl(); factorbug(); } }
void factor_vm::throw_error(cell error, stack_frame *callstack_top) { /* If the error handler is set, we rewind any C stack frames and pass the error to user-space. */ if(!current_gc && to_boolean(special_objects[OBJ_BREAK])) { /* If error was thrown during heap scan, we re-enable the GC */ gc_off = false; /* Reset local roots */ data_roots.clear(); bignum_roots.clear(); code_roots.clear(); /* If we had an underflow or overflow, stack pointers might be out of bounds */ fix_stacks(); dpush(error); /* Errors thrown from C code pass NULL for this parameter. Errors thrown from Factor code, or signal handlers, pass the actual stack pointer at the time, since the saved pointer is not necessarily up to date at that point. */ if(callstack_top) callstack_top = fix_callstack_top(callstack_top,ctx->callstack_bottom); else callstack_top = ctx->callstack_top; throw_impl(special_objects[OBJ_BREAK],callstack_top,this); } /* Error was thrown in early startup before error handler is set, just crash. */ else { std::cout << "You have triggered a bug in Factor. Please report.\n"; std::cout << "early_error: "; print_obj(error); std::cout << std::endl; factorbug(); } }
void print_layer_bnd(int n, obj *p, obj *q) /* show objects in layer n from p to q */ { obj *r; float x0, y0, x1, y1; if (p->o_x < q->o_x) { x0 = p->o_x; x1 = q->o_x; } else { x0 = q->o_x; x1 = p->o_x; } if (p->o_y < q->o_y) { y0 = p->o_y; y1 = q->o_y; } else { y0 = q->o_y; y1 = p->o_y; } for (r = objhead->o_next; r!= objtail; r = r->o_next) if (r->o_x >= x0 && r->o_x <= x1 && r->o_y >= y0 && r->o_y <= y1) r = print_obj(n, r); }
void a(){ std::vector< char > a; std::vector< char > result; result.push_back('A'); result.push_back('B'); result.push_back('C'); a.push_back('A'); a.push_back('B'); a.push_back('C'); a.push_back('D'); a.push_back('E'); int cnt = 0; do{ std::cout<<"oto "<<++cnt<<" kombinacja: "<<std::endl; print_obj(result.begin(), result.end()); } while( next_combination(a.begin(), a.end(), result.begin(), result.end()) ); }
int main(){ a(); return 0; std::vector<int> a; std::vector<int> result; result.push_back(0); result.push_back(1); result.push_back(2); for(int i=0;i<N;i++) a.push_back(i); int cnt = 0; do{ std::cout<<"oto "<<++cnt<<" kombinacja: "<<std::endl; print_obj(result.begin(), result.end()); } while( next_combination(a.begin(), a.end(), result.begin(), result.end()) ); return 0; }
void QueryEngine::dump2text(const char *fname) { const int64_t BUFFER_SIZE = 1024; char buffer[BUFFER_SIZE]; snprintf(buffer, BUFFER_SIZE, "%s.btree.main", fname); FILE *fd = fopen(buffer, "w"); if (NULL != fd) { keybtree_t::TScanHandle handle; TEKey btree_min_key; TEKey btree_max_key; if (ERROR_CODE_OK == keybtree_.get_scan_handle(handle) && ERROR_CODE_OK == keybtree_.get_min_key(btree_min_key) && ERROR_CODE_OK == keybtree_.get_max_key(btree_max_key)) { keybtree_.set_key_range(handle, btree_min_key, 0, btree_max_key, 0); TEKey key; TEValue *value = NULL; MemTableGetIter get_iter; int64_t num = 0; while (ERROR_CODE_OK == keybtree_.get_next(handle, key, value) && NULL != value) { fprintf(fd, "[ROW_INFO][%ld] btree_key=[%s] btree_value=[%s] ptr=%p\n", num, key.log_str(), value->log_str(), value); int64_t pos = 0; ObCellInfo *ci = NULL; get_iter.set_(key, value, NULL, true, NULL); while (OB_SUCCESS == get_iter.next_cell() && OB_SUCCESS == get_iter.get_cell(&ci)) { fprintf(fd, " [CELL_INFO][%ld][%ld] column_id=%lu value=[%s]\n", num, pos++, ci->column_id_, print_obj(ci->value_)); } ++num; } } fclose(fd); } }
VCSI_OBJECT error(VCSI_CONTEXT vc, char* text, VCSI_OBJECT obj) { #ifdef DEBUG printf("Error: %s - %s\n",text,print_obj(vc,vc->tmpstr,obj,1)); #endif #ifdef WITH_THREADS pthread_mutex_lock(vc->error_mutex); #endif vc->errobj->type = SYMBOL; VCELL(vc->errobj) = cons(vc,make_string(vc,text),cons(vc,obj,NULL)); vc->got_error = 1; #ifdef WITH_THREADS pthread_mutex_unlock(vc->error_mutex); #endif siglongjmp(DYNERR(vc->root_wind),1); return vc->errobj; }
int event_mlx(int keycode, t_env *e) { static int etat; if (!etat) etat = 0; another_keycode(keycode, e); move_cam(e, keycode); if (keycode == 49) { if (etat == 3) etat = 0; else etat++; ft_putstr("Etat Numero : "); ft_putnbr(etat); print_obj(etat); } movable(keycode, e, etat); ray_tracer(e); return (1); }
static void do_obj_list(void) { int rc; DBC *cur = NULL; DBT key, val; unsigned long count = 0; memset(&key, 0, sizeof(key)); memset(&val, 0, sizeof(val)); val.flags = DB_DBT_MALLOC; rc = tdb.objs->cursor(tdb.objs, NULL, &cur, 0); if (rc) { tdb.objs->err(tdb.objs, rc, "cursor create"); exit(1); } printf("bucket\towner\tmd5\tsize|addr\tn_str\n"); while (1) { struct db_obj_ent *obj; rc = cur->get(cur, &key, &val, DB_NEXT); if (rc) break; obj = val.data; print_obj(obj); count++; free(obj); } fprintf(stderr, "%lu records\n", count); cur->close(cur); }
static gfarm_error_t post_read_list(void *op_arg, gfarm_uint64_t seqnum, enum journal_operation ope, void *obj, void *closure, size_t length, int *needs_freep) { gfarm_error_t e = GFARM_ERR_NO_ERROR; off_t pos, t; gfarm_uint64_t lap; post_read_aggregate(NULL, seqnum, ope, obj, NULL, length, needs_freep); /* seqnum operation length */ printf("%12" GFARM_PRId64 " %-22s %7lu ", seqnum, journal_operation_name(ope), (unsigned long)length); if (opt_verbose) { /* offset */ journal_file_reader_committed_pos_unlocked(reader, &pos, &lap); t = journal_file_tail(jf); printf("%10" GFARM_PRId64 " ", (gfarm_off_t)((pos + t) % t)); } print_obj(ope, obj); printf("\n"); return (e); }
int ObRowCompaction::add_cell_(const ObCellInfo *cell_info, int64_t &row_ext_flag) { int ret = OB_SUCCESS; if (NULL == cell_info) { TBSYS_LOG(WARN, "invalid param cell_info=%p", cell_info); ret = OB_INVALID_ARGUMENT; } else if (OB_INVALID_ID == cell_info->column_id_ && ObExtendType == cell_info->value_.get_type()) { if (ObActionFlag::OP_DEL_ROW == cell_info->value_.get_ext()) { row_ext_flag = DEL_ROW_FLAG; list_ = NULL; tail_ = NULL; cur_version_ += 1; } else if (ObActionFlag::OP_ROW_DOES_NOT_EXIST == cell_info->value_.get_ext()) { row_ext_flag |= ROW_DOES_NOT_EXIST_FLAG; } else if (ObActionFlag::OP_NOP == cell_info->value_.get_ext()) { row_ext_flag |= NOP_FLAG; } else { TBSYS_LOG(ERROR, "invalid extend value=%ld", cell_info->value_.get_ext()); ret = OB_ERROR; } } else if (NODES_NUM_ <= cell_info->column_id_) { TBSYS_LOG(ERROR, "invalid column_id=%ld type=%d", cell_info->column_id_, cell_info->value_.get_type()); ret = OB_INVALID_ARGUMENT; } else { ObjNode *node = nodes_ + cell_info->column_id_; if (cur_version_ == node->version) { ret = node->value.apply(cell_info->value_); if (OB_SUCCESS != ret) { TBSYS_LOG(WARN, "apply fail dest=[%s] src=[%s] column_id=%lu", print_obj(node->value), print_obj(cell_info->value_), cell_info->column_id_); } } else { node->version = cur_version_; node->column_id = cell_info->column_id_; node->value = cell_info->value_; node->next = NULL; if (NULL == list_) { list_ = node; } else { tail_->next = node; } // 使用tail指针 为了保证数据有序 tail_ = node; } } return ret; }
/* The actual interpreter loop */ void interp(state_t *st) { while (1) { obj_t *x, *y, *z; char *p, c; int i; unsigned long u; /* fprintf(stderr, "Executing '%c'\n", *st->pc); */ switch (c = *st->pc++) { case '\0': return; case '\r': case '\n': case '\t': case ' ': /* nop */ break; case '!': /* call */ POP(x); if (x->type != function) { error("Not a function.\n"); } else { CALL(x); decref(x); } break; case '"': /* output string */ p = skip_string(st->pc); c = *p; /* Save old character */ *p = '\0'; /* Change it to NUL */ fputs(st->pc, stdout); /* Print the string */ *p = c; /* Replace original character */ st->pc = p + 1; /* Set the PC to one past the closing quote*/ break; case '#': /* over */ POP(y); POP(x); PUS(x); PUS(y); PUSH(x); break; case '$': /* dup */ POP(x); PUS(x); PUSH(x); break; case '%': /* mod */ BINOP(mpz_mod); break; case '&': /* && */ BINBOOL(NONZERO(x) && NONZERO(y)); break; case '\'': /* Set multi */ for (p = st->pc; *p && *p != '\''; p++); st->pc = p + 1; for (p--; *p != '\''; p--) { if (*p >= 'a' && *p <= 'z') { /* local */ POP(x); i = *p - 'a'; if ((y = st->frame->vars[i]) != NULL) decref(y); st->frame->vars[i] = x; } else if (*p >= 'A' && *p <= 'Z') { /* global */ POP(x); i = *p - 'A'; if ((y = st->vars[i]) != NULL) decref(y); st->vars[i] = x; } else if (*p != '\n' && *p != '\t' && *p != ' ') { error("Not a variable: '%c'", *p); } } break; case '(': /* Comment; can't be nested */ st->pc = skip_comment(st->pc); break; case '*': /* mul */ BINOP(mpz_mul); break; case '+': /* add */ BINOP(mpz_add); break; case ',': /* print character */ POP(x); u = to_ulong(x); putchar(u); decref(x); break; case '-': /* sub */ BINOP(mpz_sub); break; case '.': /* print */ POP(x); print_obj(stdout, x); decref(x); break; case '/': /* div */ BINOP(mpz_fdiv_q); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': p = st->pc; /* Skip to the first non-digit */ while ((c = *p) >= '0' && c <= '9') p++; *p = '\0'; /* Temporarily put a NUL there */ PUS(num_new_from_str(st->pc-1)); *p = c; /* Replace original character */ st->pc = p; break; case ':': /* Set variable */ POP(x); c = *st->pc++; if (c >= 'A' && c <= 'Z') { /* global */ i = c - 'A'; if ((y = st->vars[i]) != NULL) decref(y); st->vars[i] = x; } else if (c >= 'a' && c <= 'z') { /* local */ i = c - 'a'; if ((y = st->frame->vars[i]) != NULL) decref(y); st->frame->vars[i] = x; } else { error("Not a variable: '%c'\n", *st->pc); } break; /* case ';': */ /* break; */ case '<': /* less than */ BINBOOL(mpz_cmp(*to_mpz(x), *to_mpz(y)) < 0); break; case '=': /* equal to */ BINBOOL(mpz_cmp(*to_mpz(x), *to_mpz(y)) == 0); break; case '>': /* greater than */ BINBOOL(mpz_cmp(*to_mpz(x), *to_mpz(y)) > 0); break; case '?': /* if */ POP(z); POP(y); POP(x); if (x->type != number || y->type != function || z->type != function) error("Wrong argument type."); CALL(NONZERO(x) ? y : z); decref(z); decref(y); decref(x); break; case '@': /* rot */ POP(z); POP(y); POP(x); PUS(y); PUS(z); PUS(x); break; /* global variables */ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': /* global variables */ i = c - 'A'; if ((x = st->vars[i]) == NULL) { error("Uninitialized variable '%c'\n", c); } if (x->type == function) { CALL(x); } else { PUSH(x); } break; case '[': PUS(fun_new(st->pc)); i = 1; while (*st->pc) { switch (*st->pc++) { case '"': st->pc = skip_string(st->pc) + 1; break; case '(': st->pc = skip_comment(st->pc) + 1; break; case '[': i++; break; case ']': if (--i <= 0) goto done; break; } } done: break; case '\\': /* swap */ POP(y); POP(x); PUS(y); PUS(x); break; case ']': POPRET(); break; case '^': /* trace */ print_trace(st); break; /* case '^': /\* pow *\/ */ /* POP(y); POP(x); */ /* z = num_new(); */ /* mpz_pow_ui(z->data.mpz, *to_mpz(x), to_ulong(y)); */ /* PUSH(z); */ /* decref(y); decref(x); */ /* break; *\/ */ case '_': /* neg */ POP(x); mpz_neg(*to_mpz(x), x->data.mpz); PUS(x); break; case '`': /* drop */ POP(x); decref(x); break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* local variables */ i = c - 'a'; if ((x = st->frame->vars[i]) == NULL) { error("Uninitialized variable '%c'\n", c); } if (x->type == function) { CALL(x); } else { PUSH(x); } break; /* case '{': */ /* break; */ case '|': /* or */ BINBOOL(NONZERO(x) || NONZERO(y)); break; /* case '}': */ /* break; */ case '~': /* not */ POP(x); PUSH(ZERO(x) ? one : zero); decref(x); break; default: error("Undefined token '%c'\n", c); } } }
void ObTabletJoinTest::test_big_data(ObTabletJoin &tablet_join) { system("python gen_test_data.py join"); ObTabletJoin::TableJoinInfo tablet_join_info; tablet_join_info.left_table_id_ = LEFT_TABLE_ID; tablet_join_info.right_table_id_ = RIGHT_TABLE_ID; ObTabletJoin::JoinInfo join_info; OK(tablet_join_info.join_condition_.push_back(1)); OK(read_join_info(tablet_join_info, "tablet_join_test_data/join_info.ini")); tablet_join.set_table_join_info(tablet_join_info); ObFakeUpsMultiGet fake_ups_multi_get("tablet_join_test_data/big_ups_scan2.ini"); ObFileTable result("tablet_join_test_data/big_result2.ini"); ObFakeSSTableScan sstable("tablet_join_test_data/big_sstable2.ini"); ObFakeUpsScan ups_scan("tablet_join_test_data/none_ups.ini"); ObTabletScanFuse tablet_fuse; OK(tablet_fuse.set_sstable_scan(&sstable)); OK(tablet_fuse.set_incremental_scan(&ups_scan)); tablet_join.set_child(0, tablet_fuse); tablet_join.set_batch_count(30000); tablet_join.set_ups_multi_get(&fake_ups_multi_get); OK(sstable.open()); OK(sstable.close()); uint64_t table_id = OB_INVALID_ID; uint64_t column_id = OB_INVALID_ID; const ObRowDesc *row_desc = NULL; sstable.get_row_desc(row_desc); for(int64_t i=0;i<row_desc->get_column_num();i++) { row_desc->get_tid_cid(i, table_id, column_id); tablet_join.add_column_id(column_id); } ObGetParam get_param(true); const ObRow *row = NULL; const ObRow *result_row = NULL; const ObObj *value = NULL; const ObObj *result_value = NULL; OK(result.open()); OK(tablet_join.open()); int err = OB_SUCCESS; int64_t count = 0; while(OB_SUCCESS == (err = tablet_join.get_next_row(row))) { OK(result.get_next_row(result_row)); count ++; for(int64_t i=0;i<row->get_column_num();i++) { OK(row->raw_get_cell(i, value, table_id, column_id)); OK(result_row->get_cell(table_id, column_id, result_value)); if( *value != *result_value ) { printf("row:[%ld], column[%ld]===========\n", count, i); ObString rowkey; get_rowkey(*row, rowkey); printf("row rowkey: %.*s\n", rowkey.length(), rowkey.ptr()); printf("row: %s\n", print_obj(*value)); get_rowkey(*result_row, rowkey); printf("result rowkey: %.*s\n", rowkey.length(), rowkey.ptr()); printf("result: %s\n", print_obj(*result_value)); } ASSERT_TRUE((*value) == (*result_value)); } } ASSERT_TRUE(OB_SUCCESS == err || OB_ITER_END == err); OK(result.close()); OK(tablet_join.close()); }
obj * print_obj(int layer, obj *p) { double r, ox, oy, x0, y0, x1, y1; obj *op, *q; int n; op = p; #if 0 /* 4/23/91 -- trying to understand BoundingBox problems */ if (redo_gbox) { float bnd[4]; Gbox[2] = Gbox[3] = -(Gbox[0] = Gbox[1] = 32767); for (q = objhead->o_next; q != objtail; q = q->o_next) { if (q->o_type > TEXT) continue; get_tot_bounds(q, bnd, 1); /* get_bounds(q, bnd, 1); */ track_bounds (bnd[0], bnd[1], bnd[2], bnd[3]); if (q->o_type == BLOCK) q = q->o_val[N_VAL].o; } redo_gbox = 0; } #endif openpl(""); if (p->o_type != BLOCK && p->o_layer != layer) return p; if (p->o_type <= TEXT && (p->o_mxx!=1 || p->o_myy!=1 || p->o_mxy!=0 || p->o_myx!=0 || p->o_mxt!=0 || p->o_myt!=0)) return print_xform(layer,p); ox = p->o_x; oy = p->o_y; if (p->o_type < TEXT && (p->o_attr & (FILLED | EDGED))) chk_attrs (p); switch (p->o_type) { case TROFF: n = p->o_nt1; if (text[n].t_type & EQNTXT) puteqn(ox, oy, text[n].t_type, atoi(text[n].t_val)); else troff(text[n].t_val); return p; case BLOCK: for (q = p->o_next; q != p->o_val[N_VAL].o; q = q->o_next) if (q->o_type <= TEXT || q->o_nt2 > q->o_nt1) q = print_obj(layer,q); p = q; break; case PSFILE: puteps(p); /* CAREFUL!! THIS FLOWS THROUGH INTO BOX!! */ case BOX: if (p->o_attr & (FILLED|EDGED)) { x0 = ox - p->o_wid/2; x1 = ox + p->o_wid/2; y0 = oy - p->o_ht/2; y1 = oy + p->o_ht/2; r = p->o_val[N_VAL].f; box(x0, y0, x1, y1, r); } break; case CIRCLE: case ELLIPSE: if (p->o_attr & (FILLED|EDGED)) ellipse(ox,oy,p->o_wid/2,0.,0.,p->o_ht/2,0.,2*M_PI,0); break; case SECTOR: case ARC: if (p->o_attr & (FILLED|EDGED)) { register double ang1, ang2; if (p->o_attr & HEAD12) { print_xform(layer, p); break; } r = p->o_val[N_VAL+0].f; x0 = p->o_val[N_VAL+2].f; /* starting point */ y0 = p->o_val[N_VAL+3].f; x1 = p->o_val[N_VAL+4].f; /* ending point */ y1 = p->o_val[N_VAL+5].f; ang1 = atan2(y0-oy, x0-ox); ang2 = atan2(y1-oy, x1-ox); ellipse(ox, oy, r, 0., 0., r, ang1, ang2, p->o_type); } break; case LINE: case ARROW: case SPLINE: if (p->o_attr & (FILLED|EDGED)) { int c, nxy; if (p->o_attr & HEAD12) { print_xform(layer, p); break; } r = p->o_val[N_VAL+0].f; nxy = p->o_val[N_VAL+3].f; /* segment count */ x0 = p->o_val[N_VAL+4].f; /* first point */ y0 = p->o_val[N_VAL+5].f; x1 = p->o_val[N_VAL+4+2*nxy].f; /* last point */ y1 = p->o_val[N_VAL+5+2*nxy].f; c = (x0 == x1 && y0 == y1); /* flags closure */ if (nxy == 1) line(x0, y0, x1, y1); else if (p->o_type == SPLINE) spline(nxy, c, &p->o_val[N_VAL+4]); else pline (nxy, c, &p->o_val[N_VAL+4], r); } break; } if (op->o_nt1 < op->o_nt2) objtext(ox, oy, op); return p; }