Closed Bug 298613 Opened 19 years ago Closed 12 years ago

there should be a way to quickly insert multiple items into an RDF container

Categories

(Core Graveyard :: RDF, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jdarmochwal, Unassigned)

References

Details

(Keywords: perf, Whiteboard: [2012 Fall Equinox])

Attachments

(1 file, 3 obsolete files)

Inserting multiple items into an RDF container with
RDFContainerImpl::InsertElementAt() is very slow, because the container elements
have to be renumbered for each item inserted. Things could be much faster if the
renumbering was done for all the new items before inserting them.
One way to do this might be to make RDFContainerImpl::Renumber() scriptable via
nsIRDFContainer and then call Renumber() before doing the InsertElementAt()s
with aRenumber set to false.
A problem with this approach could be that aborting the insertion before all the
elements have been inserted might leave a "gap" in the container.
Attachment #187145 - Flags: review?(axel)
Comment on attachment 187145 [details] [diff] [review]
make RDFContainerImpl::Renumber() scriptable via nsIRDFContainer

This spreads brittle code over the platform, I favour a insertElementsAt, with
some [array, size_is()] goodness. This may be usefull to web apps, and I don't
feel like making them jump the nsIArray loop.

This patch messes with cvs blame more than necessary, too.
Attachment #187145 - Flags: review?(axel) → review-
shaver may want to verify that I'm not smoking crack in #2 about the array foo.
I can't speak reliably to your crack habits, but

void insertElementsAt([array,size_is(eltCount)] in nsIWhatever elements,
                      in PRUint32 eltCount, in PRUint32 index);

seems right to me.
Attachment #187145 - Attachment is obsolete: true
Attachment #187270 - Flags: review?(axel)
Comment on attachment 187270 [details] [diff] [review]
new methods InsertElementsAt() and RemoveElementsAt()

>Index: rdf/base/src/nsRDFContainer.cpp

>@@ -298,97 +298,122 @@ 
<...>
> NS_IMETHODIMP
> RDFContainerImpl::InsertElementAt(nsIRDFNode *aElement, PRInt32 aIndex, PRBool aRenumber)
> {
>+    return InsertElementsAt(&aElement, 1, aIndex, aRenumber);
>+}

Make this crash safe for aElement == nsnull, too.

<...>

> NS_IMETHODIMP
> RDFContainerImpl::RemoveElementAt(PRInt32 aIndex, PRBool aRenumber, nsIRDFNode** _retval)
> {
>+    return RemoveElementsAt(aIndex, 1, aRenumber, &_retval);
>+}

You're assigning a one element array allocated to a reference here, I expect
this to crash.

<...>
Attachment #187270 - Flags: review?(axel) → review-
next try

> >+	return InsertElementsAt(&aElement, 1, aIndex, aRenumber);
> 
> Make this crash safe for aElement == nsnull, too.

InsertElementsAt() checks if it's nsnull.
Attachment #187270 - Attachment is obsolete: true
Attachment #188526 - Flags: review?(axel)
Comment on attachment 188526 [details] [diff] [review]
new methods InsertElementsAt() and RemoveElementsAt()


> NS_IMETHODIMP
> RDFContainerImpl::InsertElementAt(nsIRDFNode *aElement, PRInt32 aIndex, PRBool aRenumber)
> {
>+    return InsertElementsAt(&aElement, 1, aIndex, aRenumber);
			      ^^^
this crashes.



> NS_IMETHODIMP
> RDFContainerImpl::RemoveElementAt(PRInt32 aIndex, PRBool aRenumber, nsIRDFNode** _retval)
> {
>+    PRUint32 count;
>+    nsIRDFNode **elements;
>+    nsresult rv = RemoveElementsAt(aIndex, 1, aRenumber, &count, &elements);
>+    *_retval = NS_SUCCEEDED(rv) ? elements[0] : nsnull;
>+    return rv;
>+}

This leaks elements.
Attachment #188526 - Flags: review?(axel) → review-
time for some more tries
Attachment #188526 - Attachment is obsolete: true
Attachment #210346 - Flags: review?(axel)
Comment on attachment 210346 [details] [diff] [review]
new methods InsertElementsAt() and RemoveElementsAt()

Sorry for the lag again, took me a while to actually look at the review queue of this account.

r-, the [array] foo is still broken, as that needs to allocate the array itself.

This is a low cost r-, too, given that bookmarks are moving from RDF over to sqlite places, I'm not convinced that we need to have this.
Attachment #210346 - Flags: review?(axel) → review-
With moving from RDF to Places, is this bug still actual?
Whiteboard: [2012 Fall Equinox]
(In reply to Phoenix from comment #11)
> With moving from RDF to Places, is this bug still actual?

It's probably OK to resolve this bug as WONTFIX. There does not seem to be much need for fast insertions in RDF containers anymore.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: