thorread.hpp 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 __THORREAD_HPP_
  14. #define __THORREAD_HPP_
  15. #ifdef THORHELPER_EXPORTS
  16. #define THORHELPER_API DECL_EXPORT
  17. #else
  18. #define THORHELPER_API DECL_IMPORT
  19. #endif
  20. #include "jrowstream.hpp"
  21. #include "rtlkey.hpp"
  22. //The following is constant for the life of a disk read activity
  23. interface IDiskReadOutputMapping : public IInterface
  24. {
  25. public:
  26. virtual unsigned getExpectedCrc() const = 0;
  27. virtual unsigned getProjectedCrc() const = 0;
  28. virtual IOutputMetaData * queryExpectedMeta() const = 0;
  29. virtual IOutputMetaData * queryProjectedMeta() const = 0;
  30. virtual RecordTranslationMode queryTranslationMode() const = 0;
  31. virtual bool matches(const IDiskReadOutputMapping * other) const = 0;
  32. };
  33. THORHELPER_API IDiskReadOutputMapping * createDiskReadOutputMapping(RecordTranslationMode mode, unsigned expectedCrc, IOutputMetaData & expected, unsigned projectedCrc, IOutputMetaData & projected);
  34. interface IDiskReadMapping : public IInterface
  35. {
  36. public:
  37. // Accessor functions to provide the basic information from the disk read
  38. virtual const char * queryFormat() const = 0;
  39. virtual unsigned getActualCrc() const = 0;
  40. virtual unsigned getExpectedCrc() const = 0;
  41. virtual unsigned getProjectedCrc() const = 0;
  42. virtual IOutputMetaData * queryActualMeta() const = 0;
  43. virtual IOutputMetaData * queryExpectedMeta() const = 0;
  44. virtual IOutputMetaData * queryProjectedMeta() const = 0;
  45. virtual const IPropertyTree * queryOptions() const = 0;
  46. virtual RecordTranslationMode queryTranslationMode() const = 0;
  47. virtual bool matches(const IDiskReadMapping * other) const = 0;
  48. virtual bool expectedMatchesProjected() const = 0;
  49. virtual const IDynamicTransform * queryTranslator() const = 0; // translates from actual to projected - null if no translation needed
  50. virtual const IKeyTranslator *queryKeyedTranslator() const = 0; // translates from expected to actual
  51. };
  52. THORHELPER_API IDiskReadMapping * createDiskReadMapping(RecordTranslationMode mode, const char * format, unsigned actualCrc, IOutputMetaData & actual, unsigned expectedCrc, IOutputMetaData & expected, unsigned projectedCrc, IOutputMetaData & projected, const IPropertyTree * options);
  53. typedef IConstArrayOf<IFieldFilter> FieldFilterArray;
  54. interface IRowReader : extends IInterface
  55. {
  56. public:
  57. // get the interface for reading streams of row. outputAllocator can be null if allocating next is not used.
  58. virtual IDiskRowStream * queryAllocatedRowStream(IEngineRowAllocator * _outputAllocator) = 0;
  59. };
  60. interface ITranslator;
  61. interface IDiskRowReader : extends IRowReader
  62. {
  63. public:
  64. virtual bool matches(const char * format, bool streamRemote, IDiskReadMapping * mapping) = 0;
  65. //Specify where the raw binary input for a particular file is coming from, together with its actual format.
  66. //Does this make sense, or should it be passed a filename? an actual format?
  67. //Needs to specify a filename rather than a ISerialStream so that the interface is consistent for local and remote
  68. virtual void clearInput() = 0;
  69. virtual bool setInputFile(const char * localFilename, const char * logicalFilename, unsigned partNumber, offset_t baseOffset, const IPropertyTree * meta, const FieldFilterArray & expectedFilter) = 0;
  70. virtual bool setInputFile(const RemoteFilename & filename, const char * logicalFilename, unsigned partNumber, offset_t baseOffset, const IPropertyTree * meta, const FieldFilterArray & expectedFilter) = 0;
  71. };
  72. //Create a row reader for a thor binary file. The expected, projected, actual and options never change. The file providing the data can change.
  73. extern THORHELPER_API IDiskRowReader * createLocalDiskReader(const char * format, IDiskReadMapping * mapping);
  74. extern THORHELPER_API IDiskRowReader * createRemoteDiskReader(const char * format, IDiskReadMapping * mapping);
  75. extern THORHELPER_API IDiskRowReader * createDiskReader(const char * format, bool streamRemote, IDiskReadMapping * mapping);
  76. #endif