template<class TableT>
Definition at line 59 of file Read.h. References Impala::Util::IOBuffer::GetPosition(), Impala::Util::StringParser::GetString(), ILOG_ERROR, ILOG_VAR, Read(), Impala::Util::IOBuffer::Read(), Impala::Util::IOBuffer::ReadLine(), ReadOldHeader(), Impala::Util::IOBuffer::Seek(), Impala::Util::IOBuffer::SetPosition(), and Impala::Util::StringParser::TheEnd(). Referenced by Impala::Core::Table::AnnotationTable::MakeFromFile(), and Read(). 00060 { 00061 ILOG_VAR(Impala.Core.Table.Read); 00062 if (!table) 00063 { 00064 ILOG_ERROR("No table"); 00065 return; 00066 } 00067 00068 String formatStr = "impalatableversion: 2, columns: %d, size: %d"; 00069 const int TABLEHEADERSIZE = 1024; 00070 00071 int columns; 00072 int nr; 00073 char buf[TABLEHEADERSIZE+1]; 00074 for (int i=0 ; i<TABLEHEADERSIZE+1 ; i++) 00075 buf[i] = 0; 00076 00077 Util::IOBuffer::PositionType startPos = buffer->GetPosition(); 00078 buffer->Read(buf, TABLEHEADERSIZE); 00079 00080 // backwards compatibility 00081 if((buf[0] == 'I') && (buf[1] == 'm')) 00082 { 00083 buffer->Seek(startPos, SEEK_SET); 00084 String marker = buffer->ReadLine(); 00085 if(marker.substr(0, 13) == "Impala::Table") 00086 { 00087 table->SetInfo(buffer->ReadLine()); 00088 ReadOldHeader(table, buffer); 00089 return; 00090 } 00091 buffer->Seek(startPos + TABLEHEADERSIZE, SEEK_SET); 00092 } 00093 00094 int res = sscanf(buf, formatStr.c_str(), 00095 &columns, &nr); 00096 if (res != 2) 00097 { 00098 ILOG_ERROR("Header is not compatible: res==" << res << 00099 " (should be 2), size==" << nr << 00100 ", columns==" << columns << ", startPos==" << startPos); 00101 return; 00102 } 00103 00104 // parse the rest of the header 00105 String buf2(buf); 00106 Util::StringParser sp(buf2); 00107 while(!(sp.TheEnd())) 00108 { 00109 String key = sp.GetString(':', false); 00110 if(sp.TheEnd()) break; 00111 String value = sp.GetString('\n', true); 00112 if(key == "column1") table->SetColName(1, value); 00113 if(key == "column2") table->SetColName(2, value); 00114 if(key == "column3") table->SetColName(3, value); 00115 if(key == "column4") table->SetColName(4, value); 00116 if(key == "column5") table->SetColName(5, value); 00117 if(key == "column6") table->SetColName(6, value); 00118 if(key == "column7") table->SetColName(7, value); 00119 if(key == "column8") table->SetColName(8, value); 00120 if(key == "column9") table->SetColName(9, value); 00121 if(key == "info") table->SetInfo(value); 00122 } 00123 00124 // skip past footer 00125 buffer->SetPosition(startPos + TABLEHEADERSIZE + sizeof(Int64) * 16); 00126 00127 Column::Read(table->GetColumn1(), buffer); 00128 if (table->GetColumn1()->Capacity() != nr) 00129 ILOG_ERROR("col1 has different size than header"); 00130 Column::Read(table->GetColumn2(), buffer); 00131 if (table->GetColumn2()->Valid() && (table->GetColumn2()->Capacity() != nr)) 00132 ILOG_ERROR("col2 has different size than col1"); 00133 Column::Read(table->GetColumn3(), buffer); 00134 if (table->GetColumn3()->Valid() && (table->GetColumn3()->Capacity() != nr)) 00135 ILOG_ERROR("col3 has different size than col1"); 00136 Column::Read(table->GetColumn4(), buffer); 00137 if (table->GetColumn4()->Valid() && (table->GetColumn4()->Capacity() != nr)) 00138 ILOG_ERROR("col4 has different size than col1"); 00139 Column::Read(table->GetColumn5(), buffer); 00140 if (table->GetColumn5()->Valid() && (table->GetColumn5()->Capacity() != nr)) 00141 ILOG_ERROR("col5 has different size than col1"); 00142 Column::Read(table->GetColumn6(), buffer); 00143 if (table->GetColumn6()->Valid() && (table->GetColumn6()->Capacity() != nr)) 00144 ILOG_ERROR("col6 has different size than col1"); 00145 Column::Read(table->GetColumn7(), buffer); 00146 if (table->GetColumn7()->Valid() && (table->GetColumn7()->Capacity() != nr)) 00147 ILOG_ERROR("col7 has different size than col1"); 00148 Column::Read(table->GetColumn8(), buffer); 00149 if (table->GetColumn8()->Valid() && (table->GetColumn8()->Capacity() != nr)) 00150 ILOG_ERROR("col8 has different size than col1"); 00151 Column::Read(table->GetColumn9(), buffer); 00152 if (table->GetColumn9()->Valid() && (table->GetColumn9()->Capacity() != nr)) 00153 ILOG_ERROR("col9 has different size than col1"); 00154 table->SetSize(nr); 00155 }
Here is the call graph for this function:
|