Reza,
just executed your code on my MacBook Pro with Neo4j 1.4 from inside Eclipse
with default settings, got

Check Point: 0

Check Point: 1000000

Check Point: 2000000

Check Point: 3000000

Check Point: 4000000

Check Point: 5000000

Check Point: 6000000

Check Point: 7000000

Check Point: 8000000

Check Point: 9000000


and it took 198s. Not sure what is the problem here, what are you running on
in terms of OS and JVM?


/peter

On Tue, Aug 30, 2011 at 11:10 AM, Reza Ameri <[email protected]> wrote:

> Thank you for your quick answer, my Neo4j version is 1.4. I did nothing
> except the code you can see.
> I'm trying to learn more about neo4j :)
>
>
> On Tue, Aug 30, 2011 at 1:31 PM, Peter Neubauer <
> [email protected]> wrote:
>
> > Hi there,
> > what is your Neo4j version and did you set any special JVM flags or
> > neo4j.properties?
> >
> > Cheers,
> >
> > /peter neubauer
> >
> > GTalk:      neubauer.peter
> > Skype       peter.neubauer
> > Phone       +46 704 106975
> > LinkedIn   http://www.linkedin.com/in/neubauer
> > Twitter      http://twitter.com/peterneubauer
> >
> > http://www.neo4j.org               - Your high performance graph
> database.
> > http://startupbootcamp.org/    - Ă–resund - Innovation happens HERE.
> > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
> >
> >
> > On Tue, Aug 30, 2011 at 10:57 AM, Reza Ameri <[email protected]> wrote:
> >
> > > Hi,
> > > I've written the code below to create 10M nodes, without any relations.
> > > But,
> > > it has memory exception that couldn't solve. would you please help me.
> > >
> > > Also I want to show this graph visually. I used Gremlin and Jung to
> view
> > > the
> > > graph, but it either did not work even for 1M nodes! Any Idea About
> this
> > > one?
> > >
> > > Thank you :)
> > >
> > > Code of BatchInserter:
> > >
> > >
> > > public void batchInsertor(String graphPath)
> > > {
> > > BatchInserter inserter = null;
> > > BatchInserterIndexProvider indexProvider = null;
> > > BatchInserterIndex index = null;
> > > try{
> > > inserter = new BatchInserterImpl(graphPath);
> > > indexProvider = new LuceneBatchInserterIndexProvider( inserter );
> > > index = indexProvider.nodeIndex( "index", MapUtil.stringMap( "type",
> > > "exact"
> > > ) );
> > >  for(int i=0; i<10000000; i++)
> > > {
> > > index.setCacheCapacity("name", 100000 );
> > > Map<String, Object> properties = MapUtil.map( "name",
> String.valueOf(i));
> > > long node = inserter.createNode(properties);
> > > index.add( node, properties );
> > > if(i%1000000 == 0)
> > > {
> > > System.out.println("Check Point: " + i);
> > > }
> > > }
> > >  indexProvider.shutdown();
> > > inserter.shutdown();
> > > }
> > > finally{
> > > indexProvider.shutdown();
> > > inserter.shutdown();
> > > }
> > > }
> > >
> > >
> > > Error:
> > >
> > > Exception in thread "main" java.lang.IllegalStateException: this writer
> > hit
> > > an OutOfMemoryError; cannot flush
> > > at
> > >
> >
> org.apache.lucene.index.IndexWriter.doFlushInternal(IndexWriter.java:3521)
> > > at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3509)
> > > at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3500)
> > > at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:2271)
> > > at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:2249)
> > > at
> > >
> > >
> >
> org.neo4j.index.impl.lucene.LuceneBatchInserterIndex.closeWriter(LuceneBatchInserterIndex.java:275)
> > > at
> > >
> > >
> >
> org.neo4j.index.impl.lucene.LuceneBatchInserterIndex.shutdown(LuceneBatchInserterIndex.java:350)
> > > at
> > >
> > >
> >
> org.neo4j.index.impl.lucene.LuceneBatchInserterIndexProvider.shutdown(LuceneBatchInserterIndexProvider.java:144)
> > >
> > >
> > >
> > > Code of Visualization:
> > >
> > > public JPanel showBatchInserted(String graphPath)
> > > {
> > > neo = new Neo4jGraph(graphPath);
> > > JPanel graphPanel=new JPanel();
> > > GraphJung g = new GraphJung(neo);
> > > Layout<Vertex, Edge> layout = new CircleLayout<Vertex,Edge>(g);
> > > layout.setSize(new Dimension(1500,1000));
> > > viz = new VisualizationViewer<Vertex, Edge>(layout);
> > > viz.setBackground(Color.WHITE);
> > > viz.setAutoscrolls(true);
> > > viz.setName("visualizationViewer");
> > > viz.setSize(new Dimension(1500,1000));
> > > AnnotatingGraphMousePlugin<Vertex, Edge> an=new
> > > AnnotatingGraphMousePlugin<Vertex, Edge>(viz.getRenderContext());
> > > AnnotatingModalGraphMouse<Vertex,Edge> gm =  new
> > > AnnotatingModalGraphMouse<Vertex,Edge>(viz.getRenderContext(),
> > > an);
> > >
> > > gm.setMode(ModalGraphMouse.Mode.PICKING);
> > > viz.setGraphMouse(gm);
> > > JMenuBar menuBar = new JMenuBar();
> > > JMenu modeMenu = gm.getModeMenu();
> > > modeMenu.setText("Mouse Mode");
> > > modeMenu.setIcon(null);
> > > modeMenu.setPreferredSize(new Dimension(80,20));
> > > menuBar.add(modeMenu,BorderLayout.NORTH);
> > >
> > > GraphZoomScrollPane graphScroll=new GraphZoomScrollPane(viz);
> > > graphScroll.add(menuBar,BorderLayout.NORTH);
> > > graphScroll.add(viz,BorderLayout.CENTER);
> > > graphScroll.setName("graphScroll");
> > > graphPanel.add(graphScroll,BorderLayout.CENTER);
> > >
> > >
> > > Transformer<Vertex,Paint> vertexPaint = new Transformer<Vertex,Paint>()
> {
> > > public Paint transform(Vertex i) {
> > > return Color.RED;
> > > }
> > > };
> > > Transformer<Vertex,Icon> vertexIcon = new Transformer<Vertex,Icon>() {
> > > public Icon transform(Vertex i) {
> > > ImageIcon icon=new ImageIcon("icon/icon.png");
> > > return icon;
> > > }
> > > };
> > > float dash[] = {0.1f};
> > > final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
> > > BasicStroke.JOIN_MITER, 10.0f, dash, 5.0f);
> > > Transformer<Edge, Stroke> edgeStrokeTransformer =
> > > new Transformer<Edge, Stroke>() {
> > > public Stroke transform(Edge s) {
> > > return edgeStroke;
> > > }
> > > };
> > >
> > > Transformer<Edge,Paint> edgePaint = new Transformer<Edge,Paint>() {
> > >
> > > public Paint transform(Edge arg0) {
> > > // TODO Auto-generated method stub
> > > return Color.BLUE;
> > > }
> > > };
> > > Transformer<Edge, Paint> arrowColor=new Transformer<Edge, Paint>() {
> > >
> > > @Override
> > > public Paint transform(Edge arg0) {
> > > // TODO Auto-generated method stub
> > > return Color.BLUE;
> > > }
> > > };;;
> > > Transformer<Edge, Paint> arrowDraw=new Transformer<Edge, Paint>() {
> > >
> > > @Override
> > > public Paint transform(Edge arg0) {
> > > // TODO Auto-generated method stub
> > > return Color.BLUE;
> > > }
> > > };;;
> > > Transformer<Edge, Font> fontEdge=new Transformer<Edge, Font>() {
> > >
> > > @Override
> > > public Font transform(Edge arg0) {
> > > Font temp=new Font(Font.MONOSPACED,Font.ITALIC, 12);
> > > return temp;
> > > }
> > > };;;
> > > Transformer<Vertex, Font> font=new Transformer<Vertex, Font>() {
> > >
> > > @Override
> > > public Font transform(Vertex arg0) {
> > > // TODO Auto-generated method stub
> > > Font temp=new Font(Font.MONOSPACED,Font.ITALIC, 12);
> > >
> > > return temp;
> > > }
> > > };;;
> > > Transformer<Vertex, String> vertexLabelTransformer = new
> > > Transformer<Vertex,
> > > String>() {
> > > public String transform(Vertex vertex) {
> > > return (String) vertex.getProperty(PROPERTY_NODE_NAME);
> > > }
> > > };
> > > Transformer<Edge, String> edgeLabelTransformer = new Transformer<Edge,
> > > String>() {
> > > public String transform(Edge edge) {
> > > return
> > >
> > >
> >
> edge.getProperty(PROPERTY_EDGE_TYPE)+",cost="+String.valueOf(edge.getProperty(PROPERTY_EDGE_COST))+",time="+String.valueOf(edge.getProperty(PROPERTY_EDGE_TIME));//edge.getLabel()
> > > ;
> > > }
> > > };
> > > viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer);
> > >
> viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
> > > viz.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
> > > viz.getRenderContext().setVertexIconTransformer(vertexIcon);
> > > viz.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
> > > viz.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
> > > viz.getRenderer().getVertexLabelRenderer().setPosition(Position.N);
> > > viz.getRenderContext().setArrowFillPaintTransformer(arrowColor);
> > > viz.getRenderContext().setArrowDrawPaintTransformer(arrowDraw);
> > > viz.getRenderContext().setVertexFontTransformer(font);
> > > viz.getRenderContext().setEdgeFontTransformer(fontEdge);
> > >  return graphPanel;
> > > }
> > > _______________________________________________
> > > Neo4j mailing list
> > > [email protected]
> > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> > _______________________________________________
> > Neo4j mailing list
> > [email protected]
> > https://lists.neo4j.org/mailman/listinfo/user
> >
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to