thorfile.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 "jliball.hpp"
  14. #include "thorfile.hpp"
  15. #include "eclhelper.hpp"
  16. #include "eclrtl.hpp"
  17. #include "eclrtl_imp.hpp"
  18. #include "rtlfield_imp.hpp"
  19. #include "rtlds_imp.hpp"
  20. namespace thorfile {
  21. #include "eclhelper_base.hpp"
  22. }
  23. #include "thorcommon.ipp"
  24. void setExpiryTime(IPropertyTree & properties, unsigned expireDays)
  25. {
  26. properties.setPropInt("@expireDays", expireDays);
  27. }
  28. class DiskWorkUnitReadArg : public thorfile::CThorDiskReadArg
  29. {
  30. public:
  31. DiskWorkUnitReadArg(const char * _filename, IHThorWorkunitReadArg * _wuRead) : filename(_filename), wuRead(_wuRead)
  32. {
  33. recordSize.set(wuRead->queryOutputMeta());
  34. }
  35. virtual IOutputMetaData * queryOutputMeta()
  36. {
  37. return wuRead->queryOutputMeta();
  38. }
  39. virtual const char * getFileName()
  40. {
  41. return filename;
  42. }
  43. virtual IOutputMetaData * queryDiskRecordSize()
  44. {
  45. return (IOutputMetaData *)recordSize;
  46. }
  47. virtual unsigned getFormatCrc()
  48. {
  49. return 0;
  50. }
  51. virtual unsigned getFlags()
  52. {
  53. return TDRnocrccheck;
  54. }
  55. virtual size32_t transform(ARowBuilder & rowBuilder, const void * src)
  56. {
  57. unsigned size = recordSize.getRecordSize(src);
  58. memcpy(rowBuilder.ensureCapacity(size, NULL), src, size);
  59. return size;
  60. }
  61. protected:
  62. StringAttr filename;
  63. Linked<IHThorWorkunitReadArg> wuRead;
  64. CachedOutputMetaData recordSize;
  65. };
  66. IHThorDiskReadArg * createWorkUnitReadArg(const char * filename, IHThorWorkunitReadArg * wuRead)
  67. {
  68. return new DiskWorkUnitReadArg(filename, wuRead);
  69. }