Page 5 of 5 FirstFirst ... 345
Results 41 to 45 of 45

Thread: Handling huge amounts of data

  1. #41
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Handling huge amounts of data

    Here is another option for large datasets. I used these components a long time ago D1/D2 days and I thought they were great.

    http://rmarsh.com/2001/06/18/qdb-qui...se-components/
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  2. #42

    Handling huge amounts of data

    Quote Originally Posted by Chebmaster
    Things like this
    [pascal]while (IText <Length> #32) do
    begin
    Part := Part+Text[IText]; [/pascal]
    kill performance on the spot. Brutally.

    EACH time you add a char to a string, a call to realloc its memory is performed. So you can imagine how "fast" will this code execute.

    Ideally, you should make two passes. The first one determines subsstring lengths and positions, the second pass allocates memory by calling SetLength for destination strings (once!) and copies the characters.
    Just to inform I made the optimization of that code

    I'm allocating a big block to build the string Part, and then I cut it creating another string with the standard Copy() function. In total I make just two allocations in that function, and the speed of the program didn't changed significantly on my 4 years old computer. That should mean using Part := Part+Text[IText] is not a brutal performance killer as suggested. Maybe it is already being optimized by the compiler.

    Anyway, that helped me to clear a little my code. Thanks.

  3. #43

    Handling huge amounts of data

    ok i made some test.
    I read the text file containing the spoiler and save it in a record as i want. the record is (names are in italian .P ):

    Code:
    Type
      TCardRecord = Record
        Serie &#58; String&#91;25&#93;;
        Categoria &#58; String&#91;25&#93;;
        Corporazione &#58; String&#91;30&#93;;
        Nome &#58; String&#91;30&#93;;
        Testo &#58; Array &#91;0..900&#93; of Char;
        L &#58; String&#91;2&#93;;
        Errata &#58; Array &#91;0..900&#93; of Char;
        R &#58; String&#91;3&#93;;
        C &#58; String&#91;3&#93;;
        S &#58; String&#91;3&#93;;
        A &#58; String&#91;3&#93;;
        V &#58; String&#91;3&#93;;
        P &#58; String&#91;2&#93;;
        Tipo &#58; String&#91;25&#93;;
        Grafico &#58; String&#91;20&#93;;
        Cerchietto&#58; String&#91;40&#93;;
      End;
    then i try to implement binary search as suggested, but i don't understand this:

    Code:
    FSize &#58;= FileSize&#40;F&#41;;//file size in bytes, return 2047
    RSize&#58;=Sizeof&#40;TCardRecord&#41;;//Record size in bytes, return 2030
    the file i created is around 4 mb; why filesize return this value? (i can read it all with no errors)
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

  4. #44
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Handling huge amounts of data

    If a file variable links to a typed file (ie f : file of TCardRecord), then the position and size functions work on record numbers.

    So, from that I'd say you have 2047 records in your card list.

    If you then use Seek(0) (IIRC) you will end up at record 0... the start of the file. Seek(2046) will take you to the last record in the file and Seek(2047) will take you past the end of the file ready to write another record.

    To get the file size in bytes, you must connect to it with a file of byte or textfile.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #45

    Handling huge amounts of data

    ok thanks; i thinked so but by reading some manuals they always say that filesize return the size in bytes (for untyped and typed files). Nice to know that
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

Page 5 of 5 FirstFirst ... 345

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •