1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/ustor/US_STD.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,693 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32std.h>
1.20 +#include <u32std.h>
1.21 +#include "D32REC.H"
1.22 +#include "D32STOR.H"
1.23 +#include <s32buf.h>
1.24 +//#include <s32crypt.h>
1.25 +#include <s32btree.h>
1.26 +#include <s32ucmp.h>
1.27 +//#include <e32hal.h>
1.28 +#include <e32math.h>
1.29 +#include "D32Assert.h"
1.30 +
1.31 +// classes defined
1.32 +class TDbStoreIndexStats;
1.33 +class CDbStoreIndexDef;
1.34 +class TRecordSize;
1.35 +class CDbStoreDef;
1.36 +class RClusterMap;
1.37 +class TClusterLinkCache;
1.38 +struct TClusterDes;
1.39 +class CCluster;
1.40 +class CClusterCache;
1.41 +class CDbStoreRecords;
1.42 +class CDbStoreBlobs;
1.43 +class CDbStoreIndex;
1.44 +class CDbStoreTable;
1.45 +class RDbStoreReadStream;
1.46 +class RDbStoreWriteStream;
1.47 +class MDbStreamFilter;
1.48 +class CDbStoreCompression;
1.49 +
1.50 +/**
1.51 +@internalComponent
1.52 +*/
1.53 +enum TStorePanic
1.54 + {
1.55 + EDbUnimplemented,
1.56 + EDbNoStore,
1.57 + EDbCannotSeek,
1.58 + EDbNotFixedFieldType,
1.59 + EDbWrongType
1.60 + };
1.61 +
1.62 +/**
1.63 +@internalComponent
1.64 +*/
1.65 +GLREF_C void Panic(TStorePanic aPanic);
1.66 +
1.67 +/**
1.68 +@internalComponent
1.69 +*/
1.70 +GLREF_D const TDbDriver KBuiltinDriver;
1.71 +
1.72 +/**
1.73 +@internalComponent
1.74 +*/
1.75 +const TUid KDbmsStoreDatabase={268435561};
1.76 +
1.77 +/**
1.78 +@internalComponent
1.79 +*/
1.80 +const TInt KDbStoreMaxRecordLength=0x200A; // v5.10 32 nullable longtext columns
1.81 +const TInt KClusterLimit=0x1000;
1.82 +const TInt KMaxClustering=16;
1.83 +const TInt KBlobRefSize=sizeof(TDbBlobId)+sizeof(TInt32);
1.84 +const TInt KMinInlineLimit=16;
1.85 +const TInt KMaxIndexKeySize=248;
1.86 +
1.87 +/**
1.88 +@internalComponent
1.89 +*/
1.90 +class TDbStoreIndexStats
1.91 + {
1.92 +public:
1.93 + /**
1.94 + @internalComponent
1.95 + */
1.96 + class TBound
1.97 + {
1.98 + public:
1.99 + inline void Set(TReal64 aBound);
1.100 + void Set(const TInt64& aBound);
1.101 + void Set(const TText8* aPtr,TInt aLen,const TTextOps& aConv);
1.102 + void Set(const TText16* aPtr,TInt aLen,const TTextOps& aConv);
1.103 + void Set(const TDbLookupKey::SColumn& aBound,const TTextOps& aConv);
1.104 + public:
1.105 + TReal64 iValue;
1.106 + };
1.107 + enum TType {EContinuous,EDiscrete};
1.108 +public:
1.109 + inline TDbStoreIndexStats();
1.110 +//
1.111 + void InternalizeL(RReadStream& aStream);
1.112 + void ExternalizeL(RWriteStream& aStream) const;
1.113 +//
1.114 + inline void Reset(TInt aCardinality=0);
1.115 + inline void Inc();
1.116 + inline void Dec();
1.117 + inline void Refresh(TType aType);
1.118 +//
1.119 + inline TBool IsValid() const;
1.120 + inline TBool NeedsRefresh() const;
1.121 + inline TInt Cardinality() const;
1.122 + TInt Span(TUint aInclusion,const TDbLookupKey* aLower,const TDbLookupKey* aUpper,const TTextOps& aConv) const;
1.123 +private:
1.124 + inline void Touch();
1.125 + TInt ReverseSpan(TUint aInclusion,const TDbLookupKey* aLower,const TDbLookupKey* aUpper,const TTextOps& aConv) const;
1.126 +private:
1.127 + enum {ERefreshFactor=3};
1.128 + enum {EInvalid=-1,ERefresh=0};
1.129 + enum {ERefreshShift=2+ERefreshFactor,EFlagsMask=(1<<ERefreshShift)-1};
1.130 + enum {EFlgDiscrete=0x1,EFlgClustering=0x2};
1.131 +private:
1.132 + TInt iCardinality;
1.133 + TInt iRefresh;
1.134 + TUint iFlags;
1.135 +public:
1.136 + TBound iLower;
1.137 + TBound iUpper;
1.138 + };
1.139 +
1.140 +/**
1.141 +@internalComponent
1.142 +*/
1.143 +class CDbStoreIndexDef : public CDbTableIndexDef
1.144 + {
1.145 +public:
1.146 + static CDbStoreIndexDef* NewLC(const TDesC& aName,const CDbKey& aKey,const HDbColumnSet& aColumns);
1.147 + static CDbStoreIndexDef* NewL(RReadStream& aStream);
1.148 + void ExternalizeL(RWriteStream& aStream) const;
1.149 + inline void SetTokenId(TStreamId anId);
1.150 + inline TStreamId TokenId() const;
1.151 +//
1.152 + static TInt KeySize(const TDbKeyCol& aKeyCol,const TDbColumnDef& aColumn);
1.153 + static void CheckSizeL(const CDbKey& aKey,const HDbColumnSet& aColSet);
1.154 +private:
1.155 + CDbStoreIndexDef();
1.156 + static CDbStoreIndexDef* NewLC(const TDesC& aName);
1.157 +private:
1.158 + TStreamId iTokenId;
1.159 +public:
1.160 + __MUTABLE TDbStoreIndexStats iStats; // cache the statistics here
1.161 + };
1.162 +
1.163 +/**
1.164 +@internalComponent
1.165 +*/
1.166 +class TRecordSize
1.167 + {
1.168 +public:
1.169 + TBool Set(const HDbColumnSet& aColumns);
1.170 + inline TInt Clustering() const;
1.171 + inline TInt InlineLimit() const;
1.172 +//
1.173 + static void CheckSizeL(const HDbColumnSet& aColumns);
1.174 + static TInt InlineLimit(const HDbColumnSet& aColumns);
1.175 +//
1.176 + static inline TInt FixedFieldSize(TDbColType aType);
1.177 +private:
1.178 + TInt iClustering;
1.179 + TInt iInlineLimit;
1.180 +private:
1.181 + static TUint8 const FieldSizes[];
1.182 + };
1.183 +
1.184 +/**
1.185 +@internalComponent
1.186 +*/
1.187 +NONSHARABLE_CLASS(CDbStoreDef) : public CDbTableDef
1.188 + {
1.189 +public:
1.190 + static CDbStoreDef* NewLC(const TDesC& aName,const CDbColSet& aColSet);
1.191 + static CDbStoreDef* NewL(RReadStream& aStream);
1.192 + void ExternalizeL(RWriteStream& aStream) const;
1.193 + inline void SetTokenId(TStreamId anId);
1.194 + inline TStreamId TokenId() const;
1.195 + inline TInt Clustering() const;
1.196 + inline TInt InlineLimit() const;
1.197 + void Changed();
1.198 +private:
1.199 + void AlteredColumnSetL(HDbColumnSet& aSet,const CDbColSet& aChange,const CDbColSet& aAdd);
1.200 +protected:
1.201 + CDbStoreDef();
1.202 +private:
1.203 + static CDbStoreDef* NewLC(const TDesC& aName,TInt aColumnCount);
1.204 +private:
1.205 + TStreamId iTokenId;
1.206 + TRecordSize iInfo;
1.207 + };
1.208 +
1.209 +/**
1.210 +@internalComponent
1.211 +*/
1.212 +typedef TUint32 TClusterId;
1.213 +
1.214 +/**
1.215 +@internalComponent
1.216 +*/
1.217 +const TClusterId KNullClusterId=0;
1.218 +
1.219 +/**
1.220 +@internalComponent
1.221 +*/
1.222 +inline TClusterId ClusterId(TDbRecordId aRecordId);
1.223 +inline TInt RecordIndex(TDbRecordId aRecordId);
1.224 +inline TDbRecordId RecordId(TClusterId aId,TInt aIndex);
1.225 +inline TClusterId ClusterId(TStreamId aStreamId);
1.226 +
1.227 +/**
1.228 +@internalComponent
1.229 +*/
1.230 +class RClusterMap
1.231 + {
1.232 +private:
1.233 + enum {EGranularity=8};
1.234 + class TIdPair
1.235 + {
1.236 + public:
1.237 + TClusterId iId;
1.238 + TClusterId iPreviousId;
1.239 + };
1.240 +public:
1.241 + enum {ESeparation=16};
1.242 +public:
1.243 + inline RClusterMap();
1.244 + inline void Close();
1.245 +//
1.246 + void ResetL(TClusterId aHeadCluster);
1.247 + inline void BindL(TClusterId aPrevious,TClusterId aCluster);
1.248 + void Drop(TClusterId aCluster,TClusterId aNext);
1.249 + TBool At(TClusterId aCluster,TClusterId& aPrevious);
1.250 + inline TClusterId LastBound() const;
1.251 + inline void Complete(TClusterId aLastCluster);
1.252 + inline TBool IsComplete() const;
1.253 +private:
1.254 + void AddL(TClusterId aCluster);
1.255 + void InsertL(TClusterId aCluster,TClusterId aPrevious);
1.256 + TIdPair* At(TClusterId aCluster);
1.257 +private:
1.258 + TIdPair* iMap;
1.259 + TInt iEntries;
1.260 + TInt iAlloc;
1.261 + TClusterId iLastBound;
1.262 + TClusterId iLastMapped;
1.263 + TInt iSkipped;
1.264 + TBool iComplete;
1.265 + };
1.266 +
1.267 +/**
1.268 +@internalComponent
1.269 +*/
1.270 +class TClusterLinkCache
1.271 + {
1.272 +public:
1.273 + inline void Invalidate();
1.274 + inline void Reset(TClusterId aBaseId);
1.275 + inline void Bind(TClusterId aPrevious,TClusterId aCluster,RClusterMap& aMap);
1.276 + void Add(const TClusterId* aFirst,const TClusterId* aLast);
1.277 + void Drop(TClusterId aCluster,TClusterId aNext);
1.278 + TBool Has(TClusterId aCluster) const;
1.279 + TBool At(TClusterId aCluster,TClusterId& aPrevious) const;
1.280 +private:
1.281 + void Add(TClusterId aCluster,RClusterMap& aMap);
1.282 +private:
1.283 + TClusterId iMap[RClusterMap::ESeparation+1];
1.284 + TClusterId* iEnd;
1.285 + };
1.286 +
1.287 +/**
1.288 +@internalComponent
1.289 +*/
1.290 +struct TClusterDes
1.291 + {
1.292 +public:
1.293 + void InternalizeL(RReadStream& aStream);
1.294 + void ExternalizeL(RWriteStream& aStream) const;
1.295 +public:
1.296 + TClusterId iNext;
1.297 + TUint32 iMembership;
1.298 + };
1.299 +
1.300 +/**
1.301 +@internalComponent
1.302 +*/
1.303 +NONSHARABLE_CLASS(CCluster) : public CBase
1.304 + {
1.305 + friend class CClusterCache;
1.306 +private:
1.307 + enum {EGranularity=0x200};
1.308 + enum {EExpandBuffer=0x40};
1.309 +public:
1.310 + /**
1.311 + @internalComponent
1.312 + */
1.313 + NONSHARABLE_CLASS(MAlter)
1.314 + {
1.315 + public:
1.316 + virtual TInt RecordExpansion(const TUint8* aRec,TInt aLength);
1.317 + virtual TUint8* AlterRecordL(TUint8* aWPtr,const TUint8* aRPtr,TInt aLength) =0;
1.318 + };
1.319 +public:
1.320 + static CCluster* NewL(CDbStoreDatabase& aDatabase);
1.321 + ~CCluster();
1.322 +//
1.323 + void FlushL();
1.324 + void Discard();
1.325 +//
1.326 + void Create(TClusterId aClusterId);
1.327 + void ReadL(TClusterId aCluster);
1.328 + void Relink(TClusterId aNextClusterId);
1.329 + void AlterL(MAlter& anAlterer);
1.330 +//
1.331 + TPtrC8 RecordL(TInt aIndex);
1.332 + TUint8* UpdateL(TInt aIndex,TInt aNewSize);
1.333 + TBool DeleteL(TInt aIndex);
1.334 + inline TBool IsFull() const;
1.335 +//
1.336 + inline TClusterId Id() const;
1.337 + inline const TClusterDes& Des() const;
1.338 +private:
1.339 + CCluster(CDbStoreDatabase& aDatabase);
1.340 +//
1.341 + TInt SetSizeL(TInt aSize);
1.342 + void AdjustMap(TUint8** aMapEntry,TInt aAdjust);
1.343 + void SetRecordL(TInt aIndex,TInt aNewSize);
1.344 + void AdjustL(TUint8** aMapEntry,TInt aAdjust,TUint8* aData);
1.345 +private:
1.346 + TDblQueLink iLink;
1.347 + CDbStoreDatabase& iDatabase;
1.348 + TInt iSize;
1.349 + TClusterId iCluster;
1.350 + TClusterDes iDes;
1.351 + TBool iModified;
1.352 + TUint8* iMap[KMaxClustering+1];
1.353 + };
1.354 +
1.355 +/**
1.356 +@internalComponent
1.357 +*/
1.358 +NONSHARABLE_CLASS(CClusterCache) : public CBase
1.359 + {
1.360 + #ifndef MAX_CLUSTER_CACHE_SIZE
1.361 + #define MAX_CLUSTER_CACHE_SIZE 8
1.362 + #else
1.363 + #if MAX_CLUSTER_CACHE_SIZE < 4
1.364 + #error "MAX_CLUSTER_CACHE_SIZE macro value can't be less than 4"
1.365 + #endif
1.366 + #endif
1.367 + enum {EMaxClusters=MAX_CLUSTER_CACHE_SIZE};
1.368 +public:
1.369 + static CClusterCache* NewL(CDbStoreDatabase& aDatabase);
1.370 + ~CClusterCache();
1.371 +//
1.372 + void FlushL();
1.373 + void Discard();
1.374 +//
1.375 + CCluster* Cluster(TClusterId aCluster);
1.376 + CCluster& ClusterL(TClusterId aCluster);
1.377 + CCluster& ClusterL();
1.378 +//
1.379 + inline CDbStoreDatabase& Database();
1.380 + inline CStreamStore& Store();
1.381 +private:
1.382 + inline CClusterCache(CDbStoreDatabase& aDatabase);
1.383 +//
1.384 + void Apply(void (*aFunc)(CCluster*));
1.385 + CCluster& AddClusterL();
1.386 + CCluster& NewClusterL();
1.387 + CCluster& Touch(CCluster& aCluster);
1.388 +private:
1.389 + CDbStoreDatabase& iDatabase;
1.390 + TClusterId iCachePlus1;
1.391 + TClusterId iCachePlus2;
1.392 + TUint8 iFollowOnHits;
1.393 + TUint8 iClusters;
1.394 + TDblQue<CCluster> iCache;
1.395 + };
1.396 +
1.397 +/**
1.398 +@internalComponent
1.399 +*/
1.400 +NONSHARABLE_CLASS(CDbStoreRecords) : public CDbRecordSpace
1.401 + {
1.402 +public:
1.403 + class TIteratorC;
1.404 + class CIter;
1.405 +public:
1.406 + static TStreamId CreateL(CClusterCache& aCache);
1.407 + static CDbStoreRecords* NewL(CClusterCache& aCache,const CDbStoreDef& aDef);
1.408 +//
1.409 + static TInt CardinalityL(CStreamStore& aStore,const CDbStoreDef& aDef);
1.410 +//
1.411 + TBool GotoL(TDbPosition aPosition,TIteratorC& anIterator);
1.412 + TBool GotoL(TDbRecordId aRecordId,TIteratorC& anIterator);
1.413 + TBool DeletedL(TDbPosition aPosition,TIteratorC& anIterator);
1.414 +//
1.415 + inline TClusterId Head() const;
1.416 + inline TInt Count() const;
1.417 + TInt DiscardL(TClusterId& aCluster);
1.418 + TClusterId AlterL(TClusterId aCluster,CCluster::MAlter& anAlterer);
1.419 + void DestroyL();
1.420 +// providing for CDbRecordSpace
1.421 + TBool ExistsL(TDbRecordId aRecordId);
1.422 + TPtrC8 ReadL(TDbRecordId aRecordId) const;
1.423 + TUint8* DoReplaceL(TDbRecordId aRecordId,TInt aRecordSize);
1.424 + TUint AutoIncrementL();
1.425 + TUint8* DoNewL(TInt aRecordSize);
1.426 + TDbRecordId AppendL();
1.427 + void DoEraseL(TDbRecordId aRecordId);
1.428 + CDbRecordIter* IteratorL();
1.429 + TBool RestoreL();
1.430 + void SynchL();
1.431 +private:
1.432 + CDbStoreRecords(CClusterCache& aCache);
1.433 + ~CDbStoreRecords();
1.434 +//
1.435 + TUint8* UpdateRecordL(TDbRecordId aRecordId,TInt aNewSize);
1.436 + void DesL(TClusterDes& aDes,TClusterId aCluster);
1.437 + void CompleteMapL();
1.438 + TClusterId NextClusterL(TClusterDes& aDes,TClusterId aCluster);
1.439 + TClusterId PreviousClusterL(TClusterDes& aDes,TClusterId aCluster);
1.440 + TBool LocateL(TClusterId aCluster);
1.441 +private:
1.442 + class TToken
1.443 + {
1.444 + public:
1.445 + void InternalizeL(RReadStream& aStream);
1.446 + void ExternalizeL(RWriteStream& aStream) const;
1.447 + public:
1.448 + TClusterId iHead;
1.449 + TDbRecordId iNext;
1.450 + TInt iCount;
1.451 + TUint iAutoIncrement;
1.452 + };
1.453 +private:
1.454 + CClusterCache& iCache;
1.455 + TStreamId iTokenId;
1.456 + TToken iToken;
1.457 + TInt iClustering;
1.458 + TClusterLinkCache iLinks;
1.459 + RClusterMap iMap;
1.460 + };
1.461 +
1.462 +/**
1.463 +@internalComponent
1.464 +*/
1.465 +NONSHARABLE_CLASS(CDbStoreBlobs) : public CDbBlobSpace
1.466 + {
1.467 +public:
1.468 + CDbStoreBlobs(CDbStoreDatabase& aDatabase,TInt aInlineLimit);
1.469 +//
1.470 + MStreamBuf* DoCreateL(TDbBlobId &aBlobId,TDbColType aType);
1.471 + MStreamBuf* ReadL(TDbBlobId aBlobId,TDbColType aType) const;
1.472 + void DoDeleteL(TDbBlobId aBlobId);
1.473 +private:
1.474 + CDbStoreDatabase& iDatabase;
1.475 + };
1.476 +
1.477 +/**
1.478 +@internalComponent
1.479 +*/
1.480 +NONSHARABLE_CLASS(CDbStoreIndex) : public CDbRecordIndex
1.481 + {
1.482 +public:
1.483 + class HKey;
1.484 + class HDupKey;
1.485 + class CIter;
1.486 + class CDiscarder;
1.487 + class CRecover;
1.488 + class CRepair;
1.489 +public:
1.490 + static CDbStoreIndex* NewL(CDbStoreDatabase& aDatabase,const CDbStoreIndexDef& aDef,const CDbTableDef& aTable);
1.491 + ~CDbStoreIndex();
1.492 +//
1.493 + static TStreamId CreateL(CDbStoreDatabase& aDatabase,const CDbStoreIndexDef& aDef);
1.494 + static TBool IsDamagedL(CDbStoreDatabase& aDatabase,const CDbStoreIndexDef& aDef);
1.495 +//
1.496 + inline HKey& Key() const;
1.497 + inline const TBtree& Tree() const;
1.498 + inline TInt Count() const;
1.499 + void RepairL();
1.500 + void DiscardL();
1.501 + void DestroyL();
1.502 +private:
1.503 + CDbStoreIndex(CDbStoreDatabase& aDatabase,const CDbStoreIndexDef& aDef);
1.504 +//
1.505 + void RefreshStatsL();
1.506 +// CDbTableIndex framework
1.507 + TFind FindL(TDbRecordId aRecordId,const RDbTableRow& aRow);
1.508 + TBool DoInsertL(TDbRecordId aRecordId,const RDbTableRow& aRow);
1.509 + void DoDeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow);
1.510 + CDbRecordIter* IteratorL(TUint aInclusion,const TDbLookupKey* aLowerBound,const TDbLookupKey* aUpperBound);
1.511 + TBool RestoreL();
1.512 + void AboutToModifyL();
1.513 + void SynchL();
1.514 +private:
1.515 + CDbStoreDatabase& iDatabase;
1.516 + TStreamId iTokenId;
1.517 + TBtree iTree;
1.518 + HKey* iKey;
1.519 + TBtreeInlineLeafOrg iLeafOrg;
1.520 + TBtreeInlineIndexOrg iIndexOrg;
1.521 + TDbStoreIndexStats& iStats;
1.522 + };
1.523 +
1.524 +/**
1.525 +@internalComponent
1.526 +*/
1.527 +NONSHARABLE_CLASS(CDbStoreIndex::CDiscarder) : public CDbTableDatabase::CStepper
1.528 + {
1.529 +public:
1.530 + CDiscarder();
1.531 + ~CDiscarder();
1.532 + TInt Open(CDbStoreIndex* anIndex);
1.533 +private:
1.534 + TInt StepL(TInt aStep);
1.535 +private:
1.536 + CDbStoreIndex* iIndex;
1.537 + };
1.538 +
1.539 +/**
1.540 +@internalComponent
1.541 +*/
1.542 +NONSHARABLE_CLASS(CDbStoreTable) : public CDbTable
1.543 + {
1.544 +public:
1.545 + class CDiscarder;
1.546 + class CAlter;
1.547 + class CCompressor;
1.548 + friend class CDiscarder;
1.549 + friend class CAlter;
1.550 + friend class CCompressor;
1.551 +public:
1.552 + CDbStoreTable(CDbStoreDatabase& aDatabase,const CDbTableDef& aDef);
1.553 +private:
1.554 + inline const CDbStoreDef& Def() const;
1.555 + inline CDbStoreDatabase& Database();
1.556 + inline CDbStoreRecords& StoreRecordsL();
1.557 +//
1.558 + TInt RowSize(const TUint8* aRec,TInt aLength);
1.559 + const TUint8* CopyToRow(TDbCell* aCell,TInt aSize,const TUint8* aRec);
1.560 + TUint8* AlterRecordL(TUint8* aWPtr,const TUint8* aRPtr,TInt aLength,TInt aInlineLimit);
1.561 +// providing for CDbTable framework
1.562 + TInt IndexSpanL(const CDbTableIndexDef& aIndex,TUint aInclusion,const TDbLookupKey* aLowerBound,const TDbLookupKey* aUpperBound);
1.563 + CDbRecordSpace* RecordSpaceL();
1.564 + CDbBlobSpace* BlobSpaceL();
1.565 + CDbRecordIndex* RecordIndexL(const CDbTableIndexDef& anIndex);
1.566 + void CopyToRowL(RDbRow& aRow,const TDesC8& aRecord);
1.567 + TInt RecordLength(const RDbRow& aRow);
1.568 + TInt OptimizedRowLength(const RDbRow& aRow);
1.569 + void CopyFromRow(TUint8* aRecord,const RDbRow& aRow);
1.570 + };
1.571 +
1.572 +/**
1.573 +@internalComponent
1.574 +*/
1.575 +NONSHARABLE_CLASS(CDbStoreTable::CDiscarder) : public CDbTableDatabase::CStepper, public CCluster::MAlter
1.576 + {
1.577 +private:
1.578 + enum {EDiscardClusters=32,EBlobDiscardClusters=2};
1.579 +public:
1.580 + CDiscarder();
1.581 + ~CDiscarder();
1.582 + TInt OpenL(CDbStoreTable* aTable);
1.583 +private:
1.584 + TInt StepL(TInt aStep);
1.585 + TUint8* AlterRecordL(TUint8* aWPtr,const TUint8* aRPtr,TInt aLength);
1.586 +private:
1.587 + CDbStoreTable* iTable;
1.588 + CDbStoreRecords* iRecords;
1.589 + TClusterId iCluster;
1.590 + RDbRow iRow;
1.591 + };
1.592 +
1.593 +/**
1.594 +@internalComponent
1.595 +*/
1.596 +NONSHARABLE_CLASS(CDbStoreTable::CAlter) : public CDbTableDatabase::CStepper, public CCluster::MAlter
1.597 + {
1.598 +public:
1.599 + CAlter();
1.600 + ~CAlter();
1.601 + void OpenL(CDbStoreTable* aTable,const HDbColumnSet& aNewSet);
1.602 +private:
1.603 + TUint8* AlterRecordL(TUint8* aWPtr,const TUint8* aRPtr,TInt aLength);
1.604 + TInt RecordExpansion(const TUint8* aRec,TInt aLength);
1.605 + TInt StepL(TInt aStep);
1.606 +private:
1.607 + TInt iExpansion;
1.608 + TInt iInlineLimit;
1.609 + CDbStoreTable* iTable;
1.610 + CDbStoreRecords* iRecords;
1.611 + TClusterId iCluster;
1.612 + TInt iStep;
1.613 + };
1.614 +
1.615 +/**
1.616 +@internalComponent
1.617 +*/
1.618 +class RDbStoreReadStream : public RStoreReadStream
1.619 + {
1.620 +public:
1.621 + enum TType {EMixed,EBinary,EText};
1.622 +public:
1.623 + inline RDbStoreReadStream(CDbStoreDatabase& aDatabase)
1.624 + :iDatabase(aDatabase)
1.625 + {}
1.626 + void FilterL(TType aType,TUint32 aInit);
1.627 +private:
1.628 + CDbStoreDatabase& iDatabase;
1.629 + };
1.630 +
1.631 +/**
1.632 +@internalComponent
1.633 +*/
1.634 +class RDbStoreWriteStream : public RStoreWriteStream
1.635 + {
1.636 +public:
1.637 + enum TType {EMixed,EBinary,EText};
1.638 +public:
1.639 + inline RDbStoreWriteStream(CDbStoreDatabase& aDatabase)
1.640 + :iDatabase(aDatabase)
1.641 + {}
1.642 + void FilterL(TType aType,TUint32 aInit);
1.643 +private:
1.644 + CDbStoreDatabase& iDatabase;
1.645 + };
1.646 +
1.647 +/**
1.648 +@internalComponent
1.649 +*/
1.650 +class MDbStreamFilter
1.651 + {
1.652 +public:
1.653 + virtual MStreamBuf* FilterL(MStreamBuf* aHost,TUint32 aInit,RDbStoreReadStream::TType aType) =0;
1.654 + virtual MStreamBuf* FilterL(MStreamBuf* aHost,TUint32 aInit,RDbStoreWriteStream::TType aType) =0;
1.655 + };
1.656 +
1.657 +
1.658 +/**
1.659 +@internalComponent
1.660 +*/
1.661 +NONSHARABLE_CLASS(CDbStoreCompression) : public CBase, public MDbStreamFilter
1.662 + {
1.663 +public:
1.664 + /**
1.665 + @internalComponent
1.666 + */
1.667 + class TEncoding
1.668 + {
1.669 + public:
1.670 + enum {ELiterals=256,ELengths=28,ESpecials=1,EDistances=44};
1.671 + enum {ELitLens=ELiterals+ELengths+ESpecials};
1.672 + enum {EEos=ELiterals+ELengths};
1.673 + public:
1.674 + TUint32 iLitLen[ELitLens];
1.675 + TUint32 iDistance[EDistances];
1.676 + };
1.677 +public:
1.678 + static CDbStoreCompression* NewL();
1.679 +//
1.680 + void EncodeL();
1.681 + inline void Inflate();
1.682 + void ExternalizeL(RWriteStream& aStream) const;
1.683 + void InternalizeL(RReadStream& aStream);
1.684 +// for MDbStreamFilter
1.685 + MStreamBuf* FilterL(MStreamBuf* aHost,TUint32 aInit,RDbStoreReadStream::TType aType);
1.686 + MStreamBuf* FilterL(MStreamBuf* aHost,TUint32 aInit,RDbStoreWriteStream::TType aType);
1.687 +private:
1.688 + inline CDbStoreCompression();
1.689 +private:
1.690 + enum TState {EAnalysis,EEncoding,EDecoding,EInflating};
1.691 +private:
1.692 + TState iState;
1.693 + TEncoding iEncoding[3];
1.694 + };
1.695 +
1.696 +#include "US_STD.INL"