List of usage examples for com.google.common.primitives Longs compare
public static int compare(long a, long b)
From source file:fr.putnami.pwt.core.widget.client.assist.SimpleOracle.java
@Override public void doRequest(Request request, Callback<T> callback) { List<Suggestion<T>> suggestions = Lists.newArrayList(); String query = request.getQuery(); for (T value : allSuggestions) { int relevance = getMatcher().match(value, query); if (relevance > 0) { suggestions.add(newSuggestion(query, value, relevance)); }// w w w.j av a2s . c o m } Collections.sort(suggestions, new Comparator<Suggestion<T>>() { @Override public int compare(Suggestion<T> o1, Suggestion<T> o2) { return Longs.compare(o2.getRelevance(), o1.getRelevance()); } }); Response<T> response = new Response<T>(suggestions); int limit = request.getLimit(); if (limit > 0 && suggestions.size() > limit) { response.setMoreSuggestionsCount(suggestions.size() - limit); response.setSuggestions(suggestions.subList(0, limit)); } callback.onSuggestionsReady(request, response); }
From source file:com.metamx.druid.index.v1.Rowboat.java
@Override public int compareTo(Rowboat rhs) { int retVal = Longs.compare(timestamp, rhs.timestamp); if (retVal == 0) { retVal = Ints.compare(dims.length, rhs.dims.length); }/*w w w . j ava 2s . c o m*/ int index = 0; while (retVal == 0 && index < dims.length) { int[] lhsVals = dims[index]; int[] rhsVals = rhs.dims[index]; if (lhsVals == null) { if (rhsVals == null) { index++; continue; } return -1; } if (rhsVals == null) { return 1; } retVal = Ints.compare(lhsVals.length, rhsVals.length); int valsIndex = 0; while (retVal == 0 && valsIndex < lhsVals.length) { retVal = Ints.compare(lhsVals[valsIndex], rhsVals[valsIndex]); ++valsIndex; } ++index; } return retVal; }
From source file:org.cinchapi.concourse.util.Version.java
@Override public int compareTo(Version o) { int comp;// ww w . j av a2 s .c om return (comp = Longs.compare(major, o.major)) == 0 ? (comp = Longs.compare(minor, o.minor)) == 0 ? (comp = Longs.compare(patch, o.patch)) == 0 ? (build.compareTo(o.build)) : comp : comp : comp; }
From source file:io.druid.indexing.common.actions.SegmentAllocateAction.java
public static List<Granularity> granularitiesFinerThan(final Granularity gran0) { final DateTime epoch = new DateTime(0); final List<Granularity> retVal = Lists.newArrayList(); for (Granularity gran : Granularity.values()) { if (gran.bucket(epoch).toDurationMillis() <= gran0.bucket(epoch).toDurationMillis()) { retVal.add(gran);// ww w .j ava 2 s .c om } } Collections.sort(retVal, new Comparator<Granularity>() { @Override public int compare(Granularity g1, Granularity g2) { return Longs.compare(g2.bucket(epoch).toDurationMillis(), g1.bucket(epoch).toDurationMillis()); } }); return retVal; }
From source file:io.druid.server.coordinator.ServerHolder.java
@Override public int compareTo(ServerHolder serverHolder) { int result = Longs.compare(getAvailableSize(), serverHolder.getAvailableSize()); if (result != 0) { return result; }/*from ww w. j av a 2 s . c om*/ result = server.getHost().compareTo(serverHolder.server.getHost()); if (result != 0) { return result; } result = server.getTier().compareTo(serverHolder.server.getTier()); if (result != 0) { return result; } return server.getType().compareTo(serverHolder.server.getType()); }
From source file:com.greplin.interval.LongInterval.java
@Override public int compareTo(final LongInterval other) { return Longs.compare(this.start, other.start); }
From source file:org.geogig.osm.internal.history.Changeset.java
@Override public int compareTo(Changeset o) { return Longs.compare(this.id, o.getId()); }
From source file:co.cask.cdap.explore.executor.AbstractExploreQueryExecutorHttpHandler.java
protected List<QueryInfo> filterQueries(List<QueryInfo> queries, final long offset, final boolean isForward, final int limit) { // Reverse the list if the pagination is in the reverse from the offset until the max limit if (!isForward) { queries = Lists.reverse(queries); }//from w ww . j a v a 2s . co m return FluentIterable.from(queries).filter(new Predicate<QueryInfo>() { @Override public boolean apply(QueryInfo queryInfo) { if (isForward) { return queryInfo.getTimestamp() < offset; } else { return queryInfo.getTimestamp() > offset; } } }).limit(limit).toSortedImmutableList(new Comparator<QueryInfo>() { @Override public int compare(QueryInfo first, QueryInfo second) { //sort descending. return Longs.compare(second.getTimestamp(), first.getTimestamp()); } }); }
From source file:co.cask.tigon.internal.app.runtime.flow.FlowletProcessEntry.java
@Override public int compareTo(FlowletProcessEntry o) { return Longs.compare(nextDeque, o.nextDeque); }
From source file:org.projectfloodlight.openflow.types.OduSigid.java
@Override public int compareTo(OduSigid o) { return Longs.compare(rawValue, o.rawValue); }