comparison lshlib.cpp @ 369:6564be3109c5 gcc-4.3-cleanups

gcc-4.3 warning cleanups for lshlib.cpp (I do not believe that any of these changes contain significant copyrightable "intellectual property". However, to the extent that they do, the changes are hereby released into the Public Domain, and may be therefore be used by anyone for any purpose without need for consideration of any kind.)
author mas01cr
date Wed, 12 Nov 2008 15:23:32 +0000
parents 223a5994a962
children f9d86b1db21c cead91ecf9a2
comparison
equal deleted inserted replaced
368:6fd52a9a1490 369:6564be3109c5
20 Uns32T get_page_logn(){ 20 Uns32T get_page_logn(){
21 int pagesz = (int)sysconf(_SC_PAGESIZE); 21 int pagesz = (int)sysconf(_SC_PAGESIZE);
22 return (Uns32T)log2((double)pagesz); 22 return (Uns32T)log2((double)pagesz);
23 } 23 }
24 24
25 unsigned align_up(unsigned x, unsigned w){ return ((x) + ((1<<w)-1) & ~((1<<w)-1)); } 25 unsigned align_up(unsigned x, unsigned w) { return (((x) + ((1<<w)-1)) & ~((1<<w)-1)); }
26 26
27 void H::error(const char* a, const char* b, const char *sysFunc) { 27 void H::error(const char* a, const char* b, const char *sysFunc) {
28 cerr << a << ": " << b << endl; 28 cerr << a << ": " << b << endl;
29 if (sysFunc) { 29 if (sysFunc) {
30 perror(sysFunc); 30 perror(sysFunc);
525 calling_instance = caller; 525 calling_instance = caller;
526 add_point_callback = add_point; 526 add_point_callback = add_point;
527 H::compute_hash_functions( v ); 527 H::compute_hash_functions( v );
528 for(Uns32T j = 0 ; j < H::L ; j++ ){ 528 for(Uns32T j = 0 ; j < H::L ; j++ ){
529 H::generate_hash_keys( *( H::g + j ), *( H::r1 + j ), *( H::r2 + j ) ); 529 H::generate_hash_keys( *( H::g + j ), *( H::r1 + j ), *( H::r2 + j ) );
530 if( bucket* bPtr = *(get_bucket(j) + get_t1()) ) 530 if( bucket* bPtr = *(get_bucket(j) + get_t1()) ) {
531 #ifdef LSH_LIST_HEAD_COUNTERS 531 #ifdef LSH_LIST_HEAD_COUNTERS
532 if(bPtr->t2&LSH_CORE_ARRAY_BIT) 532 if(bPtr->t2&LSH_CORE_ARRAY_BIT) {
533 retrieve_from_core_hashtable_array((Uns32T*)(bPtr->next), qpos); 533 retrieve_from_core_hashtable_array((Uns32T*)(bPtr->next), qpos);
534 else 534 } else {
535 bucket_chain_point( bPtr->next, qpos); 535 bucket_chain_point( bPtr->next, qpos);
536 #else 536 }
537 bucket_chain_point( bPtr , qpos); 537 #else
538 #endif 538 bucket_chain_point( bPtr , qpos);
539 #endif
540 }
539 } 541 }
540 } 542 }
541 543
542 void G::retrieve_point_set(vector<vector<float> >& vv, ReporterCallbackPtr add_point, void* caller){ 544 void G::retrieve_point_set(vector<vector<float> >& vv, ReporterCallbackPtr add_point, void* caller){
543 for(Uns32T qpos = 0 ; qpos < vv.size() ; qpos++ ) 545 for(Uns32T qpos = 0 ; qpos < vv.size() ; qpos++ )
682 // Check requested serialFormat 684 // Check requested serialFormat
683 if(!(serialFormat==O2_SERIAL_FILEFORMAT1 || serialFormat==O2_SERIAL_FILEFORMAT2)) 685 if(!(serialFormat==O2_SERIAL_FILEFORMAT1 || serialFormat==O2_SERIAL_FILEFORMAT2))
684 error("Unrecognized serial file format request: ", "serialize()"); 686 error("Unrecognized serial file format request: ", "serialize()");
685 687
686 // Test to see if file exists 688 // Test to see if file exists
687 if((dbfid = open (filename, O_RDONLY)) < 0) 689 if((dbfid = open (filename, O_RDONLY)) < 0) {
688 // If it doesn't, then create the file (CREATE) 690 // If it doesn't, then create the file (CREATE)
689 if(errno == ENOENT){ 691 if(errno == ENOENT) {
690 // Create the file 692 // Create the file
691 std::cout << "Creating new serialized LSH database:" << filename << "..."; 693 std::cout << "Creating new serialized LSH database:" << filename << "...";
692 std::cout.flush(); 694 std::cout.flush();
693 serial_create(filename, serialFormat); 695 serial_create(filename, serialFormat);
694 dbIsNew=1; 696 dbIsNew=1;
695 } 697 } else {
696 else
697 // The file can't be opened 698 // The file can't be opened
698 error("Can't open the file", filename, "open"); 699 error("Can't open the file", filename, "open");
700 }
701 }
699 702
700 // Load the on-disk header into core 703 // Load the on-disk header into core
701 dbfid = serial_open(filename, 1); // open for write 704 dbfid = serial_open(filename, 1); // open for write
702 db = serial_mmap(dbfid, O2_SERIAL_HEADER_SIZE, 1);// get database pointer 705 db = serial_mmap(dbfid, O2_SERIAL_HEADER_SIZE, 1);// get database pointer
703 serial_get_header(db); // read header 706 serial_get_header(db); // read header
844 for( y = 0 ; y < H::N ; y++ ){ 847 for( y = 0 ; y < H::N ; y++ ){
845 // Move disk pointer to beginning of row 848 // Move disk pointer to beginning of row
846 pe=pt+y*lshHeader->numCols; 849 pe=pt+y*lshHeader->numCols;
847 850
848 colCount=0; 851 colCount=0;
849 if(bucket* bPtr = h[x][y]) 852 if(bucket* bPtr = h[x][y]) {
850 if(merge) 853 if(merge) {
851 #ifdef LSH_LIST_HEAD_COUNTERS 854 #ifdef LSH_LIST_HEAD_COUNTERS
852 serial_merge_hashtable_row_format1(pe, bPtr->next, colCount); // skip collision counter bucket 855 serial_merge_hashtable_row_format1(pe, bPtr->next, colCount); // skip collision counter bucket
853 else 856 } else {
854 serial_write_hashtable_row_format1(pe, bPtr->next, colCount); // skip collision counter bucket 857 serial_write_hashtable_row_format1(pe, bPtr->next, colCount); // skip collision counter bucket
855 #else 858 #else
856 serial_merge_hashtable_row_format1(pe, bPtr, colCount); 859 serial_merge_hashtable_row_format1(pe, bPtr, colCount);
857 else 860 } else {
858 serial_write_hashtable_row_format1(pe, bPtr, colCount); 861 serial_write_hashtable_row_format1(pe, bPtr, colCount);
859 #endif 862 #endif
863 }
864 }
860 if(colCount){ 865 if(colCount){
861 if(colCount<minColCount) 866 if(colCount<minColCount)
862 minColCount=colCount; 867 minColCount=colCount;
863 if(colCount>maxColCount) 868 if(colCount>maxColCount)
864 maxColCount=colCount; 869 maxColCount=colCount;