thorfile.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.hpp"
  19. #include "rtlds_imp.hpp"
  20. #include "rtldynfield.hpp"
  21. #include "eclhelper_base.hpp"
  22. #include "thorcommon.ipp"
  23. void setExpiryTime(IPropertyTree & properties, unsigned expireDays)
  24. {
  25. properties.setPropInt("@expireDays", expireDays);
  26. }
  27. void setRtlFormat(IPropertyTree & properties, IOutputMetaData * meta)
  28. {
  29. if (meta && meta->queryTypeInfo())
  30. {
  31. MemoryBuffer out;
  32. if (dumpTypeInfo(out, meta->querySerializedDiskMeta()->queryTypeInfo()))
  33. properties.setPropBin("_rtlType", out.length(), out.toByteArray());
  34. }
  35. }
  36. class DiskWorkUnitReadArg : public CThorDiskReadArg
  37. {
  38. public:
  39. DiskWorkUnitReadArg(const char * _filename, IHThorWorkunitReadArg * _wuRead) : filename(_filename), wuRead(_wuRead)
  40. {
  41. recordSize.set(wuRead->queryOutputMeta());
  42. }
  43. virtual IOutputMetaData * queryOutputMeta() override
  44. {
  45. return wuRead->queryOutputMeta();
  46. }
  47. virtual const char * getFileName() override
  48. {
  49. return filename;
  50. }
  51. virtual IOutputMetaData * queryDiskRecordSize() override
  52. {
  53. return (IOutputMetaData *)recordSize;
  54. }
  55. virtual IOutputMetaData * queryProjectedDiskRecordSize() override
  56. {
  57. return (IOutputMetaData *)recordSize;
  58. }
  59. virtual unsigned getDiskFormatCrc() override
  60. {
  61. return 0;
  62. }
  63. virtual unsigned getProjectedFormatCrc() override
  64. {
  65. return 0;
  66. }
  67. virtual unsigned getFlags() override
  68. {
  69. return 0;
  70. }
  71. virtual size32_t transform(ARowBuilder & rowBuilder, const void * src) override
  72. {
  73. unsigned size = recordSize.getRecordSize(src);
  74. memcpy(rowBuilder.ensureCapacity(size, NULL), src, size);
  75. return size;
  76. }
  77. protected:
  78. StringAttr filename;
  79. Linked<IHThorWorkunitReadArg> wuRead;
  80. CachedOutputMetaData recordSize;
  81. };
  82. IHThorDiskReadArg * createWorkUnitReadArg(const char * filename, IHThorWorkunitReadArg * wuRead)
  83. {
  84. return new DiskWorkUnitReadArg(filename, wuRead);
  85. }