Harbour Data Types and limits

Harbour Data Types and limits

 

Question :

The links you provided refers to CA-Clipper. So far I could not find any info for HB on what’s the biggest and smallest (precision) value a numeric  type can hold, etc.

Answer :

It was many times discussed on Harbour related forums.

In case of numeric values it’s the same as in Clipper and most of other languages – on platforms you are using it’s limited by IEEE758 double value specification.

The date ranges and internal representation is the same as in Clipper too. In conversions between strings and date values Harbour supports years in range 0-9999 but Clipper 1-2999.

Harbour has four data types unsupported by Clipper:

  • HASH ARRAYS
  • TIMESTAMPS
  • SYMBOLS
  • POINTERS

HASH ARRAYS are arrays which can be indexed by user defined values of different types (numbers, dates, timestamps, strings, pointers) For more information read “HASH ARRAYS” in doc/xhb-diff.txt.

TIMESTAMPS are datetime values which contain date and time in milliseconds (see “DATETIME/TIMESTAMP VALUES” in doc/xhb-diff.txt)

SYMBOLS are references to functions (procedures) or methods. (see SYMBOL ITEMS AND FUNCTION REFERENCES in doc/xhb-diff.txt)

POINTER items are defined by some subsystems and 3-rd party code at C level and usually they refers to some low level resources or memory addresses. In short words it’s type of handle returned to PRG level. Unlike numeric handles pointer item value is protected and cannot be changed by PRG code so they are much safer. In C code using pointer items it’s possible to verify if given pointer item was defined by the same subsystem and protect against wrong pointers. Finally C code author can bound with pointer item destructor which is executed automatically when variable is out of scope and can release resources allocated for given item.

Maximum size of strings and arrays is limited only by available memory (I will use “unlimited” in such case).

Maximum number of symbols in single module (compiled PRG file) is 65536. Maximum number of symbols registered in HVM from all modules and RDD subsystems is 65536. The maximum number of symbols reduces number of different names which can be used for function/procedure/alias/field/public/private/class/method names. All such names are registered in HVM in single global symbol table. Anyhow the maximum size of global symbol table does not mean that it sets limit for maximum number of given constructions. Some of them like private variables can share the same name.

There is no limit for number of memvars (public and private variables) and fields but please remember about maximum size of global symbol table and number of symbols in single module. Maximum number of workareas is 65534. Maximum number of local variables in a single function is 32767. Maximum number of local parameters in a single function is 32767. Maximum number of static variables in single module is 65535 (in whole application is unlimited).

The maximum size of literal string defined in PRG code is 16MB. The maximum size of literal array defined in PRG code is 65535.

The size of PCODE generated for single function is unlimited. Anyhow maximum size of conditional and unconditional jump in Harbour is 8388607. It may introduce limits in some construction so we can only define minimum fully supported size of PCODE generated for single function or code block as 8MB. Longer code can be generated if it does not exploit jump size limit. Macro compiler has exactly the same limits as compiler. For more info look at section “MACRO COMPILER” in doc/xhb-diff.txt.

Things like maximum number of open files, maximum file size, etc. are limited only by operating system and used data structures. Harbour does not introduce any new limits here. You may find my messages about limits defined by DBF* structures or read about them in doc/xhb-diff.txt, section “NATIVE RDDs”

best regards
Przemek
https://mail.google.com/mail/u/0/?shva=1#inbox/14409765f8d5654d
~~~~~~~~~~~~~

 

Harbour File Size Limits

 

Harbour File Size Limits

  • Max record size: 2^16-1 = 65535 byts ( 64 MB )
  • Max number of recors : 2^32-1 = 4,294,967,295 ( 4 Bilion )
  • Max .dbf file size : 2^48 = 256 TB
  • Max DBT memo file size : 2 TB
  • Max FPT memo file size : 256 GB
  • Max SMT memo file size : 128 GB
  • Max NTX file size (standard) : 4GB
  • Max NTX file size (incresead ) : 4TB
  • Max CDX file size : 4GB

 

Source : Harbour\doc\xhb-diff.txt :

### NATIVE RDDs ###

In both compilers maximal file size for tables, memos and indexes is limited only by OS and file format structures. Neither Harbour nor xHarbour introduce own limits here.

The maximal file size for DBFs is limited by number of records 2^32-1 = 4294967295 and maximal record size: 2^16-1 = 65535 what gives nearly 2^48 = 256TB as maximal .dbf file size.

The maximal memo format size depends on used memo type: DBT, FPT or SMT and size of  memo block. It’s limited by maximal number of memo blocks = 2^32 and size of memo block so it’s 2^32*<size_of_memo_block>.

The default memo block size for DBT is 512 bytes, FPT – 64 bytes and for SMT 32 bytes. So for standard memo block sizes the maximum are:

DBT->2TB, FPT->256GB, SMT->128GB. The maximal memo block size in Harbour is 2^32 and minimal is 1 byte and it can be any value between 1 and 65536 and then any number of 64KB blocks. The last limitation is introduced as workaround for some wrongly implemented in other
languages memo drivers which were setting only 16 bits in 32bit field in memo header. Most of other languages has limit for memo block size at 2^15 and the block size has to be power of 2. Some of them also introduce minimal block size limits. If programmers plans to share data with programs compiled by such languages then he should check their documentation to not create memo files which cannot be accessed by them.

Maximal NTX file size for standard NTX files is 4GB and it’s limited by internal NTX structures. Enabling 64bit locking in [x]Harbour change slightly used NTX format and increase maximum NTX file size to 4TB.

The NTX format in [x]Harbour has also many other extensions like support for multitag indexes or using record number as hidden part of index key and many others which are unique to [x]Harbour. In practice all of CDX extensions are supported by NTX in [x]Harbour.

The NSX format in [x]Harbour is also limited by default to 4GB but like in NTX enabling 64bit locking extend it to 4TB. It also supports common to NTX and CDX set of features.

The CDX format is limited to 4GB and so far [x]Harbour does not support extended mode which can increase the size up to 2TB with standard page length and it can be bigger in all formats if we introduce support for bigger index pages. Of course all such extended formats are not binary compatible with original ones and so far can be used only by [x]Harbour RDDs though in ADS the .adi format is such extended CDX format so maybe in the future it will be possible to use .adi indexes in our CDX RDD.

Of course all of the above sizes can be reduced by operating system (OS) or file system (FS) limitations so it’s necessary to check what is supported by environment where [x]Harbour applications are executed. 

Limits of Harbour

Limits of array elements and String Size

Q:  Clipper had a limitation of the maximum array elements of 4096.  Does this apply in Harbour?

A: No. Harbour is limited only by available memory which can allocate single process. String size is also unlimited.  In Clipper string items are limited to 64KB. The size of macrocompiler string is also unlimited anyhow if generated code will use internally jumps longer then 8MB macrocompiler will report RT error but cleanly without any memory corruption like in Clipper or xHarbour.

Przemek

Source : https://groups.google.com/forum/#!topic/harbour-users/_bEGMVwOqpA