[casacore] r21176 committed - Handle an empty array correctly in getColumn

0 views
Skip to first unread message

casa...@googlecode.com

unread,
Feb 16, 2012, 3:24:36 AM2/16/12
to casacor...@googlegroups.com
Revision: 21176
Author: gervandiepen
Date: Thu Feb 16 00:24:04 2012
Log: Handle an empty array correctly in getColumn

http://code.google.com/p/casacore/source/detail?r=21176

Modified:
/trunk/tables/Tables/ArrayColumn.tcc

=======================================
--- /trunk/tables/Tables/ArrayColumn.tcc Mon Dec 12 18:59:29 2011
+++ /trunk/tables/Tables/ArrayColumn.tcc Thu Feb 16 00:24:04 2012
@@ -309,30 +309,30 @@
shp.append (IPosition(1,nrrow));
// Check array conformance and resize if needed and possible.
checkShape (shp, arr, resize, "ArrayColumn::getColumn");
- //# Ask if we can access the column (if that is not known yet).
- if (reaskAccessColumn_p) {
+ if (!arr.empty()) {
+ //# Ask if we can access the column (if that is not known yet).
+ if (reaskAccessColumn_p) {
canAccessColumn_p = baseColPtr_p->canAccessArrayColumn
- (reaskAccessColumn_p);
- }
- //# Access the column if possible.
- //# Otherwise fill the entire array by looping through all cells.
- if (canAccessColumn_p) {
+ (reaskAccessColumn_p);
+ }
+ //# Access the column if possible.
+ //# Otherwise fill the entire array by looping through all cells.
+ if (canAccessColumn_p) {
baseColPtr_p->getArrayColumn (&arr);
- }else{
- if (arr.nelements() > 0) {
- ArrayIterator<T> iter(arr, arr.ndim()-1);
- for (uInt rownr=0; rownr<nrrow; rownr++) {
- Array<T>& darr = iter.array();
- if (! darr.shape().isEqual (baseColPtr_p->shape (rownr))) {
- throw TableArrayConformanceError
- ("ArrayColumn::getColumn cannot be done for column " +
- baseColPtr_p->columnDesc().name() +
- "; the array shapes vary");
- }
- baseColPtr_p->get (rownr, &darr);
- iter.next();
- }
- }
+ }else{
+ ArrayIterator<T> iter(arr, arr.ndim()-1);
+ for (uInt rownr=0; rownr<nrrow; rownr++) {
+ Array<T>& darr = iter.array();
+ if (! darr.shape().isEqual (baseColPtr_p->shape (rownr))) {
+ throw TableArrayConformanceError
+ ("ArrayColumn::getColumn cannot be done for column " +
+ baseColPtr_p->columnDesc().name() +
+ "; the array shapes vary");
+ }
+ baseColPtr_p->get (rownr, &darr);
+ iter.next();
+ }
+ }
}
}

@@ -359,24 +359,24 @@
shp.append (IPosition(1,nrrow));
// Check array conformance and resize if needed and possible.
checkShape (shp, arr, resize, "ArrayColumn::getColumn");
- //# Ask if we can access the column slice (if that is not known yet).
- if (reaskAccessColumnSlice_p) {
+ if (!arr.empty()) {
+ //# Ask if we can access the column slice (if that is not known yet).
+ if (reaskAccessColumnSlice_p) {
canAccessColumnSlice_p = baseColPtr_p->canAccessColumnSlice
(reaskAccessColumnSlice_p);
- }
- //# Access the column slice if possible.
- //# Otherwise fill the entire array by looping through all cells.
- Slicer defSlicer (blc, trc, inc, Slicer::endIsLast);
- if (canAccessColumnSlice_p) {
+ }
+ //# Access the column slice if possible.
+ //# Otherwise fill the entire array by looping through all cells.
+ Slicer defSlicer (blc, trc, inc, Slicer::endIsLast);
+ if (canAccessColumnSlice_p) {
baseColPtr_p->getColumnSlice (defSlicer, &arr);
- }else{
- if (arr.nelements() > 0) {
- ArrayIterator<T> iter(arr, arr.ndim()-1);
- for (uInt rownr=0; rownr<nrrow; rownr++) {
- getSlice (rownr, defSlicer, iter.array());
- iter.next();
- }
- }
+ }else{
+ ArrayIterator<T> iter(arr, arr.ndim()-1);
+ for (uInt rownr=0; rownr<nrrow; rownr++) {
+ getSlice (rownr, defSlicer, iter.array());
+ iter.next();
+ }
+ }
}
}

Reply all
Reply to author
Forward
0 new messages