-
Notifications
You must be signed in to change notification settings - Fork 0
/
lrowgen.cpp
executable file
·46 lines (42 loc) · 1.25 KB
/
lrowgen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "Vertica.h"
using namespace Vertica;
using namespace std;
class RowGen : public TransformFunction
{
virtual void processPartition(ServerInterface &srvInterface,
PartitionReader & inputReader,
PartitionWriter & outputWriter)
{
try
{
const vint nrows = inputReader.getIntRef(0);
for ( vint i = 1 ; i <= nrows ; i++, outputWriter.next() )
outputWriter.setInt( 0 , i ) ;
}
catch (exception& e)
{
vt_report_error(0, "Exception while processing partition: [%s]", e.what());
}
}
};
class RowGenFactory : public TransformFunctionFactory
{
virtual void getPrototype(ServerInterface &srvInterface,
ColumnTypes &argTypes,
ColumnTypes &returnType )
{
argTypes.addInt();
returnType.addInt();
}
virtual void getReturnType(ServerInterface &srvInterface,
const SizedColumnTypes &inputTypes,
SizedColumnTypes &outputTypes )
{
outputTypes.addInt( "series" );
}
virtual TransformFunction *createTransformFunction( ServerInterface &srvInterface )
{
return vt_createFuncObject<RowGen>(srvInterface.allocator);
}
};
RegisterFactory(RowGenFactory);