Update Javadoc
This commit is contained in:
parent
712c8cacf7
commit
9985bf46ad
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||||
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
import crosby.binary.Osmformat;
|
|
||||||
import crosby.binary.file.BlockReaderAdapter;
|
import crosby.binary.file.BlockReaderAdapter;
|
||||||
import crosby.binary.file.FileBlock;
|
import crosby.binary.file.FileBlock;
|
||||||
import crosby.binary.file.FileBlockPosition;
|
import crosby.binary.file.FileBlockPosition;
|
||||||
|
|
@ -47,8 +46,8 @@ public abstract class BinaryParser implements BlockReaderAdapter {
|
||||||
/** Get a string based on the index used.
|
/** 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
|
* Index 0 is reserved to use as a delimiter, therefore, index 1 corresponds to the first string in the table
|
||||||
* @param id
|
* @param id the index
|
||||||
* @return
|
* @return the string at the given index
|
||||||
*/
|
*/
|
||||||
protected String getStringById(int id) {
|
protected String getStringById(int id) {
|
||||||
return strings[id];
|
return strings[id];
|
||||||
|
|
@ -56,7 +55,6 @@ public abstract class BinaryParser implements BlockReaderAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleBlock(FileBlock message) {
|
public void handleBlock(FileBlock message) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
try {
|
try {
|
||||||
if (message.getType().equals("OSMHeader")) {
|
if (message.getType().equals("OSMHeader")) {
|
||||||
Osmformat.HeaderBlock headerblock = Osmformat.HeaderBlock
|
Osmformat.HeaderBlock headerblock = Osmformat.HeaderBlock
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,11 @@ public class BinarySerializer implements Closeable, Flushable {
|
||||||
this.batch_limit = batch_limit;
|
this.batch_limit = batch_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paramaters affecting the output size.
|
// Parameters affecting the output size.
|
||||||
protected final int MIN_DENSE = 10;
|
protected final int MIN_DENSE = 10;
|
||||||
protected int batch_limit = 4000;
|
protected int batch_limit = 4000;
|
||||||
|
|
||||||
// Parmaters affecting the output.
|
// Parameters affecting the output.
|
||||||
|
|
||||||
protected int granularity = 100;
|
protected int granularity = 100;
|
||||||
protected int date_granularity = 1000;
|
protected int date_granularity = 1000;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import java.util.HashMap;
|
||||||
import com.google.protobuf.ByteString;
|
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.
|
* strings small integers.
|
||||||
*/
|
*/
|
||||||
public class StringTable {
|
public class StringTable {
|
||||||
|
|
@ -36,6 +36,10 @@ public class StringTable {
|
||||||
private HashMap<String, Integer> stringmap;
|
private HashMap<String, Integer> stringmap;
|
||||||
private String[] set;
|
private String[] set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increments the count of the given string
|
||||||
|
* @param s the string
|
||||||
|
*/
|
||||||
public void incr(String s) {
|
public void incr(String s) {
|
||||||
counts.merge(s, 1, Integer::sum);
|
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.
|
/** 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.
|
* Note, value '0' is reserved for use as a delimiter and will not be returned.
|
||||||
* @param s
|
* @param s the string to lookup
|
||||||
* @return
|
* @return the offset of the string
|
||||||
*/
|
*/
|
||||||
public int getIndex(String s) {
|
public int getIndex(String s) {
|
||||||
return stringmap.get(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
|
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
|
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
|
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,
|
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.
|
but all should be re-benchmarked.
|
||||||
|
|
@ -93,7 +97,7 @@ public class StringTable {
|
||||||
// Sort based on the frequency.
|
// Sort based on the frequency.
|
||||||
Arrays.sort(set, comparator);
|
Arrays.sort(set, comparator);
|
||||||
// Each group of keys that serializes to the same number of bytes is
|
// Each group of keys that serializes to the same number of bytes is
|
||||||
// sorted lexiconographically.
|
// sorted lexicographically.
|
||||||
// to maximize deflate compression.
|
// 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.
|
// Don't sort the first array. There's not likely to be much benefit, and we want frequent values to be small.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue