Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] Lazy load property #284

Open
wants to merge 6 commits into
base: 2.x
Choose a base branch
from
Open

[POC] Lazy load property #284

wants to merge 6 commits into from

Conversation

dantleech
Copy link
Contributor

This PR experiments with lazy-loading properties -- do not review :)

@lsmith77 lsmith77 changed the title Lazy load property [WIP] Lazy load property May 2, 2015
@lsmith77 lsmith77 changed the title [WIP] Lazy load property Lazy load property May 2, 2015
@lsmith77 lsmith77 added ready and removed in progress labels May 2, 2015
@dbu dbu changed the title Lazy load property [POC] Lazy load property May 2, 2015
@@ -886,7 +890,7 @@ public function hasProperty($relPath)
$this->checkState();

if (false === strpos($relPath, '/')) {
return isset($this->properties[$relPath]);
return isset($this->properties[$relPath]) || isset($this->propertyData[$relPath]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you even need to check $this->properties ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. .this was from an earlier stage .. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually ->setProperty sets properties directly.

@dbu
Copy link
Member

dbu commented May 2, 2015

interesting! i could not resist and had a look at it. i think what you currently miss is that when new properties are added, you also need to add their names to the $propertiesData, or you will "forget" them in some cases.

@@ -737,13 +744,13 @@ public function getProperties($nameFilter = null)
{
$this->checkState();

//OPTIMIZE: lazy iterator?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what you do below does not create a lazy iterator. but probably we don't need one.

@dbu
Copy link
Member

dbu commented Jul 4, 2015

dont you need to add information to the raw data as well when creating a new property: https://github.com/jackalope/jackalope/blob/lazy_load_property/src/Jackalope/Node.php#L1546-L1561

and what about deleting a property that has not been loaded yet?
https://github.com/jackalope/jackalope/blob/lazy_load_property/src/Jackalope/Node.php#L571-L574 i think you need to force property instantiation here.

@dantleech
Copy link
Contributor Author

dont you need to add information to the raw data as well when creating a new property:

I didn't think so, as we always try to load first from $properties and only then fallback to the "raw data".

and what about deleting a property that has not been loaded yet?

maybe, the tests are still failing on the implementation(s) and I am not sure why.

@dantleech
Copy link
Contributor Author

Note to future self: hasProperty and isset($this->properties) || isset($this->propertyData) is not strictly equivilent, should add a separate hasLocaleProperty method to the node.

@dantleech
Copy link
Contributor Author

I have reduced the errors to 7 with 5 failures, it requires probably only a few fixes before it "works". But its a bit of a mess, and I am sure I will introduce regressions somehow with the current work. But maybe it would be interesting for benchmarking and seeing if its worth finishing off.

return array();
}
$res = array();
$ntm = $this->session->getWorkspace()->getNodeTypeManager();
foreach ($this->properties['jcr:mixinTypes']->getValue() as $type) {
foreach ($this->getPropertyValue('jcr:mixinTypes') as $type) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tricky part is knowing when we can call these "API" methods, as they will always check the state and break thiings if the operation is "internal" and doesn't care about the external state.

@dantleech
Copy link
Contributor Author

Hmm, and a quick benchmark doesn't show any improvement currently, so I guess something is going wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants