Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 6e0c351 + 26705b7 commit 80455be9a35e0906d0b998ba0a091ce9ca960ca4 Richard Shane Detsch committed Jul 5, 2012
@@ -0,0 +1,41 @@
+package com.browseengine.bobo.geosearch.impl;
+
+import java.util.Comparator;
+
+import com.browseengine.bobo.geosearch.bo.CartesianGeoRecord;
+
+/**
+ *
+ * Basic comparator for CartesianGeoRecords
+ *
+ * @author gcooney
+ *
+ */
+public class CartesianGeoRecordComparator implements Comparator<CartesianGeoRecord> {
+ @Override
+ public int compare(CartesianGeoRecord recordFirst, CartesianGeoRecord recordSecond) {
+ long highdiff = recordFirst.highOrder - recordSecond.highOrder;
+ if(highdiff > 0) {
+ return 1;
+ }
+ if (highdiff < 0) {
+ return -1;
+ }
+ long lowdiff = recordFirst.lowOrder - recordSecond.lowOrder;
+ if(lowdiff > 0) {
+ return 1;
+ }
+ if (lowdiff < 0) {
+ return -1;
+ }
+
+ if (recordFirst.filterByte > recordSecond.filterByte) {
+ return 1;
+ } else if (recordFirst.filterByte < recordSecond.filterByte) {
+ return -1;
+ }
+
+ return 0;
+ }
+
+}
@@ -0,0 +1,33 @@
+package com.browseengine.bobo.geosearch.impl;
+
+import java.io.IOException;
+
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+
+import com.browseengine.bobo.geosearch.IGeoRecordSerializer;
+import com.browseengine.bobo.geosearch.bo.CartesianGeoRecord;
+
+/**
+ * Basic Serializer for CartesianGeoRecords
+ *
+ * @author gcooney
+ *
+ */
+public class CartesianGeoRecordSerializer implements IGeoRecordSerializer<CartesianGeoRecord> {
+
+ @Override
+ public void writeGeoRecord(IndexOutput output, CartesianGeoRecord record, int recordByteCount) throws IOException {
+ output.writeLong(record.highOrder);
+ output.writeLong(record.lowOrder);
+ output.writeByte(record.filterByte);
+ }
+
+ @Override
+ public CartesianGeoRecord readGeoRecord(IndexInput input, int recordByteCount) throws IOException {
+ return new CartesianGeoRecord(input.readLong(),
+ input.readLong(),
+ input.readByte());
+ }
+
+}

0 comments on commit 80455be

Please sign in to comment.