[CDO] Add content of XMI file to existing CDO resource - too slow [message #1392611] |
Wed, 02 July 2014 15:30 |
Evgeny Karataev Messages: 18 Registered: May 2014 |
Junior Member |
|
|
Hello,
I am trying to add content from several XMI files into one CDOResource and store the result in MySQL (or HSQLDB). Each XMI file is imported separately. Here is the code I have (similar to the approach suggested by Eike here):
CDOTransaction transaction = CDOUtil.beginTransaction();
CDOResource cdoResource = transaction.getOrCreateResource("/" + resourceId);
Resource resourceToImport = new XMIResourceImpl();
resourceToImport.load(is, Collections.EMPTY_MAP);
EcoreUtil.Copier copier = new EcoreUtil.Copier();
Collection<EObject> copiedObjects = copier.copyAll(resourceToImport.getContents());
cdoResource.getContents().addAll(copiedObjects);
copier.copyReferences();
transaction.commit();
The code above works fine with small XMI files and I am able to add content from several XMI files into one CDO resource. However when I tried to add XMI file of about 8 Mb size with about 30000 object in it, the code above worked very slow. Particularly, this line:
cdoResource.getContents().addAll(copiedObjects);
It took about 40 minutes to add all copied objects to cdoResource. One of the things I noticed is that when the addAll is executed, catalina.out file grew in size from basically 0 to about 60 Gb.
Here are several lines from catalina.out file:
http-bio-8180-exec-9 [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting ID: oid2
http-bio-8180-exec-9 [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting branchPoint Trace@oid2v0: BranchPoint[Branch[id=0, name=MAIN], *]
http-bio-8180-exec-9 [org.eclipse.emf.internal.cdo.view.AbstractCDOView] Registering Trace@oid2[PREPARED]
http-bio-8180-exec-9 [org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl] Registering new object Trace@oid2[PREPARED]
http-bio-8180-exec-9 [org.eclipse.net4j.util.fsm.FiniteStateMachine] Processing event PREPARE in state TRANSIENT for TraceLine[TRANSIENT] (data=Pair[Transaction 1, [TraceLine[TRANSIENT]]])
http-bio-8180-exec-9 [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting ID: oid3
http-bio-8180-exec-9 [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting branchPoint TraceLine@oid3v0: BranchPoint[Branch[id=0, name=MAIN], *]
http-bio-8180-exec-9 [org.eclipse.emf.internal.cdo.view.AbstractCDOView] Registering TraceLine@oid3[PREPARED]
http-bio-8180-exec-9 [org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl] Registering new object TraceLine@oid3[PREPARED]
http-bio-8180-exec-9 [org.eclipse.net4j.util.fsm.FiniteStateMachine] Processing event PREPARE in state TRANSIENT for TraceLine[TRANSIENT] (data=Pair[Transaction 1, [TraceLine@oid3[PREPARED], TraceLine[TRANSIENT]]])
Note the data field in the FinalStateMachine log records. It grows with each added object.
So I guess my quests are:
1) Am I doing the addition of XMI content to existing CDOResource correctly? Is there a more efficient way to do that?
2) Is the huge log file the issue that makes addAll so slow? Can I configure CDO client not to log that much?
3) Do you see anything weird in the log records? Maybe I need to try to configure CDO to be more efficient? If so, how?
Thank you in advance.
|
|
|
|
|
Re: [CDO] Add content of XMI file to existing CDO resource - too slow [message #1392656 is a reply to message #1392611] |
Wed, 02 July 2014 16:55 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Evgeny,
Comments below.
On 02/07/2014 5:30 PM, Evgeny Karataev wrote:
> Hello,
>
> I am trying to add content from several XMI files into one CDOResource
> and store the result in MySQL (or HSQLDB). Each XMI file is imported
> separately. Here is the code I have (similar to the approach suggested
> by Eike
> https://www.eclipse.org/forums/index.php/mv/msg/202347/646845/#msg_646845):
>
>
> CDOTransaction transaction = CDOUtil.beginTransaction();
>
> CDOResource cdoResource = transaction.getOrCreateResource("/" +
> resourceId);
>
> Resource resourceToImport = new XMIResourceImpl();
> resourceToImport.load(is, Collections.EMPTY_MAP);
>
> EcoreUtil.Copier copier = new EcoreUtil.Copier();
I'm not CDO expert but I don't see the point in copying objects you just
loaded.
> Collection<EObject> copiedObjects =
> copier.copyAll(resourceToImport.getContents());
>
> cdoResource.getContents().addAll(copiedObjects);
>
> copier.copyReferences();
I'm also not sure it's a good idea to copy the references after
attaching it to the cdoResource. It's probably better to do it before.
And as I said, I don't see the point of a copy.
>
> transaction.commit();
>
>
> The code above works fine with small XMI files and I am able to add
> content from several XMI files into one CDO resource. However when I
> tried to add XMI file of about 8 Mb size with about 30000 object in
> it, the code above worked very slow. Particularly, this line:
>
> cdoResource.getContents().addAll(copiedObjects);
>
> It took about 40 minutes to add all copied objects to cdoResource. One
> of the things I noticed is that when the addAll is executed,
> catalina.out file grew in size from basically 0 to about 60 Gb.
> Here are several lines from catalina.out file:
>
>
> http-bio-8180-exec-9
> [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting ID:
> oid2
> http-bio-8180-exec-9
> [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting
> branchPoint Trace@oid2v0: BranchPoint[Branch[id=0, name=MAIN], *]
> http-bio-8180-exec-9
> [org.eclipse.emf.internal.cdo.view.AbstractCDOView] Registering
> Trace@oid2[PREPARED]
> http-bio-8180-exec-9
> [org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl]
> Registering new object Trace@oid2[PREPARED]
> http-bio-8180-exec-9 [org.eclipse.net4j.util.fsm.FiniteStateMachine]
> Processing event PREPARE in state TRANSIENT for TraceLine[TRANSIENT]
> (data=Pair[Transaction 1, [TraceLine[TRANSIENT]]])
> http-bio-8180-exec-9
> [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting ID:
> oid3
> http-bio-8180-exec-9
> [org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision] Setting
> branchPoint TraceLine@oid3v0: BranchPoint[Branch[id=0, name=MAIN], *]
> http-bio-8180-exec-9
> [org.eclipse.emf.internal.cdo.view.AbstractCDOView] Registering
> TraceLine@oid3[PREPARED]
> http-bio-8180-exec-9
> [org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl]
> Registering new object TraceLine@oid3[PREPARED]
> http-bio-8180-exec-9 [org.eclipse.net4j.util.fsm.FiniteStateMachine]
> Processing event PREPARE in state TRANSIENT for TraceLine[TRANSIENT]
> (data=Pair[Transaction 1, [TraceLine@oid3[PREPARED],
> TraceLine[TRANSIENT]]])
>
>
> Note the data field in the FinalStateMachine log records. It grows
> with each added object.
>
> So I guess my quests are:
> 1) Am I doing the addition of XMI content to existing CDOResource
> correctly? Is there a more efficient way to do that?
> 2) Is the huge log file the issue that makes addAll so slow? Can I
> configure CDO client not to log that much?
> 3) Do you see anything weird in the log records? Maybe I need to try
> to configure CDO to be more efficient? If so, how?
>
> Thank you in advance.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03450 seconds