src/TabularPrefetchingHandler.h
branchv_0
changeset 6 fc1e746e26a5
parent 5 911ec74cce33
child 7 2057919937fa
equal deleted inserted replaced
5:911ec74cce33 6:fc1e746e26a5
     9 #include <regex>
     9 #include <regex>
    10 
    10 
    11 #include <relpipe/reader/typedefs.h>
    11 #include <relpipe/reader/typedefs.h>
    12 #include <relpipe/reader/TypeId.h>
    12 #include <relpipe/reader/TypeId.h>
    13 #include <relpipe/reader/handlers/RelationalReaderStringHandler.h>
    13 #include <relpipe/reader/handlers/RelationalReaderStringHandler.h>
       
    14 #include <relpipe/reader/handlers/AttributeMetadata.h>
    14 
    15 
    15 namespace relpipe {
    16 namespace relpipe {
    16 namespace out {
    17 namespace out {
    17 namespace tabular {
    18 namespace tabular {
    18 
    19 
   152 public:
   153 public:
   153 
   154 
   154 	TabularPrefetchingHandler(std::ostream& output) : output(output) {
   155 	TabularPrefetchingHandler(std::ostream& output) : output(output) {
   155 	}
   156 	}
   156 
   157 
   157 	void startRelation(string_t name, std::vector<std::pair<string_t, TypeId> > attributes) override {
   158 	void startRelation(string_t name, std::vector<handlers::AttributeMetadata> attributes) override {
   158 		if (columnCount) printCachedData();
   159 		if (columnCount) printCachedData();
   159 
   160 
   160 		output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl;
   161 		output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl;
   161 		columnCount = attributes.size();
   162 		columnCount = attributes.size();
   162 		columnTypes.resize(columnCount);
   163 		columnTypes.resize(columnCount);
   163 		columnTypeCodes.resize(columnCount);
   164 		columnTypeCodes.resize(columnCount);
   164 		columnNames.resize(columnCount);
   165 		columnNames.resize(columnCount);
   165 		columnWidths.resize(columnCount, 0);
   166 		columnWidths.resize(columnCount, 0);
   166 		for (int i = 0; i < attributes.size(); i++) {
   167 		for (int i = 0; i < attributes.size(); i++) {
   167 			columnNames[i] = attributes[i].first;
   168 			columnNames[i] = attributes[i].attributeName;
   168 			columnTypes[i] = attributes[i].second;
   169 			columnTypes[i] = attributes[i].typeId;
   169 			columnTypeCodes[i] = L"TODO"; // TODO: type codes/names
   170 			columnTypeCodes[i] = attributes[i].typeName;
   170 		}
   171 		}
   171 	}
   172 	}
   172 
   173 
   173 	void attribute(const string_t& value) override {
   174 	void attribute(const string_t& value) override {
   174 		integer_t i = values.size() % columnCount;
   175 		integer_t i = values.size() % columnCount;