[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[EP-tech] Virtual fields -when does the 'cost' of processing get triggered?
CAUTION: This e-mail originated outside the University of Southampton.
Hi,
Seems like no one knew- so I went down the investigation route.
For a virtual field, the 'cost' of the field occurs when te value is asked for, not when the EPrint object is instantiated.
This is a script I used to investigate:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fjesusbagpuss%2F553234bf241caf4d3aab78d0c5b3066c&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751263564%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Woe5gFkZdkz4hz5LEhACSIFdb5wlePrwUuNoJ8tC7dQ%3D&reserved=0
It steps through a few basic questions (archive id, eprintid, field to dump), but also allows you to set the 'noise' of the EPrints session.
This is the same mechanism that running e.g. ~/bin/epadmin --verbose --verbose --verbose uses.
Setting the noise to 3 will show SQL statements used when creating the EPrint object, or getting a field value.
It's not the most useful script as-is, but might be a useful base for other investigations.
Cheers,
John
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of John Salter via Eprints-tech
Sent: 01 December 2022 09:06
To: 'eprints-tech at ecs.soton.ac.uk' <eprints-tech at ecs.soton.ac.uk>
Subject: [EP-tech] Virtual fields -when does the 'cost' of processing get triggered?
CAUTION: This e-mail originated outside the University of Southampton.
Hi All,
I'm looking adding a 'virtualwithvalue' (https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbazaar.eprints.org%2F452%2F1%2Fplugins%2FEPrints%2FMetaField%2FVirtualwithvalue.pm&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nXfN6RhJ2Qz22BSRfr1%2BNER4pDswFoXI2br5GCsfVV4%3D&reserved=0<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbazaar.eprints.org%2F452%2F1%2Fplugins%2FEPrints%2FMetaField%2FVirtualwithvalue.pm&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nXfN6RhJ2Qz22BSRfr1%2BNER4pDswFoXI2br5GCsfVV4%3D&reserved=0>) field to my EPrints install that does a search of the EPrint history, finding the first record, and returning the datestamp for that history item (i.e. the date the EPrint was created).
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fjesusbagpuss%2F8b899eb0eb9b2b733eead25c6dfd5973&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SF0EpVFs7rUScktJBcBsg4HU84d18tKV%2FaWJiJQ6fzc%3D&reserved=0<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fjesusbagpuss%2F8b899eb0eb9b2b733eead25c6dfd5973&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SF0EpVFs7rUScktJBcBsg4HU84d18tKV%2FaWJiJQ6fzc%3D&reserved=0>
I was thinking about the processing overhead for this field, and wondered when the value is actually calculated. I guess it's one of these options:
- when the object is created in memory e.g. via an EPrints::DataObj::EPrint->new() call
- when the value is referenced e.g. $eprint->value( "virtualwithvalue_field" ) ;
If it's the first option, I should add the field to the EPrint dataobj as a non-virtual field, and calculate it once if the value is not set, and then store it.
If it's the second option, then the overhead is lower (although I might still want to do the above).
I could trace this through the system myself - but thought (hoped) that someone might know... :)
Cheers,
John
John Salter
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Forcid.org%2F0000-0002-8611-8266&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ayrnk7BnvSIdu6VZdI5m%2FdpDoZu1tFUy%2Fro0Pd7oFZs%3D&reserved=0<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Forcid.org%2F0000-0002-8611-8266&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C372e86be351f4a214c9908dade8b3656%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638066986751419807%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ayrnk7BnvSIdu6VZdI5m%2FdpDoZu1tFUy%2Fro0Pd7oFZs%3D&reserved=0>
White Rose Libraries Technical Officer
IT - Application Support (Research)
10.23B, IT Services Building
University of Leeds
Leeds
LS2 9JT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20221215/955ff1cb/attachment-0001.html