source: branches/hpc33/src/STIdxIter.h @ 2536

Last change on this file since 2536 was 2536, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Minor speedup that STIdxIterAcc skips to update internal storage and
just update data length and pointer when specified column has only
one value.


File size: 3.8 KB
Line 
1#ifndef _ASAP_INDEX_ITERATOR_H_
2#define _ASAP_INDEX_ITERATOR_H_
3
4#include <vector>
5#include <casa/Containers/Block.h>
6#include <casa/Arrays/Vector.h>
7#include <casa/Arrays/Matrix.h>
8#include <casa/Arrays/IPosition.h>
9
10#include "Scantable.h"
11
12using namespace std ;
13using namespace casa ;
14
15namespace asap {
16class IndexIterator
17{
18public:
19  IndexIterator( IPosition &shape ) ;
20  Block<uInt> current() { return idx_m ; } ;
21  Bool pastEnd() ;
22  void next() ;
23private:
24  uInt nfield_m ;
25  Block<uInt> prod_m ;
26  Block<uInt> idx_m ;
27  uInt niter_m ;
28  uInt maxiter_m ;
29} ;
30
31class ArrayIndexIterator
32{
33public:
34  ArrayIndexIterator( Matrix<uInt> &arr,
35                      vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
36  virtual ~ArrayIndexIterator() ;
37  Vector<uInt> current() ;
38  Bool pastEnd() ;
39  virtual void next() = 0 ;
40  virtual Vector<uInt> getRows( StorageInitPolicy policy=COPY ) = 0 ;
41protected:
42  IndexIterator *iter_m ;
43  uInt nrow_m ;
44  uInt ncol_m ;
45  Block<uInt> storage_m ;
46  Matrix<uInt> arr_m ;
47  IPosition pos_m ;
48  Vector<uInt> current_m ;
49  vector< vector<uInt> > idxlist_m ;
50} ;
51
52class ArrayIndexIteratorNormal : public ArrayIndexIterator
53{
54public:
55  ArrayIndexIteratorNormal( Matrix<uInt> &arr,
56                            vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
57  void next() ;
58  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
59} ;
60
61class ArrayIndexIteratorAcc : public ArrayIndexIterator
62{
63public:
64  ArrayIndexIteratorAcc( Matrix<uInt> &arr,
65                         vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
66  void next() ;
67  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
68private:
69  Int isChanged( Block<uInt> &idx ) ;
70  uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ;
71
72  Block<uInt> prev_m ;
73  Block<uInt> len_m ;
74  Block<Bool> skip_m ;
75} ;
76
77class STIdxIter
78{
79public:
80  STIdxIter() ;
81  STIdxIter( const string &name,
82                             const vector<string> &cols ) ;
83  STIdxIter( const CountedPtr<Scantable> &s,
84                          const vector<string> &cols ) ;
85  virtual ~STIdxIter() ;
86  vector<uInt> currentSTL() { return tovector( iter_m->current() ) ; } ;
87  Vector<uInt> current() { return iter_m->current() ; } ;
88  Bool pastEnd() { return iter_m->pastEnd() ; } ;
89  void next() { iter_m->next() ; } ;
90  vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
91  // !!!you should not use policy=TAKE_OVER since it causes problem!!!
92  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
93protected:
94  ArrayIndexIterator *iter_m ;
95  virtual void init( Table &t,
96                     const vector<string> &cols ) = 0 ;
97private:
98  vector<uInt> tovector( Vector<uInt> v ) ;
99} ;
100
101class STIdxIterNormal : public STIdxIter
102{
103public:
104  STIdxIterNormal() ;
105  STIdxIterNormal( const string &name,
106                   const vector<string> &cols ) ;
107  STIdxIterNormal( const CountedPtr<Scantable> &s,
108                   const vector<string> &cols ) ;
109  ~STIdxIterNormal() ;
110protected:
111  void init( Table &t,
112             const vector<string> &cols ) ;
113} ;
114
115class STIdxIterAcc : public STIdxIter
116{
117public:
118  STIdxIterAcc() ;
119  STIdxIterAcc( const string &name,
120                const vector<string> &cols ) ;
121  STIdxIterAcc( const CountedPtr<Scantable> &s,
122                const vector<string> &cols ) ;
123  ~STIdxIterAcc() ;
124protected:
125  virtual void init( Table &t,
126                     const vector<string> &cols ) ;
127} ;
128
129// class STIdxIterExAcc : public STIdxIterAcc
130// {
131//   STIdxIterExAcc() ;
132//   STIdxIterExAcc( const string &name,
133//                   const vector<string> &cols ) ;
134//   STIdxIterExAcc( const CountedPtr<Scantable> &s,
135//                   const vector<string> &cols ) ;
136//   ~STIdxIterExAcc() ;
137// protected:
138//   virtual void init( Table &t,
139//                      const vector<string> &cols ) ;
140// } ;
141
142} // namespace
143#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.