Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
commit 80455be9a35e0906d0b998ba0a091ce9ca960ca4 2 parents 6e0c351 + 26705b7
Richard Shane Detsch authored
View
41 ...trib/src/main/java/com/browseengine/bobo/geosearch/impl/CartesianGeoRecordComparator.java
@@ -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;
+ }
+
+}
View
33 ...trib/src/main/java/com/browseengine/bobo/geosearch/impl/CartesianGeoRecordSerializer.java
@@ -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());
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.