Performance fix. Require proper testing POI, Address and Map simultaneously. Could be Dangerous! Initialization map method is changed.

This commit is contained in:
Victor Shcherb 2012-01-06 01:09:24 +01:00
parent 8a2f562304
commit 640c120212
2 changed files with 19 additions and 3 deletions

View file

@ -53,6 +53,7 @@ public class BinaryMapIndexReader {
private final RandomAccessFile raf;
private int version;
// keep them immutable inside
private List<MapIndex> mapIndexes = new ArrayList<MapIndex>();
private List<PoiRegion> poiIndexes = new ArrayList<PoiRegion>();
private List<AddressRegion> addressIndexes = new ArrayList<AddressRegion>();
@ -69,6 +70,21 @@ public class BinaryMapIndexReader {
this(raf, false);
}
public BinaryMapIndexReader(final RandomAccessFile raf, BinaryMapIndexReader referenceToSameFile) throws IOException {
this.raf = raf;
codedIS = CodedInputStreamRAF.newInstance(raf, 1024 * 5);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
version = referenceToSameFile.version;
transportAdapter = new BinaryMapTransportReaderAdapter(this);
addressAdapter = new BinaryMapAddressReaderAdapter(this);
poiAdapter = new BinaryMapPoiReaderAdapter(this);
mapIndexes = new ArrayList<BinaryMapIndexReader.MapIndex>(referenceToSameFile.mapIndexes);
poiIndexes = new ArrayList<PoiRegion>(referenceToSameFile.poiIndexes);
addressIndexes = new ArrayList<AddressRegion>(referenceToSameFile.addressIndexes);
transportIndexes = new ArrayList<TransportIndex>(referenceToSameFile.transportIndexes);
indexes = new ArrayList<BinaryIndexPart>(referenceToSameFile.indexes);
}
public BinaryMapIndexReader(final RandomAccessFile raf, boolean readOnlyMapData) throws IOException {
this.raf = raf;
codedIS = CodedInputStreamRAF.newInstance(raf, 1024 * 5);

View file

@ -467,7 +467,7 @@ public class ResourceManager {
if (index.hasTransportData()) {
try {
RandomAccessFile raf = new RandomAccessFile(f, "r"); //$NON-NLS-1$
transportRepositories.add(new TransportIndexRepositoryBinary(new BinaryMapIndexReader(raf)));
transportRepositories.add(new TransportIndexRepositoryBinary(new BinaryMapIndexReader(raf, index)));
} catch (IOException e) {
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
@ -476,7 +476,7 @@ public class ResourceManager {
if(index.containsMapData()){
try {
RandomAccessFile raf = new RandomAccessFile(f, "r"); //$NON-NLS-1$
routingMapFiles.put(f.getAbsolutePath(), new BinaryMapIndexReader(raf, true));
routingMapFiles.put(f.getAbsolutePath(), new BinaryMapIndexReader(raf, index));
} catch (IOException e) {
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
@ -485,7 +485,7 @@ public class ResourceManager {
if(index.containsPoiData()) {
try {
RandomAccessFile raf = new RandomAccessFile(f, "r"); //$NON-NLS-1$
amenityRepositories.add(new AmenityIndexRepositoryBinary(new BinaryMapIndexReader(raf)));
amenityRepositories.add(new AmenityIndexRepositoryBinary(new BinaryMapIndexReader(raf, index)));
} catch (IOException e) {
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$