List of usage examples for java.lang Long MAX_VALUE
long MAX_VALUE
To view the source code for java.lang Long MAX_VALUE.
Click Source Link
From source file:ffx.numerics.fft.Real3DCuda.java
/** * <p>//w w w . j av a2 s . co m * main</p> * * @param args an array of {@link java.lang.String} objects. * @throws java.lang.Exception if any. */ public static void main(String[] args) throws Exception { int dimNotFinal = 64; int reps = 10; if (args != null) { try { dimNotFinal = Integer.parseInt(args[0]); if (dimNotFinal < 1) { dimNotFinal = 64; } reps = Integer.parseInt(args[1]); if (reps < 1) { reps = 5; } } catch (Exception e) { } } if (dimNotFinal % 2 != 0) { dimNotFinal++; } final int dim = dimNotFinal; System.out.println(String.format( "Initializing a %d cubed grid.\n" + "The best timing out of %d repititions will be used.", dim, reps)); final int dimCubed = dim * dim * dim; final int dimCubed2 = (dim + 2) * dim * dim; /** * Create an array to save the initial input and result. */ final double orig[] = new double[dimCubed2]; final double answer[] = new double[dimCubed2]; final double data[] = new double[dimCubed2]; final double recip[] = new double[dimCubed]; final float origf[] = new float[dimCubed2]; final float dataf[] = new float[dimCubed2]; final float recipf[] = new float[dimCubed]; Random randomNumberGenerator = new Random(1); int index = 0; int index2 = 0; /** * Row-major order. */ for (int x = 0; x < dim; x++) { for (int y = 0; y < dim; y++) { for (int z = 0; z < dim; z++) { float randomNumber = randomNumberGenerator.nextFloat(); orig[index] = randomNumber; origf[index] = randomNumber; index++; recip[index2] = 1.0; recipf[index2] = 1.0f; index2++; } // Padding index += 2; } } Real3D real3D = new Real3D(dim, dim, dim); Real3DParallel real3DParallel = new Real3DParallel(dim, dim, dim, new ParallelTeam(), IntegerSchedule.fixed()); Real3DCuda real3DCUDA = new Real3DCuda(dim, dim, dim, dataf, recipf); Thread cudaThread = new Thread(real3DCUDA); cudaThread.setPriority(Thread.MAX_PRIORITY); cudaThread.start(); double toSeconds = 0.000000001; long parTime = Long.MAX_VALUE; long seqTime = Long.MAX_VALUE; long clTime = Long.MAX_VALUE; real3D.setRecip(recip); for (int i = 0; i < reps; i++) { System.arraycopy(orig, 0, data, 0, dimCubed2); long time = System.nanoTime(); real3D.convolution(data); time = (System.nanoTime() - time); System.out.println(String.format("%2d Sequential: %8.3f", i + 1, toSeconds * time)); if (time < seqTime) { seqTime = time; } } System.arraycopy(data, 0, answer, 0, dimCubed2); real3DParallel.setRecip(recip); for (int i = 0; i < reps; i++) { System.arraycopy(orig, 0, data, 0, dimCubed2); long time = System.nanoTime(); real3DParallel.convolution(data); time = (System.nanoTime() - time); System.out.println(String.format("%2d Parallel: %8.3f", i + 1, toSeconds * time)); if (time < parTime) { parTime = time; } } double maxError = Double.MIN_VALUE; double rmse = 0.0; index = 0; for (int x = 0; x < dim; x++) { for (int y = 0; y < dim; y++) { for (int z = 0; z < dim; z++) { double error = Math.abs((orig[index] - data[index] / dimCubed)); if (error > maxError) { maxError = error; } rmse += error * error; index++; } index += 2; } } rmse /= dimCubed; rmse = Math.sqrt(rmse); logger.info(String.format("Parallel RMSE: %12.10f, Max: %12.10f", rmse, maxError)); for (int i = 0; i < reps; i++) { System.arraycopy(origf, 0, dataf, 0, dimCubed2); long time = System.nanoTime(); real3DCUDA.convolution(dataf); time = (System.nanoTime() - time); System.out.println(String.format("%2d CUDA: %8.3f", i + 1, toSeconds * time)); if (time < clTime) { clTime = time; } } real3DCUDA.free(); real3DCUDA = null; maxError = Double.MIN_VALUE; double avg = 0.0; rmse = 0.0; index = 0; for (int x = 0; x < dim; x++) { for (int y = 0; y < dim; y++) { for (int z = 0; z < dim; z++) { if (Float.isNaN(dataf[index])) { logger.info(String.format("Not a number %d %d %d", x, y, z)); System.exit(-1); } double error = Math.abs(origf[index] - dataf[index]); avg += error; if (error > maxError) { maxError = error; } rmse += error * error; index++; } index += 2; } } rmse /= dimCubed; avg /= dimCubed; rmse = Math.sqrt(rmse); logger.info(String.format("CUDA RMSE: %12.10f, Max: %12.10f, Avg: %12.10f", rmse, maxError, avg)); System.out.println(String.format("Best Sequential Time: %8.3f", toSeconds * seqTime)); System.out.println(String.format("Best Parallel Time: %8.3f", toSeconds * parTime)); System.out.println(String.format("Best CUDA Time: %8.3f", toSeconds * clTime)); System.out.println(String.format("Parallel Speedup: %15.5f", (double) seqTime / parTime)); System.out.println(String.format("CUDA Speedup: %15.5f", (double) seqTime / clTime)); }
From source file:com.doctor.ganymed_ssh2.SSHAgent.java
/** * Why can't I execute several commands in one single session? * /*from w w w . j a va 2s.c om*/ * If you use Session.execCommand(), then you indeed can only execute only one command per session. This is not a restriction of the library, but rather an enforcement by the underlying SSH-2 protocol (a Session object models the underlying SSH-2 session). * * There are several solutions: * * Simple: Execute several commands in one batch, e.g., something like Session.execCommand("echo Hello && echo again"). * Simple: The intended way: simply open a new session for each command - once you have opened a connection, you can ask for as many sessions as you want, they are only a "virtual" construct. * Advanced: Don't use Session.execCommand(), but rather aquire a shell with Session.startShell(). * * @param command * @return * @throws IOException */ public String execCommand(String command) throws IOException { Session session = connection.openSession(); session.execCommand(command, StandardCharsets.UTF_8.toString()); InputStream streamGobbler = new StreamGobbler(session.getStdout()); String result = IOUtils.toString(streamGobbler, StandardCharsets.UTF_8); session.waitForCondition(ChannelCondition.EXIT_SIGNAL, Long.MAX_VALUE); if (session.getExitStatus().intValue() == 0) { log.info("execCommand: {} success ", command); } else { log.error("execCommand : {} fail", command); } IOUtils.closeQuietly(streamGobbler); session.close(); return result; }
From source file:info.archinnov.achilles.it.TestTypedQueries.java
@Test public void should_perform_prepared_typed_query() throws Exception { //Given// ww w. j a va 2 s . c om final Long id = RandomUtils.nextLong(0L, Long.MAX_VALUE); scriptExecutor.executeScriptTemplate("SimpleEntity/insert_single_row.cql", ImmutableMap.of("id", id, "table", "simple")); final PreparedStatement preparedStatement = session.prepare("SELECT * FROM simple WHERE id = :id"); //When final SimpleEntity actual = manager.query().typedQueryForSelect(preparedStatement, id).getOne(); //Then assertThat(actual).isNotNull(); assertThat(actual.getValue()).contains("0 AM"); }
From source file:com.axibase.tsd.TestUtil.java
public static GetPropertiesQuery buildPropertiesQuery() { GetPropertiesQuery query = new GetPropertiesQuery(TTT_TYPE, TTT_ENTITY); query.setStartTime(0);//from w w w . ja v a 2 s . c om query.setEndTime(Long.MAX_VALUE); query.setKey(AtsdUtil.toMap("key1", "ttt-key-1")); return query; }
From source file:com.twitter.hraven.datasource.TestHdfsStatsService.java
@Test public void TestGetLastHourInvertedTimestamp() throws IOException { long ts = 1391896800L; long expectedTop = Long.MAX_VALUE - ts; long actualTop = HdfsStatsService.getEncodedRunId(ts); assertEquals(actualTop, expectedTop); }
From source file:com.hpcloud.util.Duration.java
private Duration(long length, TimeUnit timeUnit) { this.length = length; this.timeUnit = Preconditions.checkNotNull(timeUnit); finite = length == Long.MAX_VALUE && TimeUnit.DAYS.equals(timeUnit) ? false : true; }
From source file:io.fabric8.insight.log.service.LogQuery.java
public LogResults getLogEventList(int count, Predicate<PaxLoggingEvent> predicate) { LogResults answer = new LogResults(); answer.setHost(getHostName());/*from w ww . j ava 2s . c o m*/ long from = Long.MAX_VALUE; long to = Long.MIN_VALUE; if (appender != null) { LruList events = appender.getEvents(); if (events != null) { Iterable<PaxLoggingEvent> iterable = events.getElements(); if (iterable != null) { int matched = 0; for (PaxLoggingEvent event : iterable) { if (event != null) { long timestamp = event.getTimeStamp(); if (timestamp > to) { to = timestamp; } if (timestamp < from) { from = timestamp; } if (predicate == null || predicate.matches(event)) { answer.addEvent(Logs.newInstance(event)); matched += 1; if (count > 0 && matched >= count) { break; } } } } } } } else { LOG.warn("No VmLogAppender available!"); } answer.setFromTimestamp(from); answer.setToTimestamp(to); return answer; }
From source file:com.ewcms.plugin.crawler.generate.robotstxt.RobotstxtServer.java
private HostDirectives fetchDirectives(String host) { WebURL robotsTxtUrl = new WebURL(); robotsTxtUrl.setURL("http://" + host + "/robots.txt"); HostDirectives directives = null;// ww w .ja va2 s . co m PageFetchResult fetchResult = null; try { fetchResult = pageFetcher.fetchHeader(robotsTxtUrl); if (fetchResult.getStatusCode() == HttpStatus.SC_OK) { Page page = new Page(robotsTxtUrl); fetchResult.fetchContent(page); if (Util.hasPlainTextContent(page.getContentType())) { try { String content; if (page.getContentCharset() == null) { content = new String(page.getContentData()); } else { content = new String(page.getContentData(), page.getContentCharset()); } directives = RobotstxtParser.parse(content, config.getUserAgentName()); } catch (Exception e) { e.printStackTrace(); } } } } finally { fetchResult.discardContentIfNotConsumed(); } if (directives == null) { // We still need to have this object to keep track of the time we // fetched it directives = new HostDirectives(); } synchronized (host2directivesCache) { if (host2directivesCache.size() == config.getCacheSize()) { String minHost = null; long minAccessTime = Long.MAX_VALUE; for (Entry<String, HostDirectives> entry : host2directivesCache.entrySet()) { if (entry.getValue().getLastAccessTime() < minAccessTime) { minAccessTime = entry.getValue().getLastAccessTime(); minHost = entry.getKey(); } } host2directivesCache.remove(minHost); } host2directivesCache.put(host, directives); } return directives; }
From source file:info.archinnov.achilles.it.TestMultiClusteringEntityIT.java
@Test public void should_update_with_IN_clause_on_first_clustering() throws Exception { final long id = RandomUtils.nextLong(0, Long.MAX_VALUE); scriptExecutor.executeScriptTemplate("MultiClusteringEntity/insertRows.cql", ImmutableMap.of("id", id)); //When//from w w w . java2 s. co m manager.dsl().update().fromBaseTable().value().Set("new val").where().id().Eq(id).c1().IN(1, 3).c2().Eq(1) .execute(); //Then final List<Row> all = session .execute("SELECT value FROM achilles_embedded.multi_clustering_entity WHERE id = " + id + " AND c1 IN(1,3) AND c2=1") .all(); assertThat(all).hasSize(2); assertThat(all.stream().map(x -> x.getString("value")).collect(Collectors.toList())) .containsExactly("new val", "new val"); }