List of usage examples for java.lang Long compare
public static int compare(long x, long y)
From source file:org.apache.distributedlog.service.placement.StreamLoad.java
@Override public int compareTo(Object o) { StreamLoad other = (StreamLoad) o;// w w w . j av a2s .co m if (load == other.getLoad()) { return stream.compareTo(other.getStream()); } else { return Long.compare(load, other.getLoad()); } }
From source file:org.apache.ranger.plugin.geo.RangerGeolocationData.java
@Override public int compareTo(final RangerGeolocationData other) { int ret = (other == null) ? 1 : 0; if (ret == 0) { ret = Long.compare(fromIPAddress, other.fromIPAddress); if (ret == 0) { ret = Long.compare(toIPAddress, other.toIPAddress); if (ret == 0) { ret = Integer.compare(locationData.length, other.locationData.length); for (int i = 0; ret == 0 && i < locationData.length; i++) { ret = stringCompareTo(locationData[i], other.locationData[i]); }/*from w w w .j a v a 2 s. co m*/ } } } return ret; }
From source file:org.ng200.openolympus.controller.user.SolutionStatusController.java
@RequestMapping(value = "/solution", method = RequestMethod.GET) public String viewSolutionStatus(final HttpServletRequest request, final Model model, @RequestParam(value = "id") final Solution solution, final Principal principal) { if (principal == null || (!solution.getUser().getUsername().equals(principal.getName()) && !request.isUserInRole(Role.SUPERUSER))) { throw new InsufficientAuthenticationException( "You attempted to view a solution that doesn't belong to you!"); }/*from ww w. j a va2 s. co m*/ this.assertSuperuserOrTaskAllowed(principal, solution.getTask()); model.addAttribute("solution", solution); final List<Verdict> verdicts = this.solutionService.getVerdicts(solution); model.addAttribute("completeScore", verdicts.stream().map((x) -> x.getScore()).reduce((x, y) -> x.add(y)).orElse(BigDecimal.ZERO)); model.addAttribute("completeMaximumScore", verdicts.stream().map((x) -> x.getMaximumScore()) .reduce((x, y) -> x.add(y)).orElse(BigDecimal.ZERO)); model.addAttribute("verdicts", verdicts.stream().sorted((l, r) -> Long.compare(l.getId(), r.getId())) .collect(Collectors.toList())); model.addAttribute("verdictMessageStrings", new HashMap<SolutionResult.Result, String>() { /** * */ private static final long serialVersionUID = 8526897014680785208L; { this.put(SolutionResult.Result.OK, "solution.result.ok"); this.put(SolutionResult.Result.TIME_LIMIT, "solution.result.timeLimit"); this.put(SolutionResult.Result.MEMORY_LIMIT, "solution.result.memoryLimit"); this.put(SolutionResult.Result.OUTPUT_LIMIT, "solution.result.outputLimit"); this.put(SolutionResult.Result.RUNTIME_ERROR, "solution.result.runtimeError"); this.put(SolutionResult.Result.INTERNAL_ERROR, "solution.result.internalError"); this.put(SolutionResult.Result.SECURITY_VIOLATION, "solution.result.securityViolation"); this.put(SolutionResult.Result.COMPILE_ERROR, "solution.result.compileError"); this.put(SolutionResult.Result.PRESENTATION_ERROR, "solution.result.presentationError"); this.put(SolutionResult.Result.WRONG_ANSWER, "solution.result.wrongAnswer"); } }); return "tasks/solution"; }
From source file:io.servicecomb.serviceregistry.version.Version.java
@Override public int compareTo(Version other) { return Long.compare(numberVersion, other.numberVersion); }
From source file:com.freiheit.fuava.sftp.util.FilenameUtil.java
/** * Returns the lastest date/time from a list of filenames. */// w ww. j av a2 s. c om @CheckForNull public static String extractLatestDateFromFilenames(final List<String> entryList, final FileType fileType, @Nullable final RemoteFileStatus status) throws ParseException { final Optional<String> maxDate = entryList.stream().filter(p -> p != null) .filter(f -> FilenameUtil.matchesSearchedFile(f, fileType, null, status)) .max((a, b) -> Long.compare(getDateFromFilename(a), getDateFromFilename(b))); if (!maxDate.isPresent()) { return null; // no timestamp found } final String max = maxDate.get(); return String.valueOf(getDateFromFilenameWithDelimiter(max)); }
From source file:org.artifactory.storage.db.build.entity.BuildPromotionStatus.java
@Override public int compareTo(BuildPromotionStatus o) { if (buildId != o.buildId) { return Long.compare(buildId, o.buildId); }/*from w w w .j a v a 2 s . com*/ return Long.compare(created, o.created); }
From source file:de.qaware.chronix.storage.solr.timeseries.metric.MetricTimeSeries.java
/** * Sorts the time series values.//from ww w.j a v a 2 s. c o m */ public void sort() { if (timestamps.size() > 1) { LongList sortedTimes = new LongList(timestamps.size()); DoubleList sortedValues = new DoubleList(values.size()); points().sorted((o1, o2) -> Long.compare(o1.getTimestamp(), o2.getTimestamp())).forEachOrdered(p -> { sortedTimes.add(p.getTimestamp()); sortedValues.add(p.getValue()); }); timestamps = sortedTimes; values = sortedValues; } }
From source file:com.asakusafw.runtime.directio.hadoop.DirectIoTransactionEditor.java
/** * Lists Direct I/O transaction information. * @return transactions, or an empty list if not exist * @throws IOException if failed to obtain transactions information * @throws IllegalArgumentException if some parameters were {@code null} *//*w ww . j ava 2 s. c om*/ public List<TransactionInfo> list() throws IOException { LOG.info("Start listing Direct I/O transactions"); List<FileStatus> list = new ArrayList<>(HadoopDataSourceUtil.findAllTransactionInfoFiles(getConf())); if (list.isEmpty()) { LOG.info("There are no Direct I/O transactions"); return Collections.emptyList(); } Collections.sort(list, (o1, o2) -> Long.compare(o1.getModificationTime(), o2.getModificationTime())); LOG.info(MessageFormat.format("Start extracting {0} Direct I/O commit information", list.size())); List<TransactionInfo> results = new ArrayList<>(); for (FileStatus stat : list) { TransactionInfo commitObject = toInfoObject(stat); if (commitObject != null) { results.add(commitObject); } } LOG.info("Finish listing Direct I/O transactions"); return results; }
From source file:sf.net.experimaestro.manager.plans.OrderBy.java
@Override protected Iterator<ReturnValue> _iterator(final ScriptContext scriptContext) { return new AbstractIterator<ReturnValue>() { public Iterator<Value> iterator; @Override//from w w w. jav a 2 s. c o m protected ReturnValue computeNext() { if (iterator == null) { ObjectArrayList<Value> list = new ObjectArrayList<>(new Value[0]); { Iterator<Value> iterator = input.iterator(scriptContext); while (iterator.hasNext()) { list.add(iterator.next()); } } Value values[] = list.toArray(new Value[list.size()]); Arrays.sort(values, (o1, o2) -> { for (int index : contextOrder) { int z = Long.compare(o1.context[index], o2.context[index]); if (z != 0) return z; } return 0; }); iterator = Arrays.asList(values).iterator(); } if (iterator.hasNext()) { Value value = iterator.next(); return new ReturnValue(new DefaultContexts(value.context), value.nodes); } return endOfData(); } }; }
From source file:org.apache.hadoop.hbase.regionserver.MetricsTableSourceImpl.java
@Override public int compareTo(MetricsTableSource source) { if (!(source instanceof MetricsTableSourceImpl)) { return -1; }// w w w .j av a 2s .c o m MetricsTableSourceImpl impl = (MetricsTableSourceImpl) source; if (impl == null) { return -1; } return Long.compare(hashCode, impl.hashCode); }