Skip to content

Commit

Permalink
Serialize (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
jklamer authored and MikeGost committed Aug 6, 2018
1 parent 07241ee commit d6deecf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class ShardBucketCollection<LocatedType extends Located & Serial
* A helper class that associates a shard with the index that its collection is at in the
* collectionBuckets array.
*/
private static class ShardToCollectionIndex implements Located
private static class ShardToCollectionIndex implements Located, Serializable
{
private static final long serialVersionUID = 4050100671815503794L;
private final int index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openstreetmap.atlas.geography.sharding.SlippyTile;
import org.openstreetmap.atlas.utilities.maps.MultiMap;
import org.openstreetmap.atlas.utilities.scalars.Distance;
import org.openstreetmap.atlas.utilities.testing.FreezeDryFunction;

/**
* Test for example {@link ShardBucketCollection}s
Expand All @@ -31,7 +32,7 @@ public void testMultiPolygonSort()
final Rectangle maxBounds = SlippyTile.forName("1-0-0").bounds()
.contract(Distance.ONE_METER);

final ShardBucketCollectionTestClasses.MultiPolygonSort multiPolygonSort = new ShardBucketCollectionTestClasses.MultiPolygonSort(
ShardBucketCollectionTestClasses.MultiPolygonSort multiPolygonSort = new ShardBucketCollectionTestClasses.MultiPolygonSort(
maxBounds, 4);

final MultiPolygon firstShardMultiPolygon = this
Expand All @@ -47,6 +48,12 @@ public void testMultiPolygonSort()
Assert.assertTrue(multiPolygonSort.contains(firstShardMultiPolygon));
Assert.assertTrue(multiPolygonSort.contains(secondShardMultiPolygon));

// test serialization
multiPolygonSort = new FreezeDryFunction<ShardBucketCollectionTestClasses.MultiPolygonSort>()
.apply(multiPolygonSort);
Assert.assertTrue(multiPolygonSort.contains(firstShardMultiPolygon));
Assert.assertTrue(multiPolygonSort.contains(secondShardMultiPolygon));

// make a multipolygon with an outer for every shard and ensure they all get sorted into
// their proper buckets
multiPolygonSort.clear();
Expand Down

0 comments on commit d6deecf

Please sign in to comment.