List of usage examples for com.google.common.primitives Longs toArray
public static long[] toArray(Collection<? extends Number> collection)
From source file:org.sosy_lab.cpachecker.util.predicates.z3.Z3BooleanFormulaManager.java
@Override protected Long andImpl(List<Long> params) { return mk_and(z3context, params.size(), Longs.toArray(params)); }
From source file:org.apache.aurora.common.net.http.handlers.ContentionPrinter.java
@GET @Produces(MediaType.TEXT_PLAIN)//from w w w . j av a 2s . co m public String getContention() { List<String> lines = Lists.newLinkedList(); ThreadMXBean bean = ManagementFactory.getThreadMXBean(); Map<Long, StackTraceElement[]> threadStacks = Maps.newHashMap(); for (Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) { threadStacks.put(entry.getKey().getId(), entry.getValue()); } Set<Long> lockOwners = Sets.newHashSet(); lines.add("Locked threads:"); for (ThreadInfo t : bean.getThreadInfo(bean.getAllThreadIds())) { switch (t.getThreadState()) { case BLOCKED: case WAITING: case TIMED_WAITING: lines.addAll(getThreadInfo(t, threadStacks.get(t.getThreadId()))); if (t.getLockOwnerId() != -1) lockOwners.add(t.getLockOwnerId()); break; } } if (lockOwners.size() > 0) { lines.add("\nLock Owners"); for (ThreadInfo t : bean.getThreadInfo(Longs.toArray(lockOwners))) { lines.addAll(getThreadInfo(t, threadStacks.get(t.getThreadId()))); } } return String.join("\n", lines); }
From source file:org.sosy_lab.solver.mathsat5.Mathsat5AbstractProver.java
public boolean isUnsatWithAssumptions(List<BooleanFormula> pAssumptions) throws SolverException, InterruptedException { Preconditions.checkState(curEnv != 0); try {/*from w w w .j av a 2s .c o m*/ long[] assumptions = Longs.toArray(Lists.transform(pAssumptions, new Function<BooleanFormula, Long>() { @Override public Long apply(BooleanFormula pInput) { long t = Mathsat5FormulaManager.getMsatTerm(pInput); if (!useSharedEnv) { t = msat_make_copy_from(curEnv, t, mgr.getEnvironment()); } return t; } })); return !msat_check_sat_with_assumptions(curEnv, assumptions); } catch (IllegalStateException e) { handleSolverExceptionInUnsatCheck(e); throw e; } }
From source file:org.sosy_lab.java_smt.solvers.z3.Z3NumeralFormulaManager.java
@Override public Long sumImpl(List<Long> operands) { return Native.mkAdd(z3context, operands.size(), Longs.toArray(operands)); }
From source file:com.twitter.common.net.http.handlers.ContentionPrinter.java
@Override public Iterable<String> getLines(HttpServletRequest request) { List<String> lines = Lists.newLinkedList(); ThreadMXBean bean = ManagementFactory.getThreadMXBean(); Map<Long, StackTraceElement[]> threadStacks = Maps.newHashMap(); for (Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) { threadStacks.put(entry.getKey().getId(), entry.getValue()); }/*from w w w . j av a 2 s. c om*/ Set<Long> lockOwners = Sets.newHashSet(); lines.add("Locked threads:"); for (ThreadInfo t : bean.getThreadInfo(bean.getAllThreadIds())) { switch (t.getThreadState()) { case BLOCKED: case WAITING: case TIMED_WAITING: lines.addAll(getThreadInfo(t, threadStacks.get(t.getThreadId()))); if (t.getLockOwnerId() != -1) lockOwners.add(t.getLockOwnerId()); break; } } if (lockOwners.size() > 0) { lines.add("\nLock Owners"); for (ThreadInfo t : bean.getThreadInfo(Longs.toArray(lockOwners))) { lines.addAll(getThreadInfo(t, threadStacks.get(t.getThreadId()))); } } return lines; }
From source file:org.apache.cassandra.io.sstable.IndexSummaryBuilder.java
public IndexSummary build(IPartitioner partitioner) { byte[][] keysArray = new byte[keys.size()][]; for (int i = 0; i < keys.size(); i++) keysArray[i] = keys.get(i);/*from w w w.j av a 2 s. c o m*/ return new IndexSummary(partitioner, keysArray, Longs.toArray(positions)); }
From source file:org.sosy_lab.solver.z3.Z3NumeralFormulaManager.java
@Override public Long sumImpl(List<Long> operands) { return mk_add(z3context, operands.size(), Longs.toArray(operands)); }
From source file:com.jeanchampemont.wtfdyum.service.feature.impl.NotifyUnfollowFeatureStrategy.java
@Override public Set<Event> cron(final Long userId) throws WTFDYUMException { final Set<Event> result = new HashSet<>(); final Principal principal = principalService.get(userId); final Set<Long> followers = twitterService.getFollowers(userId, Optional.ofNullable(principal)); final Set<Long> unfollowersId = followersService.getUnfollowers(userId, followers); final List<User> unfollowers = twitterService.getUsers(principal, Longs.toArray(unfollowersId)); for (final User unfollower : unfollowers) { result.add(new Event(EventType.UNFOLLOW, unfollower.getScreenName())); twitterService.sendDirectMessage(principal, userId, String.format(unfollowDMText, unfollower.getScreenName())); }/* ww w.ja v a 2 s. c o m*/ return result; }
From source file:com.jeanchampemont.wtfdyum.service.feature.impl.TweetUnfollowFeatureStrategy.java
@Override public Set<Event> cron(final Long userId) throws WTFDYUMException { final Set<Event> result = new HashSet<>(); final Principal principal = principalService.get(userId); final Set<Long> followers = twitterService.getFollowers(userId, Optional.ofNullable(principal)); final Set<Long> unfollowersId = followersService.getUnfollowers(userId, followers); final List<User> unfollowers = twitterService.getUsers(principal, Longs.toArray(unfollowersId)); for (final User unfollower : unfollowers) { result.add(new Event(EventType.UNFOLLOW, unfollower.getScreenName())); twitterService.tweet(principal, String.format(unfollowTweetText, unfollower.getScreenName())); }// ww w . ja v a2 s . c om return result; }
From source file:org.sosy_lab.java_smt.solvers.z3.Z3BooleanFormulaManager.java
@Override protected Long orImpl(Collection<Long> params) { if (params.size() == 2) { Iterator<Long> it = params.iterator(); return or(it.next(), it.next()); }//w ww .j a va2 s . c o m return Native.mkOr(z3context, params.size(), Longs.toArray(params)); }