Browse Source

HPCC-8457 Add hthor support for reading/writing dictionary to workunit

Make serialized format more efficient (and safer) by including the hash
table size at the start.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 years ago
parent
commit
4f77d06e9d
2 changed files with 5 additions and 0 deletions
  1. 1 0
      ecl/hthor/hthor.cpp
  2. 4 0
      rtl/eclrtl/rtlds.cpp

+ 1 - 0
ecl/hthor/hthor.cpp

@@ -5921,6 +5921,7 @@ void CHThorDictionaryWorkUnitWriteActivity::execute()
     size32_t rows = builder.getcount();
     byte **dict = builder.queryrows();
     size32_t idx = 0;
+    rowdata.append(sizeof(rows), &rows);
     while (idx < rows)
     {
         byte numRows = 0;

+ 4 - 0
rtl/eclrtl/rtlds.cpp

@@ -956,6 +956,9 @@ extern ECLRTL_API void rtlDictionary2RowsetX(size32_t & count, byte * * & rowset
     Owned<ISerialStream> stream = createMemorySerialStream(src, lenSrc);
     CThorStreamDeserializerSource source(stream);
 
+    size32_t totalRows;
+    source.read(sizeof(totalRows), &totalRows);
+    builder.ensure(totalRows);
     byte nullsPending = 0;
     byte rowsPending = 0;
     while (!source.finishedNested(lenSrc))
@@ -969,6 +972,7 @@ extern ECLRTL_API void rtlDictionary2RowsetX(size32_t & count, byte * * & rowset
     }
 
     count = builder.getcount();
+    assertex(count==totalRows);
     rowset = builder.linkrows();
 }