//{{{ unsigned int count_intersections_i_bsearch_seq(struct interval *A, unsigned int count_intersections_i_bsearch_seq(struct interval *A, unsigned int size_A, struct interval *B, unsigned int size_B, unsigned int size_I) { unsigned int i, O = 0; unsigned int *B_starts = (unsigned int *) malloc(size_B * sizeof(unsigned int)); unsigned int *B_ends = (unsigned int *) malloc(size_B * sizeof(unsigned int)); for (i = 0; i < size_B; i++) { B_starts[i] = B[i].start; B_ends[i] = B[i].end; } qsort(B_starts, size_B, sizeof(unsigned int), compare_unsigned_int); qsort(B_ends, size_B, sizeof(unsigned int), compare_unsigned_int); unsigned int *I_starts = (unsigned int *) malloc(size_I * sizeof(unsigned int)); unsigned int *I_ends = (unsigned int *) malloc(size_I * sizeof(unsigned int)); create_index(B_starts, size_B, I_starts, size_I); create_index(B_ends, size_B, I_ends, size_I); for (i = 0; i < size_A; i++) { unsigned int num_cant_before = i_bsearch_seq(A[i].start, B_ends, size_B, I_ends, size_I); unsigned int b = i_bsearch_seq(A[i].end, B_starts, size_B, I_starts, size_I); while ( ( B_starts[b] == A[i].end) && b < size_B) ++b; unsigned int num_cant_after = size_B - b; unsigned int num_left = size_B - num_cant_before - num_cant_after; O += num_left; } free(B_starts); free(B_ends); return O; }
autoConfusion Confusion_condense (Confusion me, const char32 *search, const char32 *replace, long maximumNumberOfReplaces, int use_regexp) { try { long nmatches, nstringmatches; if (my rowLabels == 0 || my columnLabels == 0) { Melder_throw (U"No row or column labels."); } autostring32vector rowLabels (strs_replace (my rowLabels, 1, my numberOfRows, search, replace, maximumNumberOfReplaces, &nmatches, &nstringmatches, use_regexp), 1, my numberOfRows); autostring32vector columnLabels (strs_replace (my columnLabels, 1, my numberOfColumns, search, replace, maximumNumberOfReplaces, &nmatches, &nstringmatches, use_regexp), 1, my numberOfColumns); autoStrings srow = Thing_new (Strings); srow -> numberOfStrings = my numberOfRows; srow -> strings = rowLabels.transfer(); autoStrings scol = Thing_new (Strings); scol -> numberOfStrings = my numberOfColumns; scol -> strings = columnLabels.transfer(); /* Find dimension of new Confusion */ autoDistributions dcol = Strings_to_Distributions (scol.get()); long nresp = dcol -> numberOfRows; autoDistributions drow = Strings_to_Distributions (srow.get()); long nstim = drow -> numberOfRows; autoConfusion thee = Confusion_create (nstim, nresp); NUMstrings_copyElements (drow -> rowLabels, thy rowLabels, 1, nstim); NUMstrings_copyElements (dcol -> rowLabels, thy columnLabels, 1, nresp); autoNUMvector<long> rowIndex (1, my numberOfRows); create_index (srow -> strings, 1, my numberOfRows, drow -> rowLabels, 1, nstim, rowIndex.peek()); autoNUMvector<long> columnIndex (1, my numberOfColumns); create_index (scol -> strings, 1, my numberOfColumns, dcol -> rowLabels, 1, nresp, columnIndex.peek()); for (long i = 1; i <= my numberOfRows; i++) { for (long j = 1; j <= my numberOfColumns; j++) { thy data [rowIndex [i]][columnIndex[j]] += my data[i][j]; } } return thee; } catch (MelderError) { Melder_throw (me, U": not condensed."); } }
TEST_F(ClientMetadataTest, TestLocateIndicesForSearch) { start(2, 1); create_index("/foo/bar/test", "blue"); create_index("/foo/bar/test", "red"); create_index("/foo/bar/zoo", "blue"); ComplexQuery query; query.parse("/foo/bar?blue>100"); vector<string> expected_indices = { "/foo/bar/test/.vsfs/blue", "/foo/bar/zoo/.vsfs/blue" }; vector<string> actual_indices; EXPECT_TRUE(client_->locate_index_for_search(query, &actual_indices).ok()); EXPECT_THAT(actual_indices, ContainerEq(expected_indices)); }
TEST_F(ClientMetadataTest, TestSearchUTF8Indices) { start(2, 2); create_index("/foo/bar", "测试"); create_directories("/foo/bar/dog"); for (int i = 0; i < 100; i++) { ObjectId oid; client_->create("/foo/bar/dog/dog" + to_string(i), 0644, 100, 100, &oid); } vector<VSFSRpcClient::IndexUpdateRequest> requests; for (int i = 0; i < 100; i++) { requests.emplace_back(VSFSRpcClient::IndexUpdateRequest::INSERT, "/foo/bar/dog/dog" + to_string(i), "测试", to_string(i)); } LOG(INFO) << "Update request;"; EXPECT_TRUE(client_->update(requests).ok()); ComplexQuery query; EXPECT_TRUE(query.parse("/foo?测试>50").ok()); vector<string> actual_files; EXPECT_TRUE(client_->search(query, &actual_files).ok()); EXPECT_EQ(49u, actual_files.size()); }
TEST_F(ClientMetadataTest, TestSearchSuccess) { start(4, 4); create_index("/foo/bar", "dog"); create_directories("/foo/bar/zoo"); create_directories("/foo/bar/dogs"); create_directories("/foo/bar/cat"); for (int i = 0; i < 100; i++) { ObjectId oid; client_->create("/foo/bar/zoo/zoo" + to_string(i), 0644, 100, 100, &oid); client_->create("/foo/bar/dogs/dog" + to_string(i), 0644, 100, 100, &oid); client_->create("/foo/bar/cat/cat" + to_string(i), 0644, 100, 100, &oid); } vector<VSFSRpcClient::IndexUpdateRequest> requests; for (int i = 0; i < 100; i++) { requests.emplace_back(VSFSRpcClient::IndexUpdateRequest::INSERT, "/foo/bar/dogs/dog" + to_string(i), "dog", to_string(i)); } EXPECT_TRUE(client_->update(requests).ok()); vector<string> expected_files; for (int i = 51; i < 100; i++) { expected_files.push_back("/foo/bar/dogs/dog" + to_string(i)); } ComplexQuery query; query.parse("/foo?dog>50"); vector<string> actual_files; EXPECT_TRUE(client_->search(query, &actual_files).ok()); sort(actual_files.begin(), actual_files.end()); EXPECT_THAT(actual_files, ContainerEq(expected_files)); }
int main(int argc, char *argv[]) { struct adjlog tg; struct opts opts; int optind; TemporalGraphLog tgl; optind = readopts(argc, argv, &opts); INFO("Loading graph..."); //read_stdin(&tg); read_contacts(opts,&tg); INFO("Creating index..."); create_index(tgl, &tg, &opts); LOG("Size of index: %lu\n", tgl.getSize()); //LOG("Depth: %u", tgl.get_log()->getDepth()); ofstream file; LOG("Saving graph file in '%s'\n", opts.outfile); file.open(opts.outfile, ios::binary); tgl.save(file); file.close(); return 0; }
void test_checkout_conflict__link_file(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "link-1" }, { 0100644, CONFLICTING_OURS_OID, 2, "link-1" }, { 0120000, LINK_THEIRS_OID, 3, "link-1" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "link-2" }, { 0120000, LINK_OURS_OID, 2, "link-2" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "link-2" }, { 0120000, LINK_ANCESTOR_OID, 1, "link-3" }, { 0100644, CONFLICTING_OURS_OID, 2, "link-3" }, { 0120000, LINK_THEIRS_OID, 3, "link-3" }, { 0120000, LINK_ANCESTOR_OID, 1, "link-4" }, { 0120000, LINK_OURS_OID, 2, "link-4" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "link-4" }, }; opts.checkout_strategy |= GIT_CHECKOUT_SAFE; create_index(checkout_index_entries, 12); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); /* Typechange conflicts always keep the file in the workdir */ ensure_workdir_oid("link-1", CONFLICTING_OURS_OID); ensure_workdir_oid("link-2", CONFLICTING_THEIRS_OID); ensure_workdir_oid("link-3", CONFLICTING_OURS_OID); ensure_workdir_oid("link-4", CONFLICTING_THEIRS_OID); }
int index_main(SgrepData *sgrep,int argc, char *argv[]) { int end_options; IndexOptions options; FileList *file_list=NULL; set_default_index_options(sgrep,&options); /* * Get the command line options */ end_options=parse_index_options(&options,argv); if (end_options==SGREP_ERROR) { /* There was error. Display usage information */ index_usage(sgrep); goto error; } switch(options.index_mode) { case IM_CREATE: { if (argc==end_options && options.file_list_files==NULL) { sgrep_error(sgrep,"Can't read input from stdin when indexing.\n"); sgrep_error(sgrep," Use filename '-' to force indexing from stdin.\n"); goto error; } if (argc>end_options) { file_list=check_files(sgrep,argc-end_options,argv+end_options, 0,NULL); } options.file_list=file_list; if (create_index(&options)==SGREP_ERROR) { goto error; } break; } case IM_TERMS: { if (index_query(&options,argc-end_options,argv+end_options) ==SGREP_ERROR) { return 2; } else { return 0; } } case IM_DONE: return 0; case IM_NONE: default: sgrep_error(sgrep,"sgindex: You have to give one of -c, -C -h\n"); index_usage(sgrep); goto error; } if (file_list) delete_flist(file_list); if (options.file_list_files) delete_flist(options.file_list_files); return 0; error: if (file_list) delete_flist(file_list); if (options.file_list_files) delete_flist(options.file_list_files); return 2; }
int Indexer::start_index() { if(get_doc_set(m_crawledDir, m_docSet) < 0) { return -1; } return create_index(m_crawledDir, m_docSet, m_postingIndex); }
void test_checkout_conflict__mode_change(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "executable-1" }, { 0100755, CONFLICTING_ANCESTOR_OID, 2, "executable-1" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "executable-1" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "executable-2" }, { 0100644, CONFLICTING_OURS_OID, 2, "executable-2" }, { 0100755, CONFLICTING_ANCESTOR_OID, 3, "executable-2" }, { 0100755, CONFLICTING_ANCESTOR_OID, 1, "executable-3" }, { 0100644, CONFLICTING_ANCESTOR_OID, 2, "executable-3" }, { 0100755, CONFLICTING_THEIRS_OID, 3, "executable-3" }, { 0100755, CONFLICTING_ANCESTOR_OID, 1, "executable-4" }, { 0100755, CONFLICTING_OURS_OID, 2, "executable-4" }, { 0100644, CONFLICTING_ANCESTOR_OID, 3, "executable-4" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "executable-5" }, { 0100755, CONFLICTING_OURS_OID, 2, "executable-5" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "executable-5" }, { 0100755, CONFLICTING_ANCESTOR_OID, 1, "executable-6" }, { 0100644, CONFLICTING_OURS_OID, 2, "executable-6" }, { 0100755, CONFLICTING_THEIRS_OID, 3, "executable-6" }, }; opts.checkout_strategy |= GIT_CHECKOUT_SAFE; create_index(checkout_index_entries, 18); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); /* Keep the modified mode */ ensure_workdir_oid("executable-1", CONFLICTING_THEIRS_OID); ensure_workdir_mode("executable-1", 0100755); ensure_workdir_oid("executable-2", CONFLICTING_OURS_OID); ensure_workdir_mode("executable-2", 0100755); ensure_workdir_oid("executable-3", CONFLICTING_THEIRS_OID); ensure_workdir_mode("executable-3", 0100644); ensure_workdir_oid("executable-4", CONFLICTING_OURS_OID); ensure_workdir_mode("executable-4", 0100644); ensure_workdir_contents("executable-5", CONFLICTING_DIFF3_FILE); ensure_workdir_mode("executable-5", 0100755); ensure_workdir_contents("executable-6", CONFLICTING_DIFF3_FILE); ensure_workdir_mode("executable-6", 0100644); }
void indirect_intro_sort ( iter_t first, iter_t last , compare comp = compare() ) { //------------------------------- begin-------------------------- typedef less_ptr_no_null <iter_t, compare> compare_ptr ; std::vector<iter_t> VP ; create_index ( first , last , VP); intro_sort ( VP.begin() , VP.end(), compare_ptr(comp) ); sort_index ( first , VP) ; };
void indirect_sample_sort ( iter_t first, iter_t last, compare comp1, const NThread &NT = NThread() ) { //----------------------------- begin ---------------------------------- typedef less_ptr_no_null <iter_t, compare> compare_ptr ; std::vector<iter_t> VP ; create_index ( first , last , VP); sample_sort ( VP.begin() , VP.end(), compare_ptr(comp1),NT ); sort_index ( first , VP) ; };
static void create_conflicting_index(void) { struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "conflicting.txt" }, { 0100644, CONFLICTING_OURS_OID, 2, "conflicting.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting.txt" }, }; create_index(checkout_index_entries, 3); git_index_write(g_index); }
int TAO_Persistent_Context_Index::open (const ACE_TCHAR *file_name, void *base_address) { this->base_address_ = base_address; index_file_ = ACE_OS::strdup (file_name); if (index_file_ == 0) return -1; return create_index (); }
/********************************************************************* * * ss_m::create_index(vid, ntype, property, key_desc, stid) * ss_m::create_index(vid, ntype, property, key_desc, cc, stid) * *********************************************************************/ rc_t ss_m::create_index( vid_t vid, ndx_t ntype, store_property_t property, const char* key_desc, stid_t& stid ) { return create_index(vid, ntype, property, key_desc, t_cc_kvl, stid); }
TEST_F(ClientMetadataTest, TestIndexInfo) { start(2, 2); create_index("/foo/bar", "a"); create_index("/foo/bar", "b"); create_index("/foo/bar/zoo", "a"); create_index("/foo/bar/zoo", "b"); vector<IndexInfo> infos; EXPECT_TRUE(client_->get_index_infos("/foo/bar", &infos, true).ok()); EXPECT_EQ(4u, infos.size()); vector<string> actual_indices; for (const auto& info : infos) { actual_indices.emplace_back(PathUtil::index_path(info.path(), info.index_name())); EXPECT_EQ(IndexInfo::BTREE, info.index_type()); EXPECT_EQ(INT32, info.key_type()); } sort(begin(actual_indices), end(actual_indices)); EXPECT_THAT(actual_indices, ElementsAre( "/foo/bar/.vsfs/a", "/foo/bar/.vsfs/b", "/foo/bar/zoo/.vsfs/a", "/foo/bar/zoo/.vsfs/b")); }
void test_find_one() { // Create a table and insert rows. auto db = grnxx::open_db(""); auto table = db->create_table("Table"); table->insert_row(); table->insert_row(); table->insert_row(); auto column = table->create_column("Int", GRNXX_INT); assert(column->find_one(grnxx::Int(123)).is_na()); assert(column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(0), grnxx::Int(123)); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(1), grnxx::Int(456)); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(!column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(2), grnxx::Int(789)); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(!column->find_one(grnxx::Int(456)).is_na()); assert(!column->find_one(grnxx::Int(789)).is_na()); assert(column->find_one(grnxx::Int::na()).is_na()); column->create_index("Index", GRNXX_TREE_INDEX); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(!column->find_one(grnxx::Int(456)).is_na()); assert(!column->find_one(grnxx::Int(789)).is_na()); assert(column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(2), grnxx::Int::na()); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(!column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(1), grnxx::Int::na()); assert(!column->find_one(grnxx::Int(123)).is_na()); assert(column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); column->set(grnxx::Int(0), grnxx::Int::na()); assert(column->find_one(grnxx::Int(123)).is_na()); assert(column->find_one(grnxx::Int(456)).is_na()); assert(column->find_one(grnxx::Int(789)).is_na()); assert(!column->find_one(grnxx::Int::na()).is_na()); }
int main(int argc, void **argv) { char buffer[MAXLINE]; Word_t Bytes; FILE *fp = NULL; int result =0; int count = 0; int i,j; int start_len; if(argc < 2) { printf("provide file to search\n"); return; } char *file = argv[1]; // populate map and new sorted list create_index(file); fp = fopen(file, "r"); if (fp == NULL) { perror("no sorted list exist"); goto process_done; } // loop through the list from the longest word while(fgets(buffer, sizeof(buffer), fp) !=NULL) { remove_eol(buffer); start_len = strlen(buffer); while(1) { if (start_len < MIN_WORD_LEN*MIN_WORD_LEN) break; if (string_prime_div(buffer, start_len - 1)) { printf("%d.%s\n", count, buffer); count++; break; } else { start_len--; } } } printf("total %d of words found that composed of other word in the list\n", count); JSLFA(Bytes, PJArray); fclose(fp); process_done: return 0; }
void test_checkout_conflict__automerge(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "automergeable.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "automergeable.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "automergeable.txt" }, }; create_index(checkout_index_entries, 3); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); ensure_workdir_contents("automergeable.txt", AUTOMERGEABLE_MERGED_FILE); }
void test_checkout_conflict__report_progress(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; git_vector paths = GIT_VECTOR_INIT; char *path; size_t i; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "conflicting-1.txt" }, { 0100644, CONFLICTING_OURS_OID, 2, "conflicting-1.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting-1.txt" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "conflicting-2.txt" }, { 0100644, CONFLICTING_OURS_OID, 2, "conflicting-2.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting-2.txt" }, { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "conflicting-4.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "conflicting-4.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "conflicting-4.txt" }, }; opts.progress_cb = collect_progress; opts.progress_payload = &paths; create_index(checkout_index_entries, 12); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); cl_assert_equal_i(4, git_vector_length(&paths)); cl_assert_equal_s("conflicting-1.txt", git_vector_get(&paths, 0)); cl_assert_equal_s("conflicting-2.txt", git_vector_get(&paths, 1)); cl_assert_equal_s("conflicting-3.txt", git_vector_get(&paths, 2)); cl_assert_equal_s("conflicting-4.txt", git_vector_get(&paths, 3)); git_vector_foreach(&paths, i, path) git__free(path); git_vector_free(&paths); }
void test_checkout_conflict__update_only(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "automergeable.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "automergeable.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "automergeable.txt" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "modify-delete" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "modify-delete" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "directory_file-one" }, { 0100644, CONFLICTING_OURS_OID, 2, "directory_file-one" }, { 0100644, CONFLICTING_THEIRS_OID, 0, "directory_file-one/file" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "directory_file-two" }, { 0100644, CONFLICTING_OURS_OID, 0, "directory_file-two/file" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "directory_file-two" }, }; opts.checkout_strategy |= GIT_CHECKOUT_UPDATE_ONLY; create_index(checkout_index_entries, 3); git_index_write(g_index); cl_git_pass(p_mkdir("merge-resolve/directory_file-two", 0777)); cl_git_rewritefile("merge-resolve/directory_file-two/file", CONFLICTING_OURS_FILE); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); ensure_workdir_contents("automergeable.txt", AUTOMERGEABLE_MERGED_FILE); ensure_workdir("directory_file-two/file", 0100644, CONFLICTING_OURS_OID); cl_assert(!git_path_exists("merge-resolve/modify-delete")); cl_assert(!git_path_exists("merge-resolve/test-one.txt")); cl_assert(!git_path_exists("merge-resolve/test-one-side-one.txt")); cl_assert(!git_path_exists("merge-resolve/test-one-side-two.txt")); cl_assert(!git_path_exists("merge-resolve/test-one.txt~ours")); cl_assert(!git_path_exists("merge-resolve/test-one.txt~theirs")); cl_assert(!git_path_exists("merge-resolve/directory_file-one/file")); cl_assert(!git_path_exists("merge-resolve/directory_file-one~ours")); cl_assert(!git_path_exists("merge-resolve/directory_file-two~theirs")); }
void test_checkout_conflict__add_add(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_OURS_OID, 2, "conflicting.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting.txt" }, }; opts.checkout_strategy |= GIT_CHECKOUT_SAFE; create_index(checkout_index_entries, 2); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); /* Add/add writes diff3 files */ ensure_workdir_contents("conflicting.txt", CONFLICTING_DIFF3_FILE); }
int main(int argc, char ** argv){ image_t img; img.fname = malloc(strlen(argv[1])+1); memcpy(img.fname, argv[1], strlen(argv[1])+1); map_file(&img); address_list = malloc(MAX_ADDRESSES * sizeof(*address_list)); memset(address_list, NO_ADDRESS, MAX_ADDRESSES * sizeof(*address_list)); init_indexer(); add_address(&address_list, 0); scan_img_for_addresses(&img, &address_list); spread_addresses(&address_list, ADDRESS_SPREAD); LOG(LOG_INDEX, "creating index ...\n");fflush(stdout); create_index(&img); LOG(LOG_INDEX, "creating index done.\n");fflush(stdout); int as; /* start address */ int ae; /* end address */ /* O(n^2) */ for (as=0; address_list[as] != NO_ADDRESS; as++) { for (ae=0; address_list[ae] != NO_ADDRESS; ae++) { /* FIXME we could use another parameter than ADDRESS_SPREAD */ if (address_list[ae] > address_list[as] + ADDRESS_SPREAD) { LOG(LOG_ADDR, "checksumming 0x%8.8x to 0x%8.8x\n", address_list[as], address_list[ae]); do_checksum(address_list[as], address_list[ae], &img); } } } return 0; }
void test_checkout_conflict__directory_file_with_custom_labels(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "df-1" }, { 0100644, CONFLICTING_OURS_OID, 2, "df-1" }, { 0100644, CONFLICTING_THEIRS_OID, 0, "df-1/file" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "df-2" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "df-2" }, { 0100644, CONFLICTING_OURS_OID, 0, "df-2/file" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "df-3" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "df-3/file" }, { 0100644, CONFLICTING_OURS_OID, 2, "df-3/file" }, { 0100644, CONFLICTING_OURS_OID, 2, "df-4" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "df-4/file" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "df-4/file" }, }; opts.checkout_strategy |= GIT_CHECKOUT_SAFE; opts.our_label = "HEAD"; opts.their_label = "branch"; create_index(checkout_index_entries, 12); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); ensure_workdir_oid("df-1/file", CONFLICTING_THEIRS_OID); ensure_workdir_oid("df-1~HEAD", CONFLICTING_OURS_OID); ensure_workdir_oid("df-2/file", CONFLICTING_OURS_OID); ensure_workdir_oid("df-2~branch", CONFLICTING_THEIRS_OID); ensure_workdir_oid("df-3/file", CONFLICTING_OURS_OID); ensure_workdir_oid("df-3~branch", CONFLICTING_THEIRS_OID); ensure_workdir_oid("df-4~HEAD", CONFLICTING_OURS_OID); ensure_workdir_oid("df-4/file", CONFLICTING_THEIRS_OID); }
void check_out_impute(char **origin, char **destin, int *imputation_number, char **subset, char **filltabin){ char *filltab = (filltabin && *filltabin) ? *filltabin : "filled"; Tea_stopif(!origin || !*origin, return, 0, "NULL origin table, but I need that."); char *id_column= get_key_word(NULL, "id"); const char *dest = destin ? *destin : NULL; int use_rowids = 0; if (!id_column) { use_rowids++; id_column = strdup("rowid"); } sprintf(apop_opts.db_name_column, "%s", id_column); begin_transaction(); if (dest && strcmp(*origin, dest)){ apop_table_exists(dest, 'd'); apop_query("create table %s as select %s * from %s %s %s", dest, use_rowids ? "rowid as id_col, " : " ", *origin, (subset && *subset) ? "where" : " ", (subset && *subset) ? *subset : " " ); } else dest = *origin; create_index(dest, use_rowids ? "id_col" : id_column); Tea_stopif(!apop_table_exists(filltab), return , 0, "No table named '%s'; did you already doMImpute()?", filltab); apop_data *fills = apop_query_to_text("select %s, field, value from %s where (draw=%i or draw = -1)" , id_column, filltab, *imputation_number); Tea_stopif(!fills || fills->error, return, 0, "Expected fill-in table " "%s, but couldn't query it.", filltab); for(int i=0; i< *fills->textsize; i++){ _Bool is_null = !strcmp(fills->text[i][1], apop_opts.nan_string); char tick = is_null ? ' ' : '\''; apop_query("update %s set %s = %c%s%c " "where cast(%s as numeric) = %s", dest, fills->text[i][0], tick, is_null ? "NULL" : fills->text[i][1], tick, id_column, fills->names->row[i]); } commit_transaction(); apop_data_free(fills); free(id_column); }
void test_checkout_conflict__path_filters(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; char *paths[] = { "conflicting-1.txt", "conflicting-3.txt" }; git_strarray patharray = {0}; struct checkout_index_entry checkout_index_entries[] = { { 0100644, CONFLICTING_ANCESTOR_OID, 1, "conflicting-1.txt" }, { 0100644, CONFLICTING_OURS_OID, 2, "conflicting-1.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting-1.txt" }, { 0100644, CONFLICTING_ANCESTOR_OID, 1, "conflicting-2.txt" }, { 0100644, CONFLICTING_OURS_OID, 2, "conflicting-2.txt" }, { 0100644, CONFLICTING_THEIRS_OID, 3, "conflicting-2.txt" }, { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "conflicting-3.txt" }, { 0100644, AUTOMERGEABLE_ANCESTOR_OID, 1, "conflicting-4.txt" }, { 0100644, AUTOMERGEABLE_OURS_OID, 2, "conflicting-4.txt" }, { 0100644, AUTOMERGEABLE_THEIRS_OID, 3, "conflicting-4.txt" }, }; patharray.count = 2; patharray.strings = paths; opts.paths = patharray; create_index(checkout_index_entries, 12); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); ensure_workdir_contents("conflicting-1.txt", CONFLICTING_DIFF3_FILE); cl_assert(!git_path_exists("merge-resolve/conflicting-2.txt")); ensure_workdir_contents("conflicting-3.txt", AUTOMERGEABLE_MERGED_FILE); cl_assert(!git_path_exists("merge-resolve/conflicting-4.txt")); }
int _exec_stmt(DB * db, stmt_t * stmt) { switch (stmt->type) { case STMT_CREAT_TABLE: return create_table(db, stmt->table, stmt->cols, stmt->ncol); case STMT_DROP_TABLE: return drop_table(db, stmt->table); case STMT_CREAT_INDEX: return create_index(db, stmt->table, stmt->attr, stmt->index); case STMT_DROP_INDEX: return drop_index(db, stmt->index); case STMT_INSERT: return insert_into(db, stmt->table, NULL, stmt->vals, stmt->nval); case STMT_DELETE: return delete_from(db, stmt->table, stmt->conds, stmt->ncond); case STMT_SELECT: return select_and_print(db, stmt->table, stmt->cols, stmt->ncol, stmt->conds, stmt->ncond); } xerrno = ERR_INVSTMT; return -1; }
void test_checkout_conflict__links(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; struct checkout_index_entry checkout_index_entries[] = { { 0120000, LINK_ANCESTOR_OID, 1, "link-1" }, { 0120000, LINK_OURS_OID, 2, "link-1" }, { 0120000, LINK_THEIRS_OID, 3, "link-1" }, { 0120000, LINK_OURS_OID, 2, "link-2" }, { 0120000, LINK_THEIRS_OID, 3, "link-2" }, }; opts.checkout_strategy |= GIT_CHECKOUT_SAFE; create_index(checkout_index_entries, 5); git_index_write(g_index); cl_git_pass(git_checkout_index(g_repo, g_index, &opts)); /* Conflicts with links always keep the ours side (even with -Xtheirs) */ ensure_workdir_link("link-1", LINK_OURS_TARGET); ensure_workdir_link("link-2", LINK_OURS_TARGET); }
void test_contains_and_find_one() { constexpr size_t NUM_ROWS = 1 << 10; // 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]); } // Test all the values. for (size_t i = 0; i < NUM_ROWS; ++i) { assert(column->contains(values[i])); grnxx::Int row_id = column->find_one(values[i]); assert(!row_id.is_na()); assert(values[i].match(values[row_id.raw()])); } // Test all the values with index if available. try { column->create_index("Index", GRNXX_TREE_INDEX); for (size_t i = 0; i < NUM_ROWS; ++i) { assert(column->contains(values[i])); grnxx::Int row_id = column->find_one(values[i]); assert(!row_id.is_na()); assert(values[i].match(values[row_id.raw()])); } column->remove_index("Index"); } catch (...) { } // Remove N/A values. for (size_t i = 0; i < NUM_ROWS; ++i) { if (values[i].is_na()) { table->remove_row(grnxx::Int(i)); } } // Test all the values. for (size_t i = 0; i < NUM_ROWS; ++i) { if (!values[i].is_na()) { assert(column->contains(values[i])); grnxx::Int row_id = column->find_one(values[i]); assert(!row_id.is_na()); assert(values[i].match(values[row_id.raw()])); } } assert(!column->contains(T::na())); assert(column->find_one(T::na()).is_na()); // Test all the values with index if available. try { column->create_index("Index", GRNXX_TREE_INDEX); for (size_t i = 0; i < NUM_ROWS; ++i) { if (!values[i].is_na()) { assert(column->contains(values[i])); grnxx::Int row_id = column->find_one(values[i]); assert(!row_id.is_na()); assert(values[i].match(values[row_id.raw()])); } } assert(!column->contains(T::na())); assert(column->find_one(T::na()).is_na()); column->remove_index("Index"); } catch (...) { } // Insert a trailing N/A value. table->insert_row_at(grnxx::Int(NUM_ROWS)); assert(column->contains(T::na())); assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS))); try { column->create_index("Index", GRNXX_TREE_INDEX); assert(column->contains(T::na())); assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS))); column->remove_index("Index"); } catch (...) { } // Remove non-N/A values. for (size_t i = 0; i < NUM_ROWS; ++i) { if (!values[i].is_na()) { table->remove_row(grnxx::Int(i)); } } // Test all the values. for (size_t i = 0; i < NUM_ROWS; ++i) { if (!values[i].is_na()) { assert(!column->contains(values[i])); assert(column->find_one(values[i]).is_na()); } } assert(column->contains(T::na())); assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS))); // Test all the values with index if available. try { column->create_index("Index", GRNXX_TREE_INDEX); for (size_t i = 0; i < NUM_ROWS; ++i) { if (!values[i].is_na()) { assert(!column->contains(values[i])); assert(column->find_one(values[i]).is_na()); } } assert(column->contains(T::na())); assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS))); column->remove_index("Index"); } catch (...) { } }
//////////////////////////////////////////////////////////////////////////////// //create, delete problem void MtxLP::createProb(){ create_prob(); create_index(); }