Update binary inspector
This commit is contained in:
parent
c397a428a1
commit
ba3a2cee39
2 changed files with 36 additions and 16 deletions
|
@ -630,6 +630,7 @@ public class BinaryInspector {
|
||||||
private static class MapStatKey {
|
private static class MapStatKey {
|
||||||
String key = "";
|
String key = "";
|
||||||
long statCoordinates;
|
long statCoordinates;
|
||||||
|
long statCoordinatesCount;
|
||||||
long statObjectSize;
|
long statObjectSize;
|
||||||
int count;
|
int count;
|
||||||
int namesLength;
|
int namesLength;
|
||||||
|
@ -644,10 +645,13 @@ public class BinaryInspector {
|
||||||
public int lastObjectCoordinates;
|
public int lastObjectCoordinates;
|
||||||
public int lastObjectCoordinatesCount;
|
public int lastObjectCoordinatesCount;
|
||||||
|
|
||||||
|
public int lastObjectSize;
|
||||||
|
|
||||||
private Map<String, MapStatKey> types = new LinkedHashMap<String, BinaryInspector.MapStatKey>();
|
private Map<String, MapStatKey> types = new LinkedHashMap<String, BinaryInspector.MapStatKey>();
|
||||||
private SearchRequest<BinaryMapDataObject> req;
|
private SearchRequest<BinaryMapDataObject> req;
|
||||||
|
|
||||||
public void processKey(String simpleString, MapObjectStat st, TIntObjectHashMap<String> objectNames) {
|
public void processKey(String simpleString, MapObjectStat st, TIntObjectHashMap<String> objectNames,
|
||||||
|
int coordinates, boolean names ) {
|
||||||
TIntObjectIterator<String> it = objectNames.iterator();
|
TIntObjectIterator<String> it = objectNames.iterator();
|
||||||
int nameLen = 0;
|
int nameLen = 0;
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
|
@ -661,33 +665,44 @@ public class BinaryInspector {
|
||||||
types.put(simpleString, stt);
|
types.put(simpleString, stt);
|
||||||
}
|
}
|
||||||
MapStatKey key = types.get(simpleString);
|
MapStatKey key = types.get(simpleString);
|
||||||
|
if (names) {
|
||||||
|
key.namesLength += nameLen;
|
||||||
|
} else {
|
||||||
key.statCoordinates += st.lastObjectCoordinates;
|
key.statCoordinates += st.lastObjectCoordinates;
|
||||||
|
key.statCoordinatesCount += coordinates;
|
||||||
key.statObjectSize += st.lastObjectSize;
|
key.statObjectSize += st.lastObjectSize;
|
||||||
key.count++;
|
key.count++;
|
||||||
key.namesLength += nameLen;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void process(BinaryMapDataObject obj) {
|
public void process(BinaryMapDataObject obj) {
|
||||||
MapObjectStat st = req.stat;
|
MapObjectStat st = req.stat;
|
||||||
|
int cnt = 0;
|
||||||
|
boolean names = st.lastObjectCoordinates == 0;
|
||||||
this.lastStringNamesSize += st.lastStringNamesSize;
|
this.lastStringNamesSize += st.lastStringNamesSize;
|
||||||
this.lastObjectIdSize += st.lastObjectIdSize;
|
this.lastObjectIdSize += st.lastObjectIdSize;
|
||||||
this.lastObjectHeaderInfo += st.lastObjectHeaderInfo;
|
this.lastObjectHeaderInfo += st.lastObjectHeaderInfo;
|
||||||
this.lastObjectAdditionalTypes += st.lastObjectAdditionalTypes;
|
this.lastObjectAdditionalTypes += st.lastObjectAdditionalTypes;
|
||||||
this.lastObjectTypes += st.lastObjectTypes;
|
this.lastObjectTypes += st.lastObjectTypes;
|
||||||
this.lastObjectCoordinates += st.lastObjectCoordinates;
|
this.lastObjectCoordinates += st.lastObjectCoordinates;
|
||||||
this.lastObjectCoordinatesCount += obj.getPointsLength();
|
if (!names) {
|
||||||
if(obj.getPolygonInnerCoordinates() != null) {
|
cnt = obj.getPointsLength();
|
||||||
for(int[] i : obj.getPolygonInnerCoordinates()) {
|
this.lastObjectIdSize += st.lastObjectSize;
|
||||||
this.lastObjectCoordinatesCount += i.length;
|
if (obj.getPolygonInnerCoordinates() != null) {
|
||||||
|
for (int[] i : obj.getPolygonInnerCoordinates()) {
|
||||||
|
cnt += i.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < obj.getTypes().length; i++) {
|
this.lastObjectCoordinatesCount += cnt;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < obj.getTypes().length; i++) {
|
||||||
int tp = obj.getTypes()[i];
|
int tp = obj.getTypes()[i];
|
||||||
TagValuePair pair = obj.mapIndex.decodeType(tp);
|
TagValuePair pair = obj.mapIndex.decodeType(tp);
|
||||||
processKey(pair.toSimpleString(), st, obj.getObjectNames());
|
processKey(pair.toSimpleString(), st, obj.getObjectNames(), cnt, names);
|
||||||
}
|
}
|
||||||
st.clearObjectStats();
|
st.clearObjectStats();
|
||||||
|
st.lastObjectSize = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,7 +718,7 @@ public class BinaryInspector {
|
||||||
b = 0;
|
b = 0;
|
||||||
b += out("Header", lastObjectHeaderInfo);
|
b += out("Header", lastObjectHeaderInfo);
|
||||||
b += out("Coordinates", lastObjectCoordinates);
|
b += out("Coordinates", lastObjectCoordinates);
|
||||||
b += out("Coordinates Count", lastObjectCoordinatesCount);
|
b += out("Coordinates Count(pair)", lastObjectCoordinatesCount);
|
||||||
b += out("Types", lastObjectTypes);
|
b += out("Types", lastObjectTypes);
|
||||||
b += out("Additonal Types", lastObjectAdditionalTypes);
|
b += out("Additonal Types", lastObjectAdditionalTypes);
|
||||||
b += out("Ids", lastObjectIdSize);
|
b += out("Ids", lastObjectIdSize);
|
||||||
|
@ -721,14 +736,16 @@ public class BinaryInspector {
|
||||||
});
|
});
|
||||||
|
|
||||||
for(MapStatKey s : stats) {
|
for(MapStatKey s : stats) {
|
||||||
println(s.key + " cnt=" + s.count + " size=" + s.statObjectSize + " coordsize="+s.statCoordinates+
|
println(s.key + " (" + s.count + ") \t " + s.statObjectSize + " bytes \t coord="+
|
||||||
" namelen="+s.namesLength);
|
s.statCoordinatesCount+
|
||||||
|
" (" +s.statCoordinates +" bytes) " +
|
||||||
|
" names "+s.namesLength + " bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long out(String s, long i) {
|
private long out(String s, long i) {
|
||||||
while (s.length() < 20) {
|
while (s.length() < 25) {
|
||||||
s += " ";
|
s += " ";
|
||||||
}
|
}
|
||||||
DecimalFormat df = new DecimalFormat("0,000,000,000");
|
DecimalFormat df = new DecimalFormat("0,000,000,000");
|
||||||
|
|
|
@ -950,6 +950,9 @@ public class BinaryMapIndexReader {
|
||||||
BinaryMapDataObject mapObject = readMapDataObject(tree, req, root);
|
BinaryMapDataObject mapObject = readMapDataObject(tree, req, root);
|
||||||
if (mapObject != null) {
|
if (mapObject != null) {
|
||||||
mapObject.setId(mapObject.getId() + baseId);
|
mapObject.setId(mapObject.getId() + baseId);
|
||||||
|
if (READ_STATS) {
|
||||||
|
req.publish(mapObject);
|
||||||
|
}
|
||||||
if (tempResults == null) {
|
if (tempResults == null) {
|
||||||
tempResults = new ArrayList<BinaryMapDataObject>();
|
tempResults = new ArrayList<BinaryMapDataObject>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue