46 outputStream.open(filename);
48 std::vector<std::string> schemaList = writerDictionary.
getSchemaList();
53 for(
int i = 0; i < schemaList.size(); i++){
62 schemaEvent.addStructure(schemaNodeJson);
63 schemaEvent.addStructure(schemaNode);
73 std::map<std::string,std::string>::iterator it;
76 for( it = userConfig.begin(); it != userConfig.end(); it++){
77 printf(
"::: adding user configuration (key): %s\n",it->first.c_str());
79 std::string wKey = std::string(it->first.c_str());
80 std::string wConfig = std::string(it->second.c_str());
86 configEvent.addStructure(configKey);
87 configEvent.addStructure(configString);
114 outputStream.write(
reinterpret_cast<char *
> (&header),
sizeof(header));
115 long position = outputStream.tellp();
117 printf(
"writing header:: position = %ld\n",position);
118 outputStream.write(
reinterpret_cast<char *
> (&builder.
getRecordBuffer()[0]),dictionarySize);
119 position = outputStream.tellp();
120 printf(
"writing dictionary:: position = %ld\n",position);
125 for(
int i = 0; i < schemaList.size(); i++){
132 bool status = recordBuilder.
addEvent(hevent);
138 int tag = hevent.
getTag();
139 extendedBuilder[tag].setUserWordOne(tag);
140 bool status = extendedBuilder[tag].addEvent(hevent);
143 extendedBuilder[tag].addEvent(hevent);
149 int transferSize = size;
150 if(size<0){ transferSize = vec.size(); }
151 bool status = recordBuilder.
addEvent(vec,0,transferSize);
154 recordBuilder.
addEvent(vec,0,transferSize);
168 writerRecordInfo.push_back(recordInfo);
169 if(verbose>0) printf(
"%6ld : writing::record : size = %8d, entries = %8d, position = %12ld word = %12ld %12ld\n",
173 if(verbose>0) printf(
" write::record : empty record will not be written.....\n");
179 for(
int loop = 0; loop < writerRecordInfo.size(); loop++){
181 printf(
" %6d : record INFO : size = %8d, entries = %8d, position = %12ld word = %12ld %12ld\n", loop,
188 void writer::writeIndexTable(){
190 indexSchema.parse(
"position/L,length/I,entries/I,userWordOne/L,userWordTwo/L");
191 int nEntries = writerRecordInfo.size();
192 long indexPosition = outputStream.tellp();
193 printf(
"\n\n-----> writing file index : entries = %d, position = %ld\n",
194 nEntries,indexPosition);
196 for(
int i = 0; i < nEntries; i++){
201 indexBank.putLong(
"userWordOne",i,recordInfo.
userWordOne);
202 indexBank.putLong(
"userWordTwo",i,recordInfo.
userWordTwo);
205 int eventSize = 32*nEntries + 1024;
208 indexEvent.addStructure(indexBank);
209 recordBuilder.
reset();
213 outputStream.write(
reinterpret_cast<char *
> (&indexPosition), 8);
219 std::map<int,hipo::recordbuilder>::iterator it;
220 for(it = extendedBuilder.begin(); it != extendedBuilder.end(); it++){
225 outputStream.close();
226 writerRecordInfo.clear();
Represents a HIPO bank, a tabular data structure with rows and typed columns.
Collection of schema definitions, typically read from a HIPO file header.
void addSchema(schema sc)
Add a schema to the dictionary.
std::vector< std::string > getSchemaList()
Get a list of all schema names in the dictionary.
schema & getSchema(const char *name)
Retrieve a schema by name.
Represents a HIPO event, a container for multiple structures/banks.
Builds HIPO records by accumulating events and compressing them.
void build()
Compresses accumulated events and builds the final record.
void setUserWordOne(long userWordOne)
Sets the first user-defined word in the record header.
std::vector< char > & getRecordBuffer()
Returns a reference to the internal record buffer.
int getRecordSize()
Returns the total size of the built record in bytes.
void reset()
Resets the builder, clearing all accumulated events.
long getUserWordTwo()
Returns the second user-defined word stored in the record header.
void setUserWordTwo(long userWordTwo)
Sets the second user-defined word in the record header.
long getUserWordOne()
Returns the first user-defined word stored in the record header.
bool addEvent(std::vector< char > &vec, int start, int length)
Adds an event from a raw byte vector.
int getEntries()
Returns the number of events currently in the record.
Schema definition for a HIPO bank.
std::string getSchemaString()
Serialize the schema to a definition string (e.g. "pid/I,px/F").
std::string getSchemaStringJson()
Serialize the schema to a JSON-formatted string.
Low-level data structure representing a HIPO structure.
void open(const char *filename)
Open a file for writing.
void writeRecord(recordbuilder &builder)
Write a completed record to the output file.
void flush()
Flush the current record buffer to disk.
void setUserIntegerTwo(long userIntTwo)
Set the second user-defined integer in the file header.
void setUserIntegerOne(long userIntOne)
Set the first user-defined integer in the file header.
void addDictionary(hipo::dictionary &dict)
Set the dictionary to be written into the file header.
void addEvent(hipo::event &hevent)
Add an event to the current record buffer.
void showSummary()
Print a summary of records written to stdout.
void close()
Close the file, flushing remaining events and writing the trailer.
constexpr uint32_t HIPO_FILE_UNIQUE_WORD
constexpr int FILE_INDEX_ITEM
constexpr int FILE_HEADER_WORDS
constexpr int CONFIG_GROUP
constexpr int CONFIG_KEY_ITEM
constexpr uint32_t HEADER_MAGIC
constexpr int FILE_INDEX_GROUP
constexpr int DICT_JSON_ITEM
constexpr uint32_t BITINFO_VERSION_MASK
constexpr int FH_TRAILER_POS_OFFSET
constexpr int HIPO_VERSION
constexpr int CONFIG_STRING_ITEM
Metadata for a single record in a HIPO file.
long userWordOne
First user-defined word.
long userWordTwo
Second user-defined word.
int recordLength
Total record length in bytes.
long recordPosition
Byte position of the record in the file.
int recordEntries
Number of events in the record.
HIPO file writer for creating HIPO output files.