mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Make storing and sorting values using less memory allocation
(while doing indexed UPDATE/DELETE) modified: storage/connect/array.cpp storage/connect/filamtxt.cpp - Force unix like line endings modified: storage/connect/tabvct.h
This commit is contained in:
@@ -127,6 +127,10 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
|
|||||||
case TYPE_PCHAR:
|
case TYPE_PCHAR:
|
||||||
par->AddValue(g, parmp->Value);
|
par->AddValue(g, parmp->Value);
|
||||||
break;
|
break;
|
||||||
|
case TYPE_VOID:
|
||||||
|
// Integer stored inside pp->Value
|
||||||
|
par->AddValue(g, (int)parmp->Value);
|
||||||
|
break;
|
||||||
} // endswitch valtyp
|
} // endswitch valtyp
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -152,14 +156,17 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
|
|||||||
Xsize = -1;
|
Xsize = -1;
|
||||||
Len = 1;
|
Len = 1;
|
||||||
|
|
||||||
switch ((Type = type)) {
|
switch (type) {
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
Len = length;
|
Len = length;
|
||||||
break;
|
|
||||||
case TYPE_SHORT:
|
case TYPE_SHORT:
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
case TYPE_PCHAR:
|
case TYPE_PCHAR:
|
||||||
|
Type = type;
|
||||||
|
break;
|
||||||
|
case TYPE_VOID:
|
||||||
|
Type = TYPE_INT;
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case TYPE_TOKEN:
|
case TYPE_TOKEN:
|
||||||
|
@@ -282,14 +282,17 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
|
|||||||
PPARM pp = (PPARM)PlugSubAlloc(g, NULL, sizeof(PARM));
|
PPARM pp = (PPARM)PlugSubAlloc(g, NULL, sizeof(PARM));
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE_INT:
|
// case TYPE_INT:
|
||||||
pp->Value = PlugSubAlloc(g, NULL, sizeof(int));
|
// pp->Value = PlugSubAlloc(g, NULL, sizeof(int));
|
||||||
*((int*)pp->Value) = *((int*)val);
|
// *((int*)pp->Value) = *((int*)val);
|
||||||
break;
|
// break;
|
||||||
case TYPE_STRING:
|
case TYPE_VOID:
|
||||||
pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1);
|
pp->Value = (void*)*(int*)val;
|
||||||
strcpy((char*)pp->Value, (char*)val);
|
|
||||||
break;
|
break;
|
||||||
|
// case TYPE_STRING:
|
||||||
|
// pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1);
|
||||||
|
// strcpy((char*)pp->Value, (char*)val);
|
||||||
|
// break;
|
||||||
case TYPE_PCHAR:
|
case TYPE_PCHAR:
|
||||||
pp->Value = val;
|
pp->Value = val;
|
||||||
break;
|
break;
|
||||||
@@ -310,18 +313,22 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
|
|||||||
int TXTFAM::StoreValues(PGLOBAL g, bool upd)
|
int TXTFAM::StoreValues(PGLOBAL g, bool upd)
|
||||||
{
|
{
|
||||||
int pos = GetPos();
|
int pos = GetPos();
|
||||||
bool rc = AddListValue(g, TYPE_INT, &pos, &To_Pos);
|
bool rc = AddListValue(g, TYPE_VOID, &pos, &To_Pos);
|
||||||
|
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
pos = GetNextPos();
|
pos = GetNextPos();
|
||||||
rc = AddListValue(g, TYPE_INT, &pos, &To_Sos);
|
rc = AddListValue(g, TYPE_VOID, &pos, &To_Sos);
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
if (upd && !rc) {
|
if (upd && !rc) {
|
||||||
|
char *buf;
|
||||||
|
|
||||||
if (Tdbp->PrepareWriting(g))
|
if (Tdbp->PrepareWriting(g))
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
rc = AddListValue(g, TYPE_STRING, Tdbp->GetLine(), &To_Upd);
|
buf = (char*)PlugSubAlloc(g, NULL, strlen(Tdbp->GetLine()) + 1);
|
||||||
|
strcpy(buf, Tdbp->GetLine());
|
||||||
|
rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd);
|
||||||
} // endif upd
|
} // endif upd
|
||||||
|
|
||||||
return rc ? RC_FX : RC_OK;
|
return rc ? RC_FX : RC_OK;
|
||||||
|
@@ -1,124 +1,124 @@
|
|||||||
/*************** TabVct H Declares Source Code File (.H) ***************/
|
/*************** TabVct H Declares Source Code File (.H) ***************/
|
||||||
/* Name: TABVCT.H Version 3.4 */
|
/* Name: TABVCT.H Version 3.4 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
|
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the TDBVCT class declares. */
|
/* This file contains the TDBVCT class declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#ifndef __TABVCT__
|
#ifndef __TABVCT__
|
||||||
#define __TABVCT__
|
#define __TABVCT__
|
||||||
|
|
||||||
#include "tabfix.h"
|
#include "tabfix.h"
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
//#include <string.h.SUNWCCh>
|
//#include <string.h.SUNWCCh>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef class TDBVCT *PTDBVCT;
|
typedef class TDBVCT *PTDBVCT;
|
||||||
typedef class VCTCOL *PVCTCOL;
|
typedef class VCTCOL *PVCTCOL;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* VCT table. */
|
/* VCT table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class DllExport VCTDEF : public DOSDEF { /* Logical table description */
|
class DllExport VCTDEF : public DOSDEF { /* Logical table description */
|
||||||
friend class TDBVCT;
|
friend class TDBVCT;
|
||||||
friend class VCTFAM;
|
friend class VCTFAM;
|
||||||
friend class VECFAM;
|
friend class VECFAM;
|
||||||
friend class VMPFAM;
|
friend class VMPFAM;
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
VCTDEF(void) {Split = false; Estimate = Header = 0;}
|
VCTDEF(void) {Split = false; Estimate = Header = 0;}
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual const char *GetType(void) {return "VCT";}
|
virtual const char *GetType(void) {return "VCT";}
|
||||||
int GetEstimate(void) {return Estimate;}
|
int GetEstimate(void) {return Estimate;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
||||||
virtual PTDB GetTable(PGLOBAL g, MODE mode);
|
virtual PTDB GetTable(PGLOBAL g, MODE mode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int MakeFnPattern(char *fpat);
|
int MakeFnPattern(char *fpat);
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
bool Split; /* Columns in separate files */
|
bool Split; /* Columns in separate files */
|
||||||
int Estimate; /* Estimated maximum size of table */
|
int Estimate; /* Estimated maximum size of table */
|
||||||
int Header; /* 0: no, 1: separate, 2: in data file */
|
int Header; /* 0: no, 1: separate, 2: in data file */
|
||||||
}; // end of VCTDEF
|
}; // end of VCTDEF
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* This is the DOS/UNIX Access Method class declaration for files */
|
/* This is the DOS/UNIX Access Method class declaration for files */
|
||||||
/* in blocked vector format. In each block containing "Elements" */
|
/* in blocked vector format. In each block containing "Elements" */
|
||||||
/* records, values of each columns are consecutively stored (vector). */
|
/* records, values of each columns are consecutively stored (vector). */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class DllExport TDBVCT : public TDBFIX {
|
class DllExport TDBVCT : public TDBFIX {
|
||||||
friend class VCTCOL;
|
friend class VCTCOL;
|
||||||
friend class VCTFAM;
|
friend class VCTFAM;
|
||||||
friend class VCMFAM;
|
friend class VCMFAM;
|
||||||
friend class VECFAM;
|
friend class VECFAM;
|
||||||
friend class VMPFAM;
|
friend class VMPFAM;
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
TDBVCT(PVCTDEF tdp, PTXF txfp);
|
TDBVCT(PVCTDEF tdp, PTXF txfp);
|
||||||
TDBVCT(PGLOBAL g, PTDBVCT tdbp);
|
TDBVCT(PGLOBAL g, PTDBVCT tdbp);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
|
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
|
||||||
virtual PTDB Duplicate(PGLOBAL g)
|
virtual PTDB Duplicate(PGLOBAL g)
|
||||||
{return (PTDB)new(g) TDBVCT(g, this);}
|
{return (PTDB)new(g) TDBVCT(g, this);}
|
||||||
bool IsSplit(void) {return ((VCTDEF*)To_Def)->Split;}
|
bool IsSplit(void) {return ((VCTDEF*)To_Def)->Split;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual PTDB CopyOne(PTABS t);
|
virtual PTDB CopyOne(PTABS t);
|
||||||
virtual bool IsUsingTemp(PGLOBAL g);
|
virtual bool IsUsingTemp(PGLOBAL g);
|
||||||
|
|
||||||
// Database routines
|
// Database routines
|
||||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||||
virtual bool OpenDB(PGLOBAL g);
|
virtual bool OpenDB(PGLOBAL g);
|
||||||
virtual int ReadDB(PGLOBAL g);
|
virtual int ReadDB(PGLOBAL g);
|
||||||
virtual void CloseDB(PGLOBAL g);
|
virtual void CloseDB(PGLOBAL g);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
}; // end of class TDBVCT
|
}; // end of class TDBVCT
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Class VCTCOL: VCT access method column descriptor. */
|
/* Class VCTCOL: VCT access method column descriptor. */
|
||||||
/* This A.M. is used for file having column wise organization. */
|
/* This A.M. is used for file having column wise organization. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class DllExport VCTCOL : public DOSCOL {
|
class DllExport VCTCOL : public DOSCOL {
|
||||||
friend class TDBVCT;
|
friend class TDBVCT;
|
||||||
friend class VCTFAM;
|
friend class VCTFAM;
|
||||||
friend class VCMFAM;
|
friend class VCMFAM;
|
||||||
friend class VECFAM;
|
friend class VECFAM;
|
||||||
friend class VMPFAM;
|
friend class VMPFAM;
|
||||||
friend class BGVFAM;
|
friend class BGVFAM;
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
|
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
|
||||||
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
|
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) {return TYPE_AM_VCT;}
|
virtual int GetAmType(void) {return TYPE_AM_VCT;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void ReadColumn(PGLOBAL g);
|
virtual void ReadColumn(PGLOBAL g);
|
||||||
virtual void WriteColumn(PGLOBAL g);
|
virtual void WriteColumn(PGLOBAL g);
|
||||||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||||
virtual void SetOk(void);
|
virtual void SetOk(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ReadBlock(PGLOBAL g);
|
virtual void ReadBlock(PGLOBAL g);
|
||||||
virtual void WriteBlock(PGLOBAL g);
|
virtual void WriteBlock(PGLOBAL g);
|
||||||
|
|
||||||
VCTCOL(void) {} // Default constructor not to be used
|
VCTCOL(void) {} // Default constructor not to be used
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
PVBLK Blk; // Block buffer
|
PVBLK Blk; // Block buffer
|
||||||
int Clen; // Internal length in table
|
int Clen; // Internal length in table
|
||||||
int ColBlk; // Block pointed by column
|
int ColBlk; // Block pointed by column
|
||||||
int ColPos; // Last position read
|
int ColPos; // Last position read
|
||||||
int Modif; // Number of modified lines in block
|
int Modif; // Number of modified lines in block
|
||||||
}; // end of class VCTCOL
|
}; // end of class VCTCOL
|
||||||
|
|
||||||
#endif // __TABVCT__
|
#endif // __TABVCT__
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user