yql.append(", "); Class<? extends AttributeSorter> sorterType = f.getSorter().getClass(); if (sorterType == Sorting.RawSorter.class) { yql.append("[{\"") .append("\"}]"); } else if (sorterType == Sorting.UcaSorter.class) { Sorting.UcaSorter uca = (Sorting.UcaSorter) f.getSorter(); String ucaLocale = uca.getLocale(); Sorting.UcaSorter.Strength ucaStrength = uca.getStrength();
public int encode(ByteBuffer buffer) { int usedBytes = 0; byte[] nameBuffer; buffer.position(); byte space = '.'; for (FieldOrder fieldOrder : fieldOrders) { if (space == ' ') { buffer.put(space); usedBytes++; } if (fieldOrder.getSortOrder() == Order.ASCENDING) { buffer.put((byte) '+'); } else { buffer.put((byte) '-'); } usedBytes++; nameBuffer = Utf8.toBytes(fieldOrder.getSorter().toString()); buffer.put(nameBuffer); usedBytes += nameBuffer.length; // If this isn't the last element, append a separating space //if (i + 1 < sortSpec.size()) { space = ' '; } return usedBytes; }
f.getSorter().setName("[rank]"); } else if (names.containsKey(name)) { AttributesConfig.Attribute attrConfig = names.get(name); f.setAscending(attrConfig.sortascending()); if (f.getSorter().getClass().equals(Sorting.AttributeSorter.class)) { if (f.getSorter() instanceof Sorting.UcaSorter) { Sorting.UcaSorter sorter = (Sorting.UcaSorter) f.getSorter(); String locale = sorter.getLocale();
/** * Compares hits based on a sorting specification and values * stored in hit fields.0 * <p> * When one of the hits has the requested property and the other * has not, the the hit containing the property precedes the one * that does not. * <p> * There is no locale based sorting here, as the backend does * not do that either. * * @return -1, 0, 1 if first should be sorted before, equal to * or after second */ @Override public int compare(Hit first, Hit second) { for (Sorting.FieldOrder fieldOrder : sorting.fieldOrders() ) { String fieldName = fieldOrder.getFieldName(); Object a = getField(first,fieldName); Object b = getField(second,fieldName); int x = compareValues(a, b, fieldOrder.getSorter()); if (x != 0) { if (fieldOrder.getSortOrder() == Sorting.Order.DESCENDING) x *= -1; return x; } } return super.compare(first,second); }