00001 #ifndef Impala_Core_Table_SelectOneColumn_h
00002 #define Impala_Core_Table_SelectOneColumn_h
00003
00006 #include "Core/Column/Select.h"
00007 #include "Basis/Quid.h"
00008 #include "Core/Table/Filter.h"
00009
00010 namespace Impala
00011 {
00012 namespace Core
00013 {
00014 namespace Table
00015 {
00016
00017
00024 template <class T1, class T2>
00025 inline void
00026 SelectOneColumn(T1* dst, T2* src, int col, bool* filter, bool doClearDst)
00027 {
00028 int srcSize = src->Size();
00029 if (doClearDst)
00030 dst->SetSize(0);
00031 int nr = 0;
00032 if (filter)
00033 {
00034 for (int i=0 ; i<srcSize ; i++)
00035 if (filter[i])
00036 nr++;
00037 }
00038 else
00039 {
00040 nr = srcSize;
00041 }
00042 dst->ReserveMin(dst->Size() + nr, true);
00043 switch(col)
00044 {
00045 case 1:
00046 Column::Select(dst->GetColumn1(), src->GetColumn1(), filter,
00047 dst->Size(), 0, srcSize);
00048 break;
00049 case 2:
00050 Column::Select(dst->GetColumn1(), src->GetColumn2(), filter,
00051 dst->Size(), 0, srcSize);
00052 break;
00053 case 3:
00054 Column::Select(dst->GetColumn1(), src->GetColumn3(), filter,
00055 dst->Size(), 0, srcSize);
00056 break;
00057 case 4:
00058 Column::Select(dst->GetColumn1(), src->GetColumn4(), filter,
00059 dst->Size(), 0, srcSize);
00060 break;
00061 case 5:
00062 Column::Select(dst->GetColumn1(), src->GetColumn5(), filter,
00063 dst->Size(), 0, srcSize);
00064 break;
00065 case 6:
00066 Column::Select(dst->GetColumn1(), src->GetColumn6(), filter,
00067 dst->Size(), 0, srcSize);
00068 break;
00069 case 7:
00070 Column::Select(dst->GetColumn1(), src->GetColumn7(), filter,
00071 dst->Size(), 0, srcSize);
00072 break;
00073 case 8:
00074 Column::Select(dst->GetColumn1(), src->GetColumn8(), filter,
00075 dst->Size(), 0, srcSize);
00076 break;
00077 case 9:
00078 Column::Select(dst->GetColumn1(), src->GetColumn9(), filter,
00079 dst->Size(), 0, srcSize);
00080 break;
00081 }
00082 dst->SetSize(dst->Size() + nr);
00083 }
00084
00085 template <class T1, class T2, class Criterion>
00086 inline void
00087 SelectOneColumn(T1* dst, T2* src, int col, Criterion c, bool doClearDst)
00088 {
00089 bool* filter = Filter(src, c);
00090 SelectOneColumn(dst, src, col, filter, doClearDst);
00091 delete filter;
00092 }
00093
00094 }
00095 }
00096 }
00097
00098 #endif