Browse Source

* Set buffer size

Michaël Van Canneyt 3 years ago
parent
commit
e45b31ced5
2 changed files with 21 additions and 4 deletions
  1. 20 4
      packages/fcl-db/src/dbase/dbf.pas
  2. 1 0
      packages/fcl-db/src/export/fpdbfexport.pp

+ 20 - 4
packages/fcl-db/src/dbase/dbf.pas

@@ -208,7 +208,7 @@ type
     FOnIndexMissing: TDbfIndexMissingEvent;
     FOnIndexMissing: TDbfIndexMissingEvent;
     FOnCompareRecord: TNotifyEvent;
     FOnCompareRecord: TNotifyEvent;
     FOnCopyDateTimeAsString: TConvertFieldEvent;
     FOnCopyDateTimeAsString: TConvertFieldEvent;
-
+    FMyBufferSize : Cardinal;
     function GetIndexName: string;
     function GetIndexName: string;
     function GetVersion: string;
     function GetVersion: string;
     function GetPhysicalRecNo: Integer;
     function GetPhysicalRecNo: Integer;
@@ -250,7 +250,8 @@ type
     procedure SetRangeBuffer(LowRange: PChar; HighRange: PChar);
     procedure SetRangeBuffer(LowRange: PChar; HighRange: PChar);
 
 
   protected
   protected
-
+    function GetDefaultBufferCount : Cardinal; override;
+    procedure SetDefaultBufferCount(aValue : Cardinal); virtual; 
     { abstract methods }
     { abstract methods }
     function  AllocRecordBuffer: TRecordBuffer; override; {virtual abstract}
     function  AllocRecordBuffer: TRecordBuffer; override; {virtual abstract}
     procedure ClearCalcFields(Buffer: TRecordBuffer); override;
     procedure ClearCalcFields(Buffer: TRecordBuffer); override;
@@ -409,7 +410,7 @@ type
 {$ifndef SUPPORT_INITDEFSFROMFIELDS}
 {$ifndef SUPPORT_INITDEFSFROMFIELDS}
     procedure InitFieldDefsFromFields;
     procedure InitFieldDefsFromFields;
 {$endif}
 {$endif}
-
+    Property DefaultBufferCount : Cardinal Read GetDefaultBufferCount Write SetDefaultBufferCount;
     property AbsolutePath: string read FAbsolutePath;
     property AbsolutePath: string read FAbsolutePath;
     property DbfFieldDefs: TDbfFieldDefs read GetDbfFieldDefs;
     property DbfFieldDefs: TDbfFieldDefs read GetDbfFieldDefs;
     property PhysicalRecNo: Integer read GetPhysicalRecNo write SetPhysicalRecNo;
     property PhysicalRecNo: Integer read GetPhysicalRecNo write SetPhysicalRecNo;
@@ -660,6 +661,21 @@ begin
   end;
   end;
 end;
 end;
 
 
+function TDbf.GetDefaultBufferCount : Cardinal; 
+
+begin
+  Result:=fMyBufferSize;
+end;
+
+procedure TDbf.SetDefaultBufferCount(aValue : Cardinal); 
+
+begin
+  CheckInactive;
+  FMyBufferSize:=aValue;
+  if FMyBufferSize<2 then
+    FMyBufferSize:=2;
+end;
+
 //====================================================================
 //====================================================================
 // TDbf = TDataset Descendant.
 // TDbf = TDataset Descendant.
 //====================================================================
 //====================================================================
@@ -669,7 +685,7 @@ begin
 
 
   if DbfGlobals = nil then
   if DbfGlobals = nil then
     DbfGlobals := TDbfGlobals.Create;
     DbfGlobals := TDbfGlobals.Create;
-
+  FMyBufferSize:=inherited GetDefaultBufferCount;
   BookmarkSize := sizeof(TBookmarkData);
   BookmarkSize := sizeof(TBookmarkData);
   FIndexDefs := TDbfIndexDefs.Create(Self);
   FIndexDefs := TDbfIndexDefs.Create(Self);
   FMasterLink := TDbfMasterLink.Create(Self);
   FMasterLink := TDbfMasterLink.Create(Self);

+ 1 - 0
packages/fcl-db/src/export/fpdbfexport.pp

@@ -207,6 +207,7 @@ begin
   Inherited;
   Inherited;
   FDBF:=TDBF.Create(Self);
   FDBF:=TDBF.Create(Self);
   FDBF.TableName:=FFileName;
   FDBF.TableName:=FFileName;
+  FDBF.DefaultBufferCount:=2;
   FE:=FileExists(FFileName);
   FE:=FileExists(FFileName);
   If FAppendData and FE then
   If FAppendData and FE then
     FDBF.Open
     FDBF.Open