From 9985bf46ad72f1ce3f984343dcf3ef22a5106485 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 3 Jan 2021 23:40:40 +0100 Subject: [PATCH] Update Javadoc --- src.java/crosby/binary/BinaryParser.java | 6 ++---- src.java/crosby/binary/BinarySerializer.java | 4 ++-- src.java/crosby/binary/StringTable.java | 14 +++++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src.java/crosby/binary/BinaryParser.java b/src.java/crosby/binary/BinaryParser.java index 7a1d9c1..16305bb 100644 --- a/src.java/crosby/binary/BinaryParser.java +++ b/src.java/crosby/binary/BinaryParser.java @@ -23,7 +23,6 @@ import java.util.List; import com.google.protobuf.InvalidProtocolBufferException; -import crosby.binary.Osmformat; import crosby.binary.file.BlockReaderAdapter; import crosby.binary.file.FileBlock; import crosby.binary.file.FileBlockPosition; @@ -47,8 +46,8 @@ public abstract class BinaryParser implements BlockReaderAdapter { /** Get a string based on the index used. * * Index 0 is reserved to use as a delimiter, therefore, index 1 corresponds to the first string in the table - * @param id - * @return + * @param id the index + * @return the string at the given index */ protected String getStringById(int id) { return strings[id]; @@ -56,7 +55,6 @@ public abstract class BinaryParser implements BlockReaderAdapter { @Override public void handleBlock(FileBlock message) { - // TODO Auto-generated method stub try { if (message.getType().equals("OSMHeader")) { Osmformat.HeaderBlock headerblock = Osmformat.HeaderBlock diff --git a/src.java/crosby/binary/BinarySerializer.java b/src.java/crosby/binary/BinarySerializer.java index 6ec1e56..999118e 100644 --- a/src.java/crosby/binary/BinarySerializer.java +++ b/src.java/crosby/binary/BinarySerializer.java @@ -69,11 +69,11 @@ public class BinarySerializer implements Closeable, Flushable { this.batch_limit = batch_limit; } - // Paramaters affecting the output size. + // Parameters affecting the output size. protected final int MIN_DENSE = 10; protected int batch_limit = 4000; - // Parmaters affecting the output. + // Parameters affecting the output. protected int granularity = 100; protected int date_granularity = 1000; diff --git a/src.java/crosby/binary/StringTable.java b/src.java/crosby/binary/StringTable.java index 7f704b0..657c7d9 100644 --- a/src.java/crosby/binary/StringTable.java +++ b/src.java/crosby/binary/StringTable.java @@ -24,7 +24,7 @@ import java.util.HashMap; import com.google.protobuf.ByteString; /** - * Class for mapping a set of strings to integers, giving frequently occuring + * Class for mapping a set of strings to integers, giving frequently occurring * strings small integers. */ public class StringTable { @@ -36,6 +36,10 @@ public class StringTable { private HashMap stringmap; private String[] set; + /** + * Increments the count of the given string + * @param s the string + */ public void incr(String s) { counts.merge(s, 1, Integer::sum); } @@ -43,8 +47,8 @@ public class StringTable { /** After the stringtable has been built, return the offset of a string in it. * * Note, value '0' is reserved for use as a delimiter and will not be returned. - * @param s - * @return + * @param s the string to lookup + * @return the offset of the string */ public int getIndex(String s) { return stringmap.get(s); @@ -78,7 +82,7 @@ public class StringTable { So, when I decide on the master stringtable to use, I put the 127 most frequently occurring strings into A (accomplishing goal 1), and sort them by frequency (to accomplish goal 2), but for B and C, which contain the less progressively less frequently encountered strings, I sort - them lexiconographically, to maximize goal 3 and ignoring goal 2. + them lexicographically, to maximize goal 3 and ignoring goal 2. Goal 1 is the most important. Goal 2 helped enough to be worth it, and goal 3 was pretty minor, but all should be re-benchmarked. @@ -93,7 +97,7 @@ public class StringTable { // Sort based on the frequency. Arrays.sort(set, comparator); // Each group of keys that serializes to the same number of bytes is - // sorted lexiconographically. + // sorted lexicographically. // to maximize deflate compression. // Don't sort the first array. There's not likely to be much benefit, and we want frequent values to be small.