~pbms-core/pbms/5.11-beta

« back to all changes in this revision

Viewing changes to mybs/src/SystemTable_ms.h

  • Committer: barry_leslie
  • Date: 2008-09-12 14:22:01 UTC
  • Revision ID: barry_leslie-71db134102f081d5227c64cc38ca9d28e72a6c9f
Internal name changes from MyBS to PBMS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007 SNAP Innovation GmbH
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
2
2
 *
3
 
 * BLOB Streaming for MySQL
 
3
 * PrimeBase Media Stream for MySQL
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
28
28
 
29
29
/*
30
30
 
31
 
DROP TABLE IF EXISTS mybs_repository;
32
 
CREATE TABLE mybs_repository (
 
31
DROP TABLE IF EXISTS pbms_repository;
 
32
CREATE TABLE pbms_repository (
33
33
        Repository_id     INT COMMENT 'The reppository file number',
34
34
        Repo_blob_offset  BIGINT COMMENT 'The offset of the BLOB in the repository file',
35
35
        Blob_size         BIGINT COMMENT 'The size of the BLOB in bytes',
40
40
        Last_access_time  TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
41
41
        Content_type      CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
42
42
        Blob_data         LONGBLOB COMMENT 'The data of this BLOB'
43
 
) ENGINE=MyBS;
 
43
) ENGINE=PBMS;
44
44
 
45
45
        PRIMARY KEY (Repository_id, Repo_blob_offset)
46
46
 
47
 
DROP TABLE IF EXISTS mybs_reference;
48
 
CREATE TABLE mybs_reference (
 
47
DROP TABLE IF EXISTS pbms_reference;
 
48
CREATE TABLE pbms_reference (
49
49
        Table_name        CHAR(64) COMMENT 'The name of the referencing table',
50
50
        Blob_id           BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
51
51
        Column_name       CHAR(64) COMMENT 'The column name of the referencing field',
58
58
        Remove_in         INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
59
59
        Temp_log_id       INT COMMENT 'Temporary log number of the referencing deletion entry',
60
60
        Temp_log_offset   BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
61
 
) ENGINE=MyBS;
 
61
) ENGINE=PBMS;
62
62
 
63
63
        PRIMARY KEY (Table_name, Blob_id, Column_name, Condition)
64
64
*/
65
65
 
66
 
#ifndef __BSYSTEMTABLE_H__
67
 
#define __BSYSTEMTABLE_H__
 
66
#ifndef __SYSTEMTABLE_MS_H__
 
67
#define __SYSTEMTABLE_MS_H__
68
68
 
69
69
#include "CSMutex.h"
70
70
 
71
 
#include "BSDefs.h"
72
 
#include "BSRepository.h"
 
71
#include "Defs_ms.h"
 
72
#include "Repository_ms.h"
73
73
 
74
 
class BSSystemTableShare;
75
 
class BSDatabase;
 
74
class MSSystemTableShare;
 
75
class MSDatabase;
76
76
class CSDaemon;
77
 
class BSTempLogFile;
 
77
class MSTempLogFile;
78
78
 
79
 
class BSOpenSystemTable : public CSRefObject {
 
79
class MSOpenSystemTable : public CSRefObject {
80
80
public:
81
 
        BSSystemTableShare              *myShare;
 
81
        MSSystemTableShare              *myShare;
82
82
        TABLE                                   *mySQLTable;
83
83
 
84
 
        BSOpenSystemTable(BSSystemTableShare *share, TABLE *table);
85
 
        virtual ~BSOpenSystemTable();
 
84
        MSOpenSystemTable(MSSystemTableShare *share, TABLE *table);
 
85
        virtual ~MSOpenSystemTable();
86
86
 
87
87
        virtual void use() { }
88
88
        virtual void unuse() { }
95
95
private:
96
96
};
97
97
 
98
 
class BSRepositoryTable : public BSOpenSystemTable {
 
98
class MSRepositoryTable : public MSOpenSystemTable {
99
99
public:
100
 
        BSRepositoryTable(BSSystemTableShare *share, TABLE *table);
101
 
        virtual ~BSRepositoryTable();
 
100
        MSRepositoryTable(MSSystemTableShare *share, TABLE *table);
 
101
        virtual ~MSRepositoryTable();
102
102
 
103
103
        virtual void use();
104
104
        virtual void unuse();
108
108
        virtual void seqScanPos(csWord1 *pos);
109
109
        virtual void seqScanRead(csWord1 *pos, char *buf);
110
110
 
111
 
        friend class BSReferenceTable;
 
111
        friend class MSReferenceTable;
112
112
 
113
113
private:
114
114
        csWord4                 iRepoIndex;
115
115
        csWord8                 iRepoOffset;
116
116
        csWord8                 iRepoFileSize;
117
117
        CSDaemon                *iCompactor;
118
 
        BSRepoFile              *iRepoFile;
 
118
        MSRepoFile              *iRepoFile;
119
119
        CSStringBuffer  *iBlobBuffer;
120
120
 
121
121
        virtual bool returnRecord(char *buf);
122
122
        virtual bool returnSubRecord(char *buf);
123
 
        virtual bool returnRow(BSBlobHeadPtr blob, char *buf);
 
123
        virtual bool returnRow(MSBlobHeadPtr blob, char *buf);
124
124
};
125
125
 
126
 
typedef struct BSRefData {
 
126
typedef struct MSRefData {
127
127
        u_int                           rd_ref_count;
128
128
        csWord4                         rd_tab_id;
129
129
        csWord8                         rd_blob_id;
130
130
        csWord4                         rd_temp_log_id;
131
131
        csWord4                         rd_temp_log_offset;
132
132
        csWord2                         rd_col_index;
133
 
        MyBSEngineRefRec        rd_ref;
134
 
} BSRefDataRec, *BSRefDataPtr;
 
133
        PBMSEngineRefRec        rd_ref;
 
134
} MSRefDataRec, *MSRefDataPtr;
135
135
 
136
 
class BSReferenceTable : public BSRepositoryTable {
 
136
class MSReferenceTable : public MSRepositoryTable {
137
137
public:
138
 
        BSReferenceTable(BSSystemTableShare *share, TABLE *table);
139
 
        virtual ~BSReferenceTable();
 
138
        MSReferenceTable(MSSystemTableShare *share, TABLE *table);
 
139
        virtual ~MSReferenceTable();
140
140
 
141
141
        void unuse();
142
142
        void seqScanInit();
143
143
 
144
144
private:
145
 
        BSRefDataPtr    iRefDataList;
 
145
        MSRefDataPtr    iRefDataList;
146
146
        u_int                   iRefDataSize;
147
147
        u_int                   iRefDataUsed;
148
148
        u_int                   iRefDataPos;
150
150
        csWord8                 iRefBlobSize;
151
151
        csWord4                 iRefBlobRepo;
152
152
        csWord8                 iRefBlobOffset;
153
 
        BSOpenTable             *iRefOpenTable;
154
 
        BSTempLogFile   *iRefTempLog;
 
153
        MSOpenTable             *iRefOpenTable;
 
154
        MSTempLogFile   *iRefTempLog;
155
155
 
156
156
        virtual bool returnRecord(char *buf);
157
157
        virtual bool returnSubRecord(char *buf);
158
 
        virtual void returnRow(BSRefDataPtr ref_data, char *buf);
 
158
        virtual void returnRow(MSRefDataPtr ref_data, char *buf);
159
159
};
160
160
 
161
 
class BSSystemTableShare : public CSRefObject {
 
161
class MSSystemTableShare : public CSRefObject {
162
162
public:
163
163
        CSString                                *myTablePath;
164
164
        THR_LOCK                                myThrLock;
165
 
        BSDatabase                              *mySysDatabase;
 
165
        MSDatabase                              *mySysDatabase;
166
166
 
167
 
        BSSystemTableShare();
168
 
        ~BSSystemTableShare();
 
167
        MSSystemTableShare();
 
168
        ~MSSystemTableShare();
169
169
 
170
170
        /* Make this object sortable: */
171
171
        virtual CSObject *getKey();
180
180
        static void startUp();
181
181
        static void shutDown();
182
182
 
183
 
        static BSOpenSystemTable *openSystemTable(const char *table_path, TABLE *table);
184
 
        static void releaseSystemTable(BSOpenSystemTable *tab);
 
183
        static MSOpenSystemTable *openSystemTable(const char *table_path, TABLE *table);
 
184
        static void releaseSystemTable(MSOpenSystemTable *tab);
185
185
 
186
 
        static BSSystemTableShare *newTableShare(CSString *table_path);
 
186
        static MSSystemTableShare *newTableShare(CSString *table_path);
187
187
};
188
188
 
189
189
#endif