Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Shane Detsch committed Jul 5, 2012
2 parents 6e0c351 + 26705b7 commit 80455be
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
@@ -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.