Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: [XE5] Using GetPropInfo with record


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 17, 2015 10:40 AM Last Post By: Boris Herbinier...
Boris Herbinier...

Posts: 3
Registered: 4/15/05
[XE5] Using GetPropInfo with record  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 1:30 AM
Hello,

I use RTTI to deserialize the result of an SQL request to a TList of records. I'm using TRttiField.SetValue() and it works fine but is quite slow for large requests (~20k records/s).

I'm trying to speed things up and a possible solution would be to bypass SetValue and directly use SetOrdProp, SetStrProp...

Unfortunately I cannot figure out how to get a valid PPropInfo for a given field of a record as GetPropInfo() always return a nil pointer.

- Is it possible to use GetPropInfo with records?
- Is there a way to retrieve a valid PPropInfo from a given TRttiType or TRttiField?
- Any other suggestion as to how I could improve performance?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [XE5] Using GetPropInfo with record  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 9:30 AM   in response to: Boris Herbinier... in response to: Boris Herbinier...
Boris wrote:

Unfortunately I cannot figure out how to get a valid PPropInfo for a
given field of a record as GetPropInfo() always return a nil pointer.

As it should, because PPropInfo only works with properties (hense its name),
not fields.

- Is it possible to use GetPropInfo with records?

Yes, but only for properties.

- Is there a way to retrieve a valid PPropInfo from a given TRttiType
or TRttiField?

No. Only TRttiProperty (well, more accurately, TRttiInstanceProperty) exposes
that info.

- Any other suggestion as to how I could improve performance?

Are you sure it is the RTTI itself that is slowing your code down, and not
something else? Did you profile the code to see where the time is actually
being spent?

--
Remy Lebeau (TeamB)
Boris Herbinier...

Posts: 3
Registered: 4/15/05
Re: [XE5] Using GetPropInfo with record  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 10:40 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you for the clarification, I won't waste more time trying to retrieve something impossible then.

Are you sure it is the RTTI itself that is slowing your code down, and not
something else? Did you profile the code to see where the time is actually
being spent?

As far as I can be sure yes, I timed each loop with good-old GetTickCount and used AQTime for a more high level view.

I already tweaked the database, optimize the query, looped on fields as RTTI field enumeration is more expensive than rows and split the resulting TDataSet descendant so I can multi-thread the deserialization.

It's probably time to refactor to avoid working with records or tell users that loading 1.8 million data point should take 30s.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02