daftformat.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #ifndef DAFTFORMAT_HPP
  14. #define DAFTFORMAT_HPP
  15. #include "filecopy.hpp"
  16. #include "daft.hpp"
  17. #include "ftbase.ipp"
  18. #define DEFAULT_STD_BUFFER_SIZE 0x10000
  19. #define EFX_BLOCK_HEADER_TYPE unsigned
  20. #define EFX_BLOCK_HEADER_SIZE sizeof(EFX_BLOCK_HEADER_TYPE)
  21. #define VARIABLE_LENGTH_TYPE unsigned
  22. #define EXPECTED_VARIABLE_LENGTH 512 // NOt very criticial
  23. //---------------------------------------------------------------------------
  24. struct PartitionCursor
  25. {
  26. public:
  27. PartitionCursor(offset_t _inputOffset) { inputOffset = nextInputOffset = _inputOffset; outputOffset = 0; trimLength = 0; }
  28. offset_t inputOffset;
  29. offset_t nextInputOffset;
  30. offset_t outputOffset;
  31. offset_t trimLength;
  32. };
  33. struct TransformCursor
  34. {
  35. public:
  36. TransformCursor() { inputOffset = 0; }
  37. offset_t inputOffset;
  38. };
  39. interface IOutputProcessor;
  40. interface IFormatPartitioner : public IInterface
  41. {
  42. public:
  43. //Analysis
  44. virtual void calcPartitions(Semaphore * sem) = 0;
  45. virtual void getResults(PartitionPointArray & partition) = 0;
  46. virtual void setPartitionRange(offset_t _totalSize, offset_t _thisOffset, offset_t _thisSize, unsigned _thisHeaderSize, unsigned _numParts) = 0;
  47. virtual void setSource(unsigned _whichInput, const RemoteFilename & _fullPath, bool compressedInput, const char *decryptKey) = 0;
  48. virtual void setTarget(IOutputProcessor * _target) = 0;
  49. virtual void setRecordStructurePresent(bool _recordStructurePresent) = 0;
  50. virtual void getRecordStructure(StringBuffer & _recordStructure) = 0;
  51. virtual void setAbort(IAbortRequestCallback * _abort) = 0;
  52. };
  53. interface IFormatProcessor : public IFormatPartitioner
  54. {
  55. virtual void setSource(unsigned _whichInput, const RemoteFilename & _fullPath, bool compressedInput, const char *decryptKey) = 0;
  56. virtual void setTarget(IOutputProcessor * _target) = 0;
  57. //Processing.
  58. virtual void beginTransform(offset_t thisOffset, offset_t thisLength, TransformCursor & cursor) = 0;
  59. virtual void endTransform(TransformCursor & cursor) = 0;
  60. virtual crc32_t getInputCRC() = 0;
  61. virtual void setInputCRC(crc32_t value) = 0;
  62. virtual unsigned transformBlock(offset_t endOffset, TransformCursor & cursor) = 0;
  63. };
  64. interface IOutputProcessor : public IInterface
  65. {
  66. public:
  67. virtual offset_t getOutputOffset() = 0;
  68. virtual void setOutput(offset_t startOffset, IFileIOStream * out = NULL) = 0;
  69. virtual void updateOutputOffset(size32_t len, const byte * data) = 0;
  70. virtual void finishOutputOffset() = 0;
  71. virtual void outputRecord(size32_t len, const byte * data) = 0;
  72. virtual void finishOutputRecords() = 0;
  73. //Record processing
  74. // virtual void processRecord(size32_t len, byte * data, IFileIOStream * output);
  75. };
  76. typedef IArrayOf<IFormatProcessor> FormatProcessorArray;
  77. typedef IArrayOf<IFormatPartitioner> FormatPartitionerArray;
  78. extern DALIFT_API IFormatProcessor * createFormatProcessor(const FileFormat & srcFormat, const FileFormat & tgtFormat, bool calcOutput);
  79. extern DALIFT_API IOutputProcessor * createOutputProcessor(const FileFormat & format);
  80. extern DALIFT_API IFormatPartitioner * createFormatPartitioner(const SocketEndpoint & ep, const FileFormat & srcFormat, const FileFormat & tgtFormat, bool calcOutput, const char * slave, const char *wuid);
  81. #endif