use of org.apache.hyracks.api.dataflow.value.ILinearizeComparator in project asterixdb by apache.
the class LinearizeComparatorFactoryProvider method addOffset.
private ILinearizeComparatorFactory addOffset(final IBinaryComparatorFactory inst, final boolean ascending) {
return new ILinearizeComparatorFactory() {
private static final long serialVersionUID = 1L;
@Override
public ILinearizeComparator createBinaryComparator() {
final ILinearizeComparator bc = (ILinearizeComparator) inst.createBinaryComparator();
final int dimension = bc.getDimensions();
if (ascending) {
return new ILinearizeComparator() {
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
return bc.compare(b1, s1 + 1, l1, b2, s2 + 1, l2);
}
@Override
public int getDimensions() {
// TODO Auto-generated method stub
return dimension;
}
};
} else {
return new ILinearizeComparator() {
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
return -bc.compare(b1, s1 + 1, l1, b2, s2 + 1, l2);
}
@Override
public int getDimensions() {
// TODO Auto-generated method stub
return dimension;
}
};
}
}
};
}
Aggregations