<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
on the server side even with the read-only search the
MMapDataAccess is <b>not</b> fully thread safe due to the limited
Java API (ByteBuffer) which is stateful. For example see getBytes
where bb.position(0) can potentially influence other threads. Just
try to use QueryTorture and exceptions should show up pretty early
or check distance/geometry. So yes, using the sync wrapper is
highly recommended or use RAMDataAccess.<br>
<br>
We could implement memory mapping via Unsafe to make it faster and
no synchronized would be necessary (as we do not use the
ByteBuffer API). But there was no demand regarding this and also
it is quite tricky and we leave Java supported land ;)<br>
<br>
Regards,<br>
Peter<br>
<br>
On 01.07.2015 19:49, John Zhao wrote:<br>
</div>
<blockquote
cite="mid:CA+EBg9Rd6NPC4RVYHkTR+zAcpp3X-XCH3C557x+vw2u9OOrDnQ@mail.gmail.com"
type="cite">
<div dir="ltr">Hi Peter,
<div><br>
</div>
<div>If we use RAM to extract graphhopper, then use <span
style="color:rgb(0,0,0);font-family:'Segoe UI','Segoe UI Web
Regular','Segoe UI Symbol','Helvetica
Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">MMapDataAccess
to load graphhopper data.<br>
</span></div>
<div><font color="#000000" face="Segoe UI, Segoe UI Web Regular,
Segoe UI Symbol, Helvetica Neue, Helvetica, Arial,
sans-serif"><span style="line-height:18.8500003814697px">In
other words, if we read only with </span></font><span
style="color:rgb(0,0,0);font-family:'Segoe UI','Segoe UI Web
Regular','Segoe UI Symbol','Helvetica
Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">MMapDataAccess
on server side, is it correct and thread-safe?</span></div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="gmail_signature"><b>Best Regards,</b>
<div><b>ZhiQiang ZHAO</b></div>
</div>
</div>
<br>
<div class="gmail_quote">On Tue, Jun 30, 2015 at 10:53 PM, Peter
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:graphhopper@gmx.de" target="_blank">graphhopper@gmx.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Hi,<br>
<br>
this is for two reasons:<br>
first, it allows you to use the MMap for server side<br>
second, it allows us to use multi-threaded algorithms
at some point in the future<br>
<br>
Regards,<br>
Peter
<div>
<div class="h5"><br>
<br>
On 01.07.2015 02:31, John Zhao wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">Hi Peter,
<div><br>
</div>
<div>This question is for you. :)</div>
<div><br>
</div>
<div><span>I guess MMapDataAccess is mainly
designed for running Graphhopper on Android
device, which you can't load all the data into
the limited memory.</span></div>
<div><font color="#000000" face="Segoe UI, Segoe
UI Web Regular, Segoe UI Symbol, Helvetica
Neue, Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px"><br>
</span></font></div>
<div><span>In the comment of MMapDataAccess:</span><br>
<span>This is a data structure which uses the
operating system to synchronize between disc
and memory.</span><br>
<span>Use SynchDAWrapper if you intent to use
this from multiple threads!</span></div>
<div><font color="#000000" face="Segoe UI, Segoe
UI Web Regular, Segoe UI Symbol, Helvetica
Neue, Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px"><br>
</span></font></div>
<div><span>why GH need a thread-safe one, somebody
want to do the extract on Android device?</span><br>
<font color="#000000" face="Segoe UI, Segoe UI
Web Regular, Segoe UI Symbol, Helvetica Neue,
Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px">just
curious.</span></font></div>
<div><font color="#000000" face="Segoe UI, Segoe
UI Web Regular, Segoe UI Symbol, Helvetica
Neue, Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px"><br>
</span></font></div>
<div><font color="#000000" face="Segoe UI, Segoe
UI Web Regular, Segoe UI Symbol, Helvetica
Neue, Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px">Thanks
in advance.</span></font></div>
<div><font color="#000000" face="Segoe UI, Segoe
UI Web Regular, Segoe UI Symbol, Helvetica
Neue, Helvetica, Arial, sans-serif"><span
style="line-height:18.8500003814697px"><br
clear="all">
</span></font>
<div>
<div><b>Best Regards,</b>
<div><b>ZhiQiang ZHAO</b></div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>