File: filamgz.h

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (170 lines) | stat: -rw-r--r-- 6,634 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*************** FilAmGz H Declares Source Code File (.H) **************/
/*  Name: FILAMGZ.H    Version 1.3                                     */
/*                                                                     */
/*  (C) Copyright to the author Olivier BERTRAND          2005-2016    */
/*                                                                     */
/*  This file contains the GZIP access method classes declares.        */
/***********************************************************************/
#ifndef __FILAMGZ_H
#define __FILAMGZ_H

#include "zlib.h"

typedef class GZFAM *PGZFAM;
typedef class ZBKFAM *PZBKFAM;
typedef class GZXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM;

/***********************************************************************/
/*  This is the access method class declaration for not optimized      */
/*  variable record length files compressed using the gzip library     */
/*  functions. File is accessed record by record (row).                */
/***********************************************************************/
class DllExport GZFAM : public TXTFAM {
//  friend class DOSCOL;
 public:
  // Constructor
  GZFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
  GZFAM(PGZFAM txfp);

  // Implementation
  AMT  GetAmType(void) override {return TYPE_AM_GZ;}
  int  GetPos(void) override;
  int  GetNextPos(void) override;
  PTXF Duplicate(PGLOBAL g) override
                {return (PTXF)new(g) GZFAM(this);}

  // Methods
  void Reset(void) override;
  int  GetFileLength(PGLOBAL g) override;
  int  Cardinality(PGLOBAL g) override {return (g) ? -1 : 0;}
  int  MaxBlkSize(PGLOBAL g, int s) override {return s;}
  bool AllocateBuffer(PGLOBAL g) override;
  int  GetRowID(void) override;
  bool RecordPos(PGLOBAL g) override;
  bool SetPos(PGLOBAL g, int recpos) override;
  int  SkipRecord(PGLOBAL g, bool header) override;
  bool OpenTableFile(PGLOBAL g) override;
  int  ReadBuffer(PGLOBAL g) override;
  int  WriteBuffer(PGLOBAL g) override;
  int  DeleteRecords(PGLOBAL g, int irc) override;
  void CloseTableFile(PGLOBAL g, bool abort) override;
  void Rewind(void) override;

 protected:
          int  Zerror(PGLOBAL g);    // GZ error function

  // Members
  gzFile  Zfile;              // Points to GZ file structure
  z_off_t Zpos;               // Uncompressed file position
  }; // end of class GZFAM

/***********************************************************************/
/*  This is the access method class declaration for optimized variable */
/*  record length files compressed using the gzip library functions.   */
/*  The File is accessed by block (requires an opt file).              */
/***********************************************************************/
class DllExport ZBKFAM : public GZFAM {
 public:
  // Constructor
  ZBKFAM(PDOSDEF tdp);
  ZBKFAM(PZBKFAM txfp);

  // Implementation
  int  GetPos(void) override;
  int  GetNextPos(void) override {return 0;}
  PTXF Duplicate(PGLOBAL g) override
                {return (PTXF)new(g) ZBKFAM(this);}

  // Methods
  int  Cardinality(PGLOBAL g) override;
  int  MaxBlkSize(PGLOBAL g, int s) override;
  bool AllocateBuffer(PGLOBAL g) override;
  int  GetRowID(void) override;
  bool RecordPos(PGLOBAL g) override;
  int  SkipRecord(PGLOBAL g, bool header) override;
  int  ReadBuffer(PGLOBAL g) override;
  int  WriteBuffer(PGLOBAL g) override;
  int  DeleteRecords(PGLOBAL g, int irc) override;
  void CloseTableFile(PGLOBAL g, bool abort) override;
  void Rewind(void) override;

 protected:
  // Members
  char *CurLine;              // Position of current line in buffer
  char *NxtLine;              // Position of Next    line in buffer
  bool  Closing;              // True when closing on Insert
  }; // end of class ZBKFAM

/***********************************************************************/
/*  This is the access method class declaration for fixed record       */
/*  length files compressed using the gzip library functions.          */
/*  The file is always accessed by block.                              */
/***********************************************************************/
class DllExport GZXFAM : public ZBKFAM {
 public:
  // Constructor
  GZXFAM(PDOSDEF tdp);
  GZXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}

  // Implementation
  int  GetNextPos(void) override {return 0;}
  PTXF Duplicate(PGLOBAL g) override
                {return (PTXF)new(g) GZXFAM(this);}

  // Methods
  int  Cardinality(PGLOBAL g) override;
  bool AllocateBuffer(PGLOBAL g) override;
  int  ReadBuffer(PGLOBAL g) override;
  int  WriteBuffer(PGLOBAL g) override;

 protected:
  // No additional Members
  }; // end of class GZXFAM

/***********************************************************************/
/*  This is the DOS/UNIX Access Method class declaration for PlugDB    */
/*  fixed/variable files compressed using the zlib library functions.  */
/*  Physically these are written and read using the same technique     */
/*  than blocked variable files, only the contain of each block is     */
/*  compressed using the deflate zlib function. The purpose of this    */
/*  specific format is to have a fast mechanism for direct access of   */
/*  records so blocked optimization is fast and direct access (joins)  */
/*  is allowed. Note that the block length is written ahead of each    */
/*  block to enable reading when optimization file is not available.   */
/***********************************************************************/
class DllExport ZLBFAM : public BLKFAM {
 public:
  // Constructor
  ZLBFAM(PDOSDEF tdp);
  ZLBFAM(PZLBFAM txfp);

  // Implementation
  AMT  GetAmType(void) override {return TYPE_AM_ZLIB;}
  int  GetPos(void) override;
  int  GetNextPos(void) override;
  PTXF Duplicate(PGLOBAL g) override
                  {return (PTXF)new(g) ZLBFAM(this);}
  inline  void SetOptimized(bool b) {Optimized = b;}

  // Methods
  int  GetFileLength(PGLOBAL g) override;
  bool SetPos(PGLOBAL g, int recpos) override;
  bool AllocateBuffer(PGLOBAL g) override;
  int  ReadBuffer(PGLOBAL g) override;
  int  WriteBuffer(PGLOBAL g) override;
  void CloseTableFile(PGLOBAL g, bool abort) override;
  void Rewind(void) override;

 protected:
          bool WriteCompressedBuffer(PGLOBAL g);
          int  ReadCompressedBuffer(PGLOBAL g, void *rdbuf);

  // Members
  z_streamp Zstream;          // Compression/decompression stream
  Byte     *Zbuffer;          // Compressed block buffer
  int      *Zlenp;            // Pointer to block length
  bool      Optimized;        // true when opt file is available
  }; // end of class ZLBFAM

#endif // __FILAMGZ_H