Commit b3b02104 authored by Olivier Bertrand's avatar Olivier Bertrand

- Prepar using indexes in MAP mode (not used yet)

modified:
  storage/connect/tabdos.cpp
  storage/connect/xindex.cpp
  storage/connect/xindex.h
parent f60b5672
...@@ -554,9 +554,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) ...@@ -554,9 +554,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
if (!x->Make(g, sxp)) { if (!x->Make(g, sxp)) {
// Retreive define values from the index // Retreive define values from the index
xdp->SetMaxSame(x->GetMaxSame()); xdp->SetMaxSame(x->GetMaxSame());
// xdp->SetOffset(x->GetDefoff()); // xdp->SetSize(x->GetSize());
// xdp->SetOffhigh(x->GetDefhigh());
xdp->SetSize(x->GetSize());
// store KXYCOL Mxs in KPARTDEF Mxsame // store KXYCOL Mxs in KPARTDEF Mxsame
xdp->SetMxsame(x); xdp->SetMxsame(x);
...@@ -565,7 +563,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) ...@@ -565,7 +563,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
printf("Make done...\n"); printf("Make done...\n");
#endif // TRACE #endif // TRACE
if (x->GetSize() > 0) // if (x->GetSize() > 0)
sxp = xdp; sxp = xdp;
xdp->SetInvalid(false); xdp->SetInvalid(false);
......
/***************** Xindex C++ Class Xindex Code (.CPP) *****************/ /***************** Xindex C++ Class Xindex Code (.CPP) *****************/
/* Name: XINDEX.CPP Version 2.7 */ /* Name: XINDEX.CPP Version 2.8 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2013 */
/* */ /* */
/* This file contains the class XINDEX implementation code. */ /* This file contains the class XINDEX implementation code. */
/***********************************************************************/ /***********************************************************************/
...@@ -112,7 +112,7 @@ INDEXDEF::INDEXDEF(char *name, bool uniq, int n) ...@@ -112,7 +112,7 @@ INDEXDEF::INDEXDEF(char *name, bool uniq, int n)
ID = n; ID = n;
//Offset = 0; //Offset = 0;
//Offhigh = 0; //Offhigh = 0;
Size = 0; //Size = 0;
MaxSame = 1; MaxSame = 1;
} // end of INDEXDEF constructor } // end of INDEXDEF constructor
...@@ -212,7 +212,7 @@ XINDEX::XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp, int k) ...@@ -212,7 +212,7 @@ XINDEX::XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp, int k)
Incr = 0; Incr = 0;
//Defoff = xdp->GetOffset(); //Defoff = xdp->GetOffset();
//Defhigh = xdp->GetOffhigh(); //Defhigh = xdp->GetOffhigh();
Size = xdp->GetSize(); //Size = xdp->GetSize();
MaxSame = xdp->GetMaxSame(); MaxSame = xdp->GetMaxSame();
} // end of XINDEX constructor } // end of XINDEX constructor
...@@ -283,16 +283,13 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) ...@@ -283,16 +283,13 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
/* Table can be accessed through an index. */ /* Table can be accessed through an index. */
/*********************************************************************/ /*********************************************************************/
int k, rc = RC_OK; int k, rc = RC_OK;
int *bof, i, j, n, ndf, nkey; int *bof, i, j, n, ndf, nkey;
PKPDEF kdfp = Xdp->GetToKeyParts(); PKPDEF kdfp = Xdp->GetToKeyParts();
bool brc = true; bool brc = true;
PCOL colp; PCOL colp;
PXCOL kp, prev = NULL, kcp = NULL; PXCOL kp, prev = NULL, kcp = NULL;
PDBUSER dup = (PDBUSER)g->Activityp->Aptr; PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
Defoff = 0;
Size = 0; // Void index
/*********************************************************************/ /*********************************************************************/
/* Allocate the storage that will contain the keys and the file */ /* Allocate the storage that will contain the keys and the file */
/* positions corresponding to them. */ /* positions corresponding to them. */
...@@ -704,7 +701,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -704,7 +701,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
char *ftype; char *ftype;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int n[NZ], nof = (Mul) ? (Ndif + 1) : 0; int n[NZ], nof = (Mul) ? (Ndif + 1) : 0;
int id = -1; int id = -1, size = 0;
bool sep, rc = false; bool sep, rc = false;
PXCOL kcp = To_KeyCol; PXCOL kcp = To_KeyCol;
PDOSDEF defp = (PDOSDEF)Tdbp->To_Def; PDOSDEF defp = (PDOSDEF)Tdbp->To_Def;
...@@ -754,13 +751,6 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -754,13 +751,6 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
if (!Ndif) if (!Ndif)
goto end; // Void index goto end; // Void index
// Defoff is the start of the definition in the index file
//X->GetOff(Defoff, Defhigh, sxp);
#if defined(TRACE)
printf("Defoff=%d Defhigh=%d\n", Defoff, Defhigh);
#endif // TRACE
/*********************************************************************/ /*********************************************************************/
/* Write the index values on the index file. */ /* Write the index values on the index file. */
/*********************************************************************/ /*********************************************************************/
...@@ -777,16 +767,16 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -777,16 +767,16 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
ID, Nk, nof, Num_K, Incr, Nblk, Sblk); ID, Nk, nof, Num_K, Incr, Nblk, Sblk);
#endif // TRACE #endif // TRACE
Size = X->Write(g, n, NZ, sizeof(int), rc); size = X->Write(g, n, NZ, sizeof(int), rc);
dup->ProgCur = 1; dup->ProgCur = 1;
if (Mul) // Write the offset array if (Mul) // Write the offset array
Size += X->Write(g, Pof, nof, sizeof(int), rc); size += X->Write(g, Pof, nof, sizeof(int), rc);
dup->ProgCur = 5; dup->ProgCur = 5;
if (!Incr) // Write the record position array(s) if (!Incr) // Write the record position array(s)
Size += X->Write(g, To_Rec, Num_K, sizeof(int), rc); size += X->Write(g, To_Rec, Num_K, sizeof(int), rc);
dup->ProgCur = 15; dup->ProgCur = 15;
...@@ -797,19 +787,19 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -797,19 +787,19 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
n[3] = kcp->Klen; // To be checked later n[3] = kcp->Klen; // To be checked later
n[4] = kcp->Type; // To be checked later n[4] = kcp->Type; // To be checked later
Size += X->Write(g, n, NW, sizeof(int), rc); size += X->Write(g, n, NW, sizeof(int), rc);
dup->ProgCur += 1; dup->ProgCur += 1;
if (n[2]) if (n[2])
Size += X->Write(g, kcp->To_Bkeys, Nblk, kcp->Klen, rc); size += X->Write(g, kcp->To_Bkeys, Nblk, kcp->Klen, rc);
dup->ProgCur += 5; dup->ProgCur += 5;
Size += X->Write(g, kcp->To_Keys, n[0], kcp->Klen, rc); size += X->Write(g, kcp->To_Keys, n[0], kcp->Klen, rc);
dup->ProgCur += 5; dup->ProgCur += 5;
if (n[1]) if (n[1])
Size += X->Write(g, kcp->Kof, n[1], sizeof(int), rc); size += X->Write(g, kcp->Kof, n[1], sizeof(int), rc);
dup->ProgCur += 5; dup->ProgCur += 5;
} // endfor kcp } // endfor kcp
...@@ -1078,7 +1068,7 @@ bool XINDEX::Init(PGLOBAL g) ...@@ -1078,7 +1068,7 @@ bool XINDEX::Init(PGLOBAL g)
const char *ftype; const char *ftype;
BYTE *mbase; BYTE *mbase;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int *nv, k, n; int *nv, k, n, id = -1;
bool estim; bool estim;
PCOL colp; PCOL colp;
PXCOL prev = NULL, kcp = NULL; PXCOL prev = NULL, kcp = NULL;
...@@ -1138,8 +1128,10 @@ bool XINDEX::Init(PGLOBAL g) ...@@ -1138,8 +1128,10 @@ bool XINDEX::Init(PGLOBAL g)
_splitpath(defp->GetOfn(), drive, direc, fname, NULL); _splitpath(defp->GetOfn(), drive, direc, fname, NULL);
strcat(strcat(fname, "_"), Xdp->GetName()); strcat(strcat(fname, "_"), Xdp->GetName());
_makepath(fn, drive, direc, fname, ftype); _makepath(fn, drive, direc, fname, ftype);
} else } else {
id = ID;
strcat(PlugRemoveType(fn, strcpy(fn, defp->GetOfn())), ftype); strcat(PlugRemoveType(fn, strcpy(fn, defp->GetOfn())), ftype);
} // endif SepIndex
PlugSetPath(fn, fn, Tdbp->GetPath()); PlugSetPath(fn, fn, Tdbp->GetPath());
...@@ -1150,9 +1142,17 @@ bool XINDEX::Init(PGLOBAL g) ...@@ -1150,9 +1142,17 @@ bool XINDEX::Init(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
/* Get a view on the part of the index file containing this index. */ /* Get a view on the part of the index file containing this index. */
/*********************************************************************/ /*********************************************************************/
if (!(mbase = (BYTE*)X->FileView(g, fn, Defoff, Defhigh, Size))) if (!(mbase = (BYTE*)X->FileView(g, fn)))
goto err; goto err;
if (id >= 0) {
// Get offset from the header
IOFF *noff = (IOFF*)mbase;
// Position the memory base at the offset of this index
mbase += noff[id].Low;
} // endif id
// Now start the mapping process. // Now start the mapping process.
nv = (int*)mbase; nv = (int*)mbase;
mbase += NZ * sizeof(int); mbase += NZ * sizeof(int);
...@@ -2152,24 +2152,8 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2152,24 +2152,8 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return false; return false;
} // end of Open } // end of Open
#if 0
/***********************************************************************/ /***********************************************************************/
/* Tell were we are in the index file. */ /* Move into an index file. */
/***********************************************************************/
bool XFILE::GetOff(int& low, int& high, PIXDEF sxp)
{
if (sxp) {
low = sxp->GetOffset() + sxp->GetSize();
high = 0;
} else
low = high = 0;
return false;
} // end of GetOff
#endif // 0
/***********************************************************************/
/* Tell were we are in a huge file. */
/***********************************************************************/ /***********************************************************************/
bool XFILE::Seek(PGLOBAL g, int low, int high, int origin) bool XFILE::Seek(PGLOBAL g, int low, int high, int origin)
{ {
...@@ -2252,121 +2236,15 @@ void XFILE::Close(void) ...@@ -2252,121 +2236,15 @@ void XFILE::Close(void)
} // end of Close } // end of Close
#if defined(XMAP) #if defined(XMAP)
#if defined(WIN32)
/***********************************************************************/
/* Return a pointer to the segment at the given offset and size. */
/***********************************************************************/
void *XFILE::FileView(PGLOBAL g, char *fn, int loff, int hoff, int size)
{
SYSTEM_INFO SysInfo; // system information; used to get the granularity
char *pData; // pointer to the data
int iViewDelta; // the offset into the view where the data shows up
HANDLE hMapFile; // handle for the file's memory-mapped region
DWORD offset; // Where to start in the index file
DWORD FileMapSize; // size of the file mapping
DWORD FileMapStart; // where in the file to start the file map view
DWORD Granularity; // system allocation granularity
DWORD MapViewSize; // the size of the view
if (hoff) {
strcpy(g->Message, MSG(HI_OFFSET_ERR));
return NULL;
} // endf hoff
// Open the file in mode read only
Hfile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (Hfile == INVALID_HANDLE_VALUE) {
char buf[512];
DWORD rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_READ, fn);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
strcat(g->Message, buf);
return NULL;
} // endif Hfile
// Get the system allocation granularity.
GetSystemInfo(&SysInfo);
Granularity = SysInfo.dwAllocationGranularity;
// The offset is a 64 byte integer low part
offset = loff;
// To calculate where to start the file mapping, round down the
// offset of the data into the file to the nearest multiple of the
// system allocation granularity.
FileMapStart = (offset / Granularity) * Granularity;
// Calculate the size of the file mapping view.
MapViewSize = offset % Granularity + (DWORD)size;
// How large will the file-mapping object be?
FileMapSize = offset + (DWORD)size;
// The data of interest isn't at the beginning of the
// view, so determine how far into the view to set the pointer.
iViewDelta = (int)(offset - FileMapStart);
// Check that the index file is more than large enough
if (GetFileSize(Hfile, NULL) < FileMapSize) {
strcpy(g->Message, MSG(XFILE_TOO_SMALL));
return NULL;
} // endif FileSize
// Create a file-mapping object for the file.
hMapFile = CreateFileMapping( Hfile, // current file handle
NULL, // default security
PAGE_READONLY, // permission
0, // size, high
FileMapSize, // size, low
NULL); // name
if (hMapFile == NULL) {
sprintf(g->Message, MSG(HANDLE_IS_NULL), "hMapFile", GetLastError() );
return NULL;
} // endif hMapFile
// Map the view.
ViewBase = MapViewOfFile(hMapFile, // handle to mapping object
FILE_MAP_READ, // access mode
0, // high-order 32 bits of file offset
FileMapStart, // low-order 32 bits of file offset
MapViewSize); // number of bytes to map
if (!ViewBase) {
sprintf(g->Message, MSG(HANDLE_IS_NULL), "ViewBase", GetLastError());
return NULL;
} // endif ViewBase
// Calculate the pointer to the data.
pData = (char *)ViewBase + iViewDelta;
// close the file-mapping object
if (!CloseHandle(hMapFile))
sprintf(g->Message, MSG(MAP_OBJ_ERR), GetLastError());
// close the file itself
if (!CloseHandle(Hfile))
sprintf(g->Message, MSG(FILE_CLOSE_ERR), GetLastError());
else
Hfile = INVALID_HANDLE_VALUE;
return pData;
} // end of FileView
#else // not WIN32
/*********************************************************************/ /*********************************************************************/
/* Map the entire index. */ /* Map the entire index file. */
/*********************************************************************/ /*********************************************************************/
void *XFILE::FileView(PGLOBAL g, char *fn, int loff, int hoff, int size) void *XFILE::FileView(PGLOBAL g, char *fn)
{ {
HANDLE h; HANDLE h;
Mmp = (MMP)PlugSubAlloc(g, NULL, sizeof(MEMMAP)); Mmp = (MMP)PlugSubAlloc(g, NULL, sizeof(MEMMAP));
h = CreateFileMap(g, filename, Mmp, MODE_READ, false); h = CreateFileMap(g, fn, Mmp, MODE_READ, false);
if (h == INVALID_HANDLE_VALUE || (!Mmp->lenH && !Mmp->lenL)) { if (h == INVALID_HANDLE_VALUE || (!Mmp->lenH && !Mmp->lenL)) {
if (!(*g->Message)) if (!(*g->Message))
...@@ -2379,7 +2257,6 @@ void *XFILE::FileView(PGLOBAL g, char *fn, int loff, int hoff, int size) ...@@ -2379,7 +2257,6 @@ void *XFILE::FileView(PGLOBAL g, char *fn, int loff, int hoff, int size)
CloseFileHandle(h); // Not used anymore CloseFileHandle(h); // Not used anymore
return Mmp->memory; return Mmp->memory;
} // end of FileView } // end of FileView
#endif // not WIN32
#endif // XMAP #endif // XMAP
/* -------------------------- XHUGE Class --------------------------- */ /* -------------------------- XHUGE Class --------------------------- */
...@@ -2564,42 +2441,6 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2564,42 +2441,6 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return false; return false;
} // end of Open } // end of Open
#if 0
/***********************************************************************/
/* Get the offset of this index in the index file. */
/***********************************************************************/
bool XHUGE::GetOff(int& low, int& high, PIXDEF sxp)
{
if (!sxp) {
low = 0;
high = 0;
return false;
} // endif sxp
#if defined(WIN32)
LARGE_INTEGER ln;
ln.LowPart = sxp->GetOffset();
ln.HighPart = sxp->GetOffhigh();
ln.QuadPart += (LONGLONG)sxp->GetSize();
low = ln.LowPart;
high = (int)ln.HighPart;
#else // UNIX
#define G4 ((off64_t)0x100 * (off64_t)0x1000000)
#if defined(TRACE)
printf("in GetOff...\n");
#endif // TRACE
off64_t pos;
pos = (off64_t)sxp->GetOffset() + (off64_t)sxp->GetOffhigh() * G4;
pos += (off64_t)sxp->GetSize();
low = (int)(pos % G4);
high = (int)(pos / G4);
#endif // UNIX
return false;
} // end of GetOff
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Go to position in a huge file. */ /* Go to position in a huge file. */
/***********************************************************************/ /***********************************************************************/
...@@ -2755,111 +2596,14 @@ void XHUGE::Close(char *fn, int id) ...@@ -2755,111 +2596,14 @@ void XHUGE::Close(char *fn, int id)
} // end of Close } // end of Close
#if defined(XMAP) #if defined(XMAP)
#if defined(WIN32)
/***********************************************************************/
/* Return a pointer to the segment at the given offset and size. */
/***********************************************************************/
void *XHUGE::FileView(PGLOBAL g, char *fn, int loff, int hoff, int size)
{
SYSTEM_INFO SysInfo; // system information; used to get the granularity
char *pData; // pointer to the data
int iViewDelta; // the offset into the view where the data shows up
HANDLE hMapFile; // handle for the file's memory-mapped region
LARGE_INTEGER lint; // a utility holder
__int64 offset; // Where to start in the index file
__int64 FileMapSize; // size of the file mapping
__int64 FileMapStart; // where in the file to start the file map view
__int64 Granularity; // system allocation granularity
DWORD MapViewSize; // the size of the view
// Open the file in mode read only
if (Open(g, fn, MODE_READ))
return NULL;
// Get the system allocation granularity.
GetSystemInfo(&SysInfo);
Granularity = (__int64)SysInfo.dwAllocationGranularity;
// Calculate the offset as a 64 byte integer
lint.LowPart = loff;
lint.HighPart = hoff;
offset = lint.QuadPart;
// To calculate where to start the file mapping, round down the
// offset of the data into the file to the nearest multiple of the
// system allocation granularity.
FileMapStart = (offset / Granularity) * Granularity;
// Calculate the size of the file mapping view.
MapViewSize = (DWORD)(offset % Granularity) + (DWORD)size;
// How large will the file-mapping object be?
FileMapSize = offset + (__int64)size;
// The data of interest isn't at the beginning of the
// view, so determine how far into the view to set the pointer.
iViewDelta = (int)(offset - FileMapStart);
// Let the user know that the index file is more than large enough
lint.LowPart = GetFileSize(Hfile, (LPDWORD)&lint.HighPart);
// Prepare the low and high parts of the size.
lint.QuadPart = FileMapSize;
// Create a file-mapping object for the file.
hMapFile = CreateFileMapping( Hfile, // current file handle
NULL, // default security
PAGE_READONLY, // permission
lint.HighPart, // size, high
lint.LowPart, // size, low
NULL); // name
if (hMapFile == NULL) {
sprintf(g->Message, MSG(HANDLE_IS_NULL), "hMapFile", GetLastError());
return NULL;
} // endif hMapFile
// Prepare the low and high parts of the starting file offset.
lint.QuadPart = FileMapStart;
// Map the view.
ViewBase = MapViewOfFile(hMapFile, // handle to mapping object
FILE_MAP_READ, // access mode
lint.HighPart, // high-order 32 bits of file offset
lint.LowPart, // low-order 32 bits of file offset
MapViewSize); // number of bytes to map
if (!ViewBase) {
sprintf(g->Message, MSG(HANDLE_IS_NULL), "ViewBase", GetLastError());
return NULL;
} // endif ViewBase
// Calculate the pointer to the data.
pData = (char *)ViewBase + iViewDelta;
// close the file-mapping object
if (!CloseHandle(hMapFile))
sprintf(g->Message, MSG(MAP_OBJ_ERR), GetLastError());
// close the file itself
if (!CloseHandle(Hfile))
sprintf(g->Message, MSG(FILE_CLOSE_ERR), GetLastError());
else
Hfile = INVALID_HANDLE_VALUE;
return pData;
} // end of FileView
#else // not WIN32
/***********************************************************************/ /***********************************************************************/
/* Don't know whether this is possible for non Windows OS. */ /* Don't know whether this is possible for huge files. */
/***********************************************************************/ /***********************************************************************/
void *XHUGE::FileView(PGLOBAL g, char *fn, void *XHUGE::FileView(PGLOBAL g, char *fn)
int loff, int hoff, int size)
{ {
strcpy(g->Message, MSG(NO_PART_MAP)); strcpy(g->Message, MSG(NO_PART_MAP));
return NULL; return NULL;
} // end of FileView } // end of FileView
#endif // not WIN32
#endif // XMAP #endif // XMAP
/* -------------------------- XXROW Class --------------------------- */ /* -------------------------- XXROW Class --------------------------- */
......
/*************** Xindex H Declares Source Code File (.H) ***************/ /*************** Xindex H Declares Source Code File (.H) ***************/
/* Name: XINDEX.H Version 3.4 */ /* Name: XINDEX.H Version 3.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004 - 2012 */ /* (C) Copyright to the author Olivier BERTRAND 2004 - 2013 */
/* */ /* */
/* This file contains the XINDEX class declares. */ /* This file contains the XINDEX class declares. */
/***********************************************************************/ /***********************************************************************/
...@@ -11,12 +11,17 @@ ...@@ -11,12 +11,17 @@
#include "csort.h" /* Base class declares */ #include "csort.h" /* Base class declares */
#include "xtable.h" #include "xtable.h"
#include "valblk.h" #include "valblk.h"
#if defined(XMAP)
#include "maputil.h"
#endif // XMAP
enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */ enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */
TYPE_IDX_INDX = 4, /* Permanent standard index */ TYPE_IDX_INDX = 4, /* Permanent standard index */
TYPE_IDX_XROW = 5}; /* Permanent row index */ TYPE_IDX_XROW = 5}; /* Permanent row index */
typedef struct mem_map *MMP; #if defined(XMAP)
typedef MEMMAP *MMP;
#endif // XMAP
typedef class INDEXDEF *PIXDEF; typedef class INDEXDEF *PIXDEF;
typedef class KPARTDEF *PKPDEF; typedef class KPARTDEF *PKPDEF;
typedef class XINDEX *PXINDEX; typedef class XINDEX *PXINDEX;
...@@ -96,8 +101,8 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */ ...@@ -96,8 +101,8 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
//void SetOffset(int off) {Offset = off;} //void SetOffset(int off) {Offset = off;}
//int GetOffhigh(void) {return Offhigh;} //int GetOffhigh(void) {return Offhigh;}
//void SetOffhigh(int hof) {Offhigh = hof;} //void SetOffhigh(int hof) {Offhigh = hof;}
int GetSize(void) {return Size;} //int GetSize(void) {return Size;}
void SetSize(int size) {Size = size;} //void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p); bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false); PIXDEF GetIndexOf(PCOL colp, bool hd = false);
...@@ -119,7 +124,7 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */ ...@@ -119,7 +124,7 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
int ID; /* Index ID number */ int ID; /* Index ID number */
//int Offset; /* Offset in index file */ //int Offset; /* Offset in index file */
//int Offhigh; /* Offset high in big index file */ //int Offhigh; /* Offset high in big index file */
int Size; /* Size of index file */ //int Size; /* Size of index file */
int MaxSame; /* Max number of same values */ int MaxSame; /* Max number of same values */
}; // end of INDEXDEF }; // end of INDEXDEF
...@@ -246,9 +251,9 @@ class DllExport XINDEX : public XXBASE { ...@@ -246,9 +251,9 @@ class DllExport XINDEX : public XXBASE {
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;} virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;} virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
int GetDefoff(void) {return Defoff;} // int GetDefoff(void) {return Defoff;}
int GetDefhigh(void) {return Defhigh;} // int GetDefhigh(void) {return Defhigh;}
int GetSize(void) {return Size;} // int GetSize(void) {return Size;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
...@@ -281,9 +286,9 @@ class DllExport XINDEX : public XXBASE { ...@@ -281,9 +286,9 @@ class DllExport XINDEX : public XXBASE {
int Nk; // The number of indexed columns int Nk; // The number of indexed columns
int Nval; // The number of used columns int Nval; // The number of used columns
int Incr; // Increment of record position int Incr; // Increment of record position
int Defoff; // Offset of definition in index file //int Defoff; // Offset of definition in index file
int Defhigh; // High order of offset big value //int Defhigh; // High order of offset big value
int Size; // Size of definition in index file //int Size; // Size of definition in index file
int MaxSame; // Max number of same values int MaxSame; // Max number of same values
}; // end of class XINDEX }; // end of class XINDEX
...@@ -324,7 +329,6 @@ class DllExport XLOAD : public BLOCK { ...@@ -324,7 +329,6 @@ class DllExport XLOAD : public BLOCK {
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode) = 0; virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode) = 0;
//virtual bool GetOff(int& low, int& high, PIXDEF sxp) = 0;
virtual bool Seek(PGLOBAL g, int low, int high, int origin) = 0; virtual bool Seek(PGLOBAL g, int low, int high, int origin) = 0;
virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0; virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0;
virtual int Write(PGLOBAL g, void *buf, int n, virtual int Write(PGLOBAL g, void *buf, int n,
...@@ -332,8 +336,7 @@ class DllExport XLOAD : public BLOCK { ...@@ -332,8 +336,7 @@ class DllExport XLOAD : public BLOCK {
virtual void Close(char *fn, int id) = 0; virtual void Close(char *fn, int id) = 0;
virtual void Close(void); virtual void Close(void);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn) = 0;
int hoff, int size) = 0;
#endif // XMAP #endif // XMAP
protected: protected:
...@@ -359,22 +362,20 @@ class DllExport XFILE : public XLOAD { ...@@ -359,22 +362,20 @@ class DllExport XFILE : public XLOAD {
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode); virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode);
//virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin); virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size); virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc); virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
virtual void Close(char *fn, int id); virtual void Close(char *fn, int id);
virtual void Close(void); virtual void Close(void);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn);
int hoff, int size);
#endif // XMAP #endif // XMAP
protected: protected:
// Members // Members
FILE *Xfile; // Index stream file FILE *Xfile; // Index stream file
#if defined(XMAP) && !defined(WIN32) #if defined(XMAP)
MMP Mmp; // To UNIX mapped index file MMP Mmp; // To mapped index file
#endif // XMAP #endif // XMAP
}; // end of class XFILE }; // end of class XFILE
...@@ -388,14 +389,12 @@ class DllExport XHUGE : public XLOAD { ...@@ -388,14 +389,12 @@ class DllExport XHUGE : public XLOAD {
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode); virtual bool Open(PGLOBAL g, char *filename, int id, MODE mode);
//virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin); virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size); virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc); virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
virtual void Close(char *fn, int id); virtual void Close(char *fn, int id);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn);
int hoff, int size);
#endif // XMAP #endif // XMAP
protected: protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment