Changeset 38422
- Timestamp:
- Jun 7, 2015, 11:40:02 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_split.c
r38419 r38422 12 12 if (fullWrite && catcompress) return TRUE; // we want to compress, so do not swap 13 13 return FALSE; 14 } 15 16 int byteswap_varlength_ftable (Header *header, FTable *table) { 17 int i, Nfields; 18 if (!gfits_scan (header, "TFIELDS", "%d", 1, &Nfields)) return FALSE; 19 for (i = 0; i < Nfields; i++) { 20 if (!gfits_byteswap_varlength_column (table, i+1)) return FALSE; 21 } 22 return TRUE; 14 23 } 15 24 … … 124 133 fprintf (stderr, "compress %s\n", catalog->filename); 125 134 char *compressMode = dvo_catalog_compress_string (catalog->catcompress); 126 if (!gfits_compress_table (ftable, &cmptable, 0, compressMode)) { 135 // I should test how Ntile affects fpack/funpack and speed 136 if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) { 127 137 fprintf (stderr, "compression failure\n"); 128 138 return (FALSE); 139 } 140 if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) { 141 fprintf (stderr, "failed to swap varlength column\n"); 142 return FALSE; 129 143 } 130 144 if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) { … … 140 154 if (fullWrite) { 141 155 if (!gfits_fwrite_Theader (catalog->f, outtable->header)) { 142 fprintf (stderr, "can't write table data\n");156 fprintf (stderr, "can't write table header\n"); 143 157 return (FALSE); 144 158 } … … 149 163 } else { 150 164 if (!gfits_fwrite_ftable_range (catalog->f, outtable, start, Nrows, Ndisk, Ntotal)) { 151 fprintf (stderr, "can't write table data \n");165 fprintf (stderr, "can't write table data (range)\n"); 152 166 return (FALSE); 153 167 } … … 257 271 rawtable.header = &rawheader; 258 272 259 // NOTE: uncompress swaps the bytes into native order 273 // NOTE: uncompress swaps the data bytes into native order, but needs the varlength columns native 274 if (!byteswap_varlength_ftable (ftable->header, ftable)) { 275 fprintf (stderr, "failed to swap varlength column\n"); 276 return FALSE; 277 } 260 278 if (!gfits_uncompress_table (ftable, &rawtable)) { 261 279 if (VERBOSE) fprintf (stderr, "failed to uncompress table\n"); … … 819 837 int swapFromNative = !output_is_compressed (start, Nrows, Naverage_disk_new, catalog->catcompress); 820 838 839 // convert to external table format 821 840 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary, swapFromNative)) { 822 841 fprintf (stderr, "trouble converting format\n"); … … 855 874 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 856 875 876 // if we are going to compress, we need to receive unswapped data -- 877 int swapFromNative = !output_is_compressed (start, Nrows, Nmeasure_disk_new, catalog->catcompress); 878 857 879 // convert to external table format 858 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) {880 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, swapFromNative)) { 859 881 fprintf (stderr, "trouble converting format\n"); 860 882 goto failure; … … 878 900 } 879 901 902 // if we are going to compress, we need to receive unswapped data -- 903 int swapFromNative = !output_is_compressed (start, Nrows, Nmissing_disk_new, catalog->catcompress); 904 880 905 // convert to external table format 881 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE)) {906 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, swapFromNative)) { 882 907 fprintf (stderr, "trouble converting format\n"); 883 908 goto failure; … … 907 932 // XXX check these for consistency... 908 933 934 // if we are going to compress, we need to receive unswapped data -- 935 int swapFromNative = !output_is_compressed (start, Nrows, Nsecfilt_disk_new, catalog->catcompress); 936 909 937 // convert to external table format 910 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE); 938 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative)) { 939 fprintf (stderr, "trouble converting format\n"); 940 goto failure; 941 } 911 942 912 943 // write out SecFilt table … … 931 962 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 932 963 964 // if we are going to compress, we need to receive unswapped data -- 965 int swapFromNative = !output_is_compressed (start, Nrows, Nlensing_disk_new, catalog->catcompress); 966 933 967 // convert to external table format 934 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) {968 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, swapFromNative)) { 935 969 fprintf (stderr, "trouble converting format\n"); 936 970 goto failure; … … 958 992 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 959 993 994 // if we are going to compress, we need to receive unswapped data -- 995 int swapFromNative = !output_is_compressed (start, Nrows, Nlensobj_disk_new, catalog->catcompress); 996 960 997 // convert to external table format 961 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) {998 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, swapFromNative)) { 962 999 fprintf (stderr, "trouble converting format\n"); 963 1000 goto failure; … … 985 1022 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 986 1023 1024 // if we are going to compress, we need to receive unswapped data -- 1025 int swapFromNative = !output_is_compressed (start, Nrows, Nstarpar_disk_new, catalog->catcompress); 1026 987 1027 // convert to external table format 988 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) {1028 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, swapFromNative)) { 989 1029 fprintf (stderr, "trouble converting format\n"); 990 1030 goto failure; … … 1012 1052 assert (catalog[0].Ngalphot_disk >= catalog[0].Ngalphot_off); 1013 1053 1054 // if we are going to compress, we need to receive unswapped data -- 1055 int swapFromNative = !output_is_compressed (start, Nrows, Ngalphot_disk_new, catalog->catcompress); 1056 1014 1057 // convert to external table format 1015 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, TRUE)) {1058 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, swapFromNative)) { 1016 1059 fprintf (stderr, "trouble converting format\n"); 1017 1060 goto failure; … … 1152 1195 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 1153 1196 1154 // if we are going to compress, we need to receive unswapped data --1155 int swapFromNative = !output_is_compressed (start, Nrows, Nmeasure_disk_new, catalog->catcompress);1156 1157 1197 // convert to external table format (note that the block above does not damage or free catalog.average) 1158 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, swapFromNative)) {1198 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) { 1159 1199 fprintf (stderr, "trouble converting format\n"); 1160 1200 goto failure; … … 1178 1218 } 1179 1219 1180 // if we are going to compress, we need to receive unswapped data --1181 int swapFromNative = !output_is_compressed (0, catalog->Nmissing, catalog->Nmissing, catalog->catcompress);1182 1183 1220 // convert to external table format 1184 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, swapFromNative)) {1221 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE)) { 1185 1222 fprintf (stderr, "trouble converting format\n"); 1186 1223 goto failure; … … 1210 1247 // XXX check these for consistency... 1211 1248 1212 // if we are going to compress, we need to receive unswapped data --1213 int swapFromNative = !output_is_compressed (start, Nrows, Nsecfilt_disk_new, catalog->catcompress);1214 1215 1249 // convert to external table format 1216 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative); 1250 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE)) { 1251 fprintf (stderr, "trouble converting format\n"); 1252 goto failure; 1253 } 1217 1254 1218 1255 // write out SecFilt table … … 1238 1275 1239 1276 if (catalog[0].Nlensing) { 1240 // if we are going to compress, we need to receive unswapped data --1241 int swapFromNative = !output_is_compressed (start, Nrows, Nlensing_disk_new, catalog->catcompress);1242 1243 1277 // convert to external table format (note that the block above does not damage or free catalog.average) 1244 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, swapFromNative)) {1278 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) { 1245 1279 fprintf (stderr, "trouble converting format\n"); 1246 1280 goto failure; … … 1270 1304 1271 1305 if (catalog[0].Nlensobj) { 1272 // if we are going to compress, we need to receive unswapped data --1273 int swapFromNative = !output_is_compressed (start, Nrows, Nlensobj_disk_new, catalog->catcompress);1274 1275 1306 // convert to external table format (note that the block above does not damage or free catalog.average) 1276 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, swapFromNative)) {1307 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) { 1277 1308 fprintf (stderr, "trouble converting format\n"); 1278 1309 goto failure; … … 1302 1333 1303 1334 if (catalog[0].Nstarpar) { 1304 // if we are going to compress, we need to receive unswapped data --1305 int swapFromNative = !output_is_compressed (start, Nrows, Nstarpar_disk_new, catalog->catcompress);1306 1307 1335 // convert to external table format (note that the block above does not damage or free catalog.average) 1308 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, swapFromNative)) {1336 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) { 1309 1337 fprintf (stderr, "trouble converting format\n"); 1310 1338 goto failure; … … 1334 1362 1335 1363 if (catalog[0].Ngalphot) { 1336 // if we are going to compress, we need to receive unswapped data --1337 int swapFromNative = !output_is_compressed (start, Nrows, Ngalphot_disk_new, catalog->catcompress);1338 1339 1364 // convert to external table format (note that the block above does not damage or free catalog.average) 1340 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, swapFromNative)) {1365 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, TRUE)) { 1341 1366 fprintf (stderr, "trouble converting format\n"); 1342 1367 goto failure; … … 1566 1591 1567 1592 // convert to external table format 1568 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE); 1593 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE)) { 1594 fprintf (stderr, "trouble converting format\n"); 1595 goto failure; 1596 } 1569 1597 1570 1598 // write out SecFilt table
Note:
See TracChangeset
for help on using the changeset viewer.
