Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-19815

Embed activity downgraded to hthor

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.0.0
    • Fix Version/s: 7.0.0
    • Component/s: eclcc
    • Labels:
      None

      Description

      Embed activities targeted at thor can be downgraded to hthor. As an example the following code if targeted at thor will run on hthor:

      r := RECORD
          UNSIGNED id;
          STRING name;
      END;
      
      streamed dataset(r) test(unsigned numRows, boolean isLocal = false, unsigned numParallel = 0) := EMBED(C++ : activity, local(isLocal), parallel(numParallel))
      #include <sstream>
      	#include <stdio.h>
      	class TestDataset : public RtlCInterface, implements IRowStream
          {
            	unsigned _num_rows;
            	unsigned _current_row;
           	Linked<IEngineRowAllocator> _result_allocator;
          public:
              RTLIMPLEMENT_IINTERFACE
                  
              TestDataset(unsigned nr, IEngineRowAllocator* allocator) : _num_rows(nr), _current_row(0), _result_allocator(allocator){}
                  
              virtual const void* nextRow() {
                  if (_current_row >= _num_rows) {
                      return nullptr;
                  }
                  _current_row++;
      
                  std::stringstream ss;
                  ss << "Row: " << _current_row;
                  unsigned nameLength = ss.str().size();
      
                  RtlDynamicRowBuilder rowBuilder(_result_allocator);
                  unsigned recordLen = sizeof(uint64_t) + sizeof(size32_t) + nameLength;
                  byte * row = rowBuilder.ensureCapacity(recordLen, NULL);
      
                  *(uint64_t*)(row) = _current_row;
                  *(size32_t *)(row + sizeof(uint64_t)) = nameLength;
                  memcpy(row+sizeof(__uint64)+sizeof(size32_t), ss.str().c_str(), nameLength);
      
                  return rowBuilder.finalizeRowClear(recordLen);
              }
              
              virtual void stop(){}
          };
      #body
      	return new TestDataset(numrows,_resultAllocator);
      ENDEMBED;
      
      ds := test(10);
      output(ds);
      

        Attachments

          Activity

            People

            • Assignee:
              mcmuja01 James McMullan
              Reporter:
              mcmuja01 James McMullan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: