keydiff.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 _KEYDIFF_INCL
  14. #define _KEYDIFF_INCL
  15. #ifdef JHTREE_EXPORTS
  16. #define jhtree_decl DECL_EXPORT
  17. #else
  18. #define jhtree_decl DECL_IMPORT
  19. #endif
  20. #include "jstring.hpp"
  21. #include "jio.hpp"
  22. #include "keybuild.hpp"
  23. class IKeyDiffProgressCallback : public IInterface
  24. {
  25. public:
  26. virtual void handle(offset_t bytesRead) = 0;
  27. };
  28. class IKeyDiffGenerator : public IInterface
  29. {
  30. public:
  31. virtual void run() = 0;
  32. virtual void logStats() const = 0;
  33. virtual unsigned queryPatchCRC() = 0;
  34. virtual unsigned queryPatchFileCRC() = 0; // this should be actual crc of physical file generated
  35. virtual void setProgressCallback(IKeyDiffProgressCallback * callback, offset_t freq) = 0;
  36. };
  37. class INodeSender : public IInterface
  38. {
  39. public:
  40. virtual void send(CNodeInfo & info) = 0;
  41. };
  42. class INodeReceiver : public IInterface
  43. {
  44. public:
  45. virtual bool recv(CNodeInfo & info) = 0;
  46. virtual void stop() = 0;
  47. };
  48. class IKeyDiffApplicator : public IInterface
  49. {
  50. public:
  51. virtual void setTransmitTLK(INodeSender * sender) = 0;
  52. virtual void setReceiveTLK(INodeReceiver * receiver, unsigned numParts) = 0;
  53. virtual void run() = 0;
  54. virtual void getHeaderVersionInfo(unsigned short & versionMajor, unsigned short & versionMinor, unsigned short & minPatchVersionMajor, unsigned short & minPatchVersionMinor)= 0;
  55. virtual void getHeaderFileInfo(StringAttr & oldindex, StringAttr & newindex, bool & tlkInfo, StringAttr & newTLK) = 0;
  56. virtual bool compatibleVersions(StringBuffer & error) const = 0;
  57. virtual void setProgressCallback(IKeyDiffProgressCallback * callback, offset_t freq) = 0;
  58. };
  59. extern jhtree_decl IKeyDiffGenerator * createKeyDiffGenerator(char const * oldIndex, char const * newIndex, char const * patch, char const * newTLK, bool overwrite, unsigned compmode);
  60. extern jhtree_decl IKeyDiffApplicator * createKeyDiffApplicator(char const * patch, bool overwrite, bool ignoreTLK);
  61. extern jhtree_decl IKeyDiffApplicator * createKeyDiffApplicator(char const * patch, char const * oldIndex, char const * newIndex, char const * newTLK, bool overwrite, bool ignoreTLK);
  62. extern jhtree_decl StringBuffer & getKeyDiffVersion(StringBuffer & buff);
  63. extern jhtree_decl StringBuffer & getKeyDiffMinDiffVersionForPatch(StringBuffer & buff);
  64. extern jhtree_decl StringBuffer & getKeyDiffMinPatchVersionForDiff(StringBuffer & buff);
  65. // KeyReader and KeyWriter
  66. interface IPropertyTree;
  67. interface IKeyFileRowReader: extends IRowStream
  68. {
  69. virtual IPropertyTree *queryHeader()=0;
  70. };
  71. interface IKeyFileRowWriter: extends IRowWriter
  72. {
  73. };
  74. extern jhtree_decl IKeyFileRowReader *createKeyFileRowReader(const char *filename);
  75. extern jhtree_decl IKeyFileRowWriter *createKeyFileRowWriter(const char *filename,IPropertyTree *header, bool overwrite);
  76. #endif