thpullslave.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "slave.ipp"
  14. #include "thactivityutil.ipp"
  15. #include "thbufdef.hpp"
  16. #include "thpullslave.ipp"
  17. class PullSlaveActivity : public CSlaveActivity
  18. {
  19. typedef CSlaveActivity PARENT;
  20. public:
  21. PullSlaveActivity(CGraphElementBase *_container) : CSlaveActivity(_container)
  22. {
  23. appendOutputLinked(this);
  24. }
  25. // IThorDataLink methods
  26. virtual void setInputStream(unsigned index, CThorInput &_input, bool consumerOrdered) override
  27. {
  28. PARENT::setInputStream(index, _input, consumerOrdered);
  29. setLookAhead(0, createRowStreamLookAhead(this, inputStream, queryRowInterfaces(input), PULL_SMART_BUFFER_SIZE, true, false, RCUNBOUND, NULL, &container.queryJob().queryIDiskUsage()));
  30. }
  31. virtual void start() override
  32. {
  33. ActivityTimer s(totalCycles, timeActivities);
  34. PARENT::start();
  35. }
  36. const void * nextRow() override
  37. {
  38. ActivityTimer t(totalCycles, timeActivities);
  39. OwnedConstThorRow row = inputStream->nextRow();
  40. if (!row)
  41. return NULL;
  42. dataLinkIncrement();
  43. return row.getClear();
  44. }
  45. virtual bool isGrouped() const override { return false; } // or input->isGrouped?
  46. virtual void getMetaInfo(ThorDataLinkMetaInfo &info) override
  47. {
  48. initMetaInfo(info);
  49. info.buffersInput = true;
  50. calcMetaInfoSize(info, queryInput(0));
  51. }
  52. };
  53. CActivityBase *createPullSlave(CGraphElementBase *container)
  54. {
  55. return new PullSlaveActivity(container);
  56. }