forked from senseidb/bobo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...trib/src/main/java/com/browseengine/bobo/geosearch/impl/CartesianGeoRecordComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
|
|||
} |
33 changes: 33 additions & 0 deletions
33
...trib/src/main/java/com/browseengine/bobo/geosearch/impl/CartesianGeoRecordSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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()); | |||
} | |||
|
|||
} |