List of usage examples for java.util Map put
V put(K key, V value);
From source file:geomesa.tutorial.QueryTutorial.java
/** * Main entry point. Executes queries against an existing GDELT dataset. * * @param args//from w w w.j av a 2s. c o m * * @throws Exception */ public static void main(String[] args) throws Exception { // read command line options - this contains the connection to accumulo and the table to query CommandLineParser parser = new BasicParser(); Options options = SetupUtil.getCommonRequiredOptions(); options.addOption(OptionBuilder.withArgName(FEATURE_NAME_ARG).hasArg().isRequired() .withDescription("the FeatureTypeName used to store the GDELT data, e.g.: gdelt") .create(FEATURE_NAME_ARG)); CommandLine cmd = parser.parse(options, args); // verify that we can see this Accumulo destination in a GeoTools manner Map<String, String> dsConf = SetupUtil.getAccumuloDataStoreConf(cmd); //Disable states collection dsConf.put("collectStats", "false"); DataStore dataStore = DataStoreFinder.getDataStore(dsConf); assert dataStore != null; // create the simple feature type for our test String simpleFeatureTypeName = cmd.getOptionValue(FEATURE_NAME_ARG); SimpleFeatureType simpleFeatureType = GdeltFeature.buildGdeltFeatureType(simpleFeatureTypeName); // get the feature store used to query the GeoMesa data FeatureStore featureStore = (AccumuloFeatureStore) dataStore.getFeatureSource(simpleFeatureTypeName); // execute some queries basicQuery(simpleFeatureTypeName, featureStore); basicProjectionQuery(simpleFeatureTypeName, featureStore); basicTransformationQuery(simpleFeatureTypeName, featureStore); renamedTransformationQuery(simpleFeatureTypeName, featureStore); mutliFieldTransformationQuery(simpleFeatureTypeName, featureStore); geometricTransformationQuery(simpleFeatureTypeName, featureStore); // the list of available transform functions is available here: // http://docs.geotools.org/latest/userguide/library/main/filter.html - scroll to 'Function List' }
From source file:net.landora.justintv.JustinTVAPI.java
public static void main(String[] args) throws Exception { List<JustinArchive> archives = readArchives("tsmtournaments", 64); Map<String, List<JustinArchive>> groups = new HashMap<String, List<JustinArchive>>(); for (int i = 0; i < archives.size(); i++) { JustinArchive archive = archives.get(i); List<JustinArchive> group = groups.get(archive.getBroadcastId()); if (group == null) { group = new ArrayList<JustinArchive>(archive.getBroadcastPart()); groups.put(archive.getBroadcastId(), group); }/*w w w. j a va 2 s .co m*/ group.add(archive); } BroadcastSorter sorter = new BroadcastSorter(); for (List<JustinArchive> group : groups.values()) { Collections.sort(group, sorter); JustinArchive base = group.get(group.size() - 1); StringBuffer cmd = new StringBuffer(); cmd.append("mkvmerge -o \""); cmd.append(base.getBroadcastId()); cmd.append(" - "); cmd.append(base.getTitle()); cmd.append("\" "); for (int i = 0; i < group.size(); i++) { JustinArchive archive = group.get(i); if (i > 0) cmd.append("+ "); cmd.append(archive.getId()); cmd.append(".mkv "); } System.out.println(cmd); } }
From source file:com.amazonaws.services.dynamodbv2.client.DynamoDBDynamicFaultInjection.java
public static void main(String[] args) throws Exception { init();/* www. j a va 2 s. c o m*/ try { // Create a table with a primary key named 'name', which holds a string createTable(); // Describe our new table describeTable(); // Add some items putItem(newItem("Bill & Ted's Excellent Adventure", 1989, "****", "James", "Sara")); putItem(newItem("Airplane", 1980, "*****", "James", "Billy Bob")); // Get some items getItem("Airplane"); getItem("Bill & Ted's Excellent Adventure"); // Scan items for movies with a year attribute greater than 1985 Map<String, Condition> scanFilter = new HashMap<String, Condition>(); Condition condition = new Condition().withComparisonOperator(ComparisonOperator.GT.toString()) .withAttributeValueList(new AttributeValue().withN("1985")); scanFilter.put("year", condition); ScanRequest scanRequest = new ScanRequest(TABLENAME).withScanFilter(scanFilter); ScanResult scanResult = dynamoDBClient.scan(scanRequest); logger.info("Result: " + scanResult); } catch (AmazonServiceException ase) { logger.error("Service Exception: " + ase); } catch (AmazonClientException ace) { logger.error("Client Exception: " + ace); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map<String, List<String>> fontFaceNames = new HashMap<String, List<String>>(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); for (int i = 0; i < fonts.length; i++) { String familyName = fonts[i].getFamily(); String faceName = fonts[i].getName(); List<String> list = fontFaceNames.get(familyName); if (list == null) { list = new ArrayList<String>(); fontFaceNames.put(familyName, list); }//from w ww. j a va 2s.co m list.add(faceName); } System.out.println(fontFaceNames); }
From source file:gpframework.RunExperiment.java
/** * Application's entry point.// w ww .j a v a 2s .c o m * * @param args * @throws ParseException * @throws ParameterException */ public static void main(String[] args) throws ParseException, ParameterException { // Failsafe parameters if (args.length == 0) { args = new String[] { "-f", "LasSortednessFunction", "-n", "5", "-ff", "JoinFactory", "-tf", "SortingElementFactory", "-pf", "SortingProgramFactory", "-s", "SMOGPSelection", "-a", "SMOGP", "-t", "50", "-e", "1000000000", "-mf", "SingleMutationFactory", "-d", "-bn", "other" }; } // Create options Options options = new Options(); setupOptions(options); // Read options from the command line CommandLineParser parser = new PosixParser(); CommandLine cmd; // Print help if parameter requirements are not met try { cmd = parser.parse(options, args); } // If some parameters are missing, print help catch (MissingOptionException e) { HelpFormatter hf = new HelpFormatter(); hf.printHelp("java -jar GPFramework \n", options); System.out.println(); System.out.println("Missing parameters: " + e.getMissingOptions()); return; } // Re-initialize PRNG long seed = System.currentTimeMillis(); Utils.random = new Random(seed); // Set the problem size int problemSize = Integer.parseInt(cmd.getOptionValue("n")); // Set debug mode and cluster mode Utils.debug = cmd.hasOption("d"); RunExperiment.cluster = cmd.hasOption("c"); // Initialize fitness function and some factories FitnessFunction fitnessFunction = fromName(cmd.getOptionValue("f"), problemSize); MutationFactory mutationFactory = fromName(cmd.getOptionValue("mf")); Selection selectionCriterion = fromName(cmd.getOptionValue("s")); FunctionFactory functionFactory = fromName(cmd.getOptionValue("ff")); TerminalFactory terminalFactory = fromName(cmd.getOptionValue("tf"), problemSize); ProgramFactory programFactory = fromName(cmd.getOptionValue("pf"), functionFactory, terminalFactory); // Initialize algorithm Algorithm algorithm = fromName(cmd.getOptionValue("a"), mutationFactory, selectionCriterion); algorithm.setParameter("evaluationsBudget", cmd.getOptionValue("e")); algorithm.setParameter("timeBudget", cmd.getOptionValue("t")); // Initialize problem Problem problem = new Problem(programFactory, fitnessFunction); Program solution = algorithm.solve(problem); Utils.debug("Population results: "); Utils.debug(algorithm.getPopulation().toString()); Utils.debug(algorithm.getPopulation().parse()); Map<String, Object> entry = new HashMap<String, Object>(); // Copy algorithm setup for (Object o : options.getRequiredOptions()) { Option option = options.getOption(o.toString()); entry.put(option.getLongOpt(), cmd.getOptionValue(option.getOpt())); } entry.put("seed", seed); // Copy results entry.put("bestProgram", solution.toString()); entry.put("bestSolution", fitnessFunction.normalize(solution)); // Copy all statistics entry.putAll(algorithm.getStatistics()); Utils.debug("Maximum encountered population size: " + algorithm.getStatistics().get("maxPopulationSizeToCompleteFront")); Utils.debug("Maximum encountered tree size: " + algorithm.getStatistics().get("maxProgramComplexityToCompleteFront")); Utils.debug("Solution complexity: " + solution.complexity() + "/" + (2 * problemSize - 1)); }
From source file:com.github.besherman.fingerprint.Main.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withDescription("creates a fingerprint file for the directory").hasArg() .withArgName("dir").create('c')); options.addOption(OptionBuilder.withDescription("shows a diff between two fingerprint files") .withArgName("left-file> <right-file").hasArgs(2).create('d')); options.addOption(OptionBuilder.withDescription("shows a diff between a fingerprint and a directory") .withArgName("fingerprint> <dir").hasArgs(2).create('t')); options.addOption(OptionBuilder.withDescription("shows duplicates in a directory").withArgName("dir") .hasArgs(1).create('u')); options.addOption(//from w w w. j ava 2s.co m OptionBuilder.withDescription("output to file").withArgName("output-file").hasArg().create('o')); PosixParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException ex) { System.out.println(ex.getMessage()); System.out.println(""); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("fingerprint-dir", options, true); System.exit(7); } if (cmd.hasOption('c')) { Path root = Paths.get(cmd.getOptionValue('c')); if (!Files.isDirectory(root)) { System.err.println("root is not a directory"); System.exit(7); } OutputStream out = System.out; if (cmd.hasOption('o')) { Path p = Paths.get(cmd.getOptionValue('o')); out = Files.newOutputStream(p); } Fingerprint fp = new Fingerprint(root, ""); fp.write(out); } else if (cmd.hasOption('d')) { String[] ar = cmd.getOptionValues('d'); Path leftFingerprintFile = Paths.get(ar[0]), rightFingerprintFile = Paths.get(ar[1]); if (!Files.isRegularFile(leftFingerprintFile)) { System.out.printf("%s is not a file%n", leftFingerprintFile); System.exit(7); } if (!Files.isRegularFile(rightFingerprintFile)) { System.out.printf("%s is not a file%n", rightFingerprintFile); System.exit(7); } Fingerprint left, right; try (InputStream input = Files.newInputStream(leftFingerprintFile)) { left = new Fingerprint(input); } try (InputStream input = Files.newInputStream(rightFingerprintFile)) { right = new Fingerprint(input); } Diff diff = new Diff(left, right); // TODO: if we have redirected output diff.print(System.out); } else if (cmd.hasOption('t')) { throw new RuntimeException("Not yet implemented"); } else if (cmd.hasOption('u')) { Path root = Paths.get(cmd.getOptionValue('u')); Fingerprint fp = new Fingerprint(root, ""); Map<String, FilePrint> map = new HashMap<>(); fp.stream().forEach(f -> { if (map.containsKey(f.getHash())) { System.out.println(" " + map.get(f.getHash()).getPath()); System.out.println("= " + f.getPath()); System.out.println(""); } else { map.put(f.getHash(), f); } }); } else { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("fingd", options, true); } }
From source file:com.yahoo.storm.yarn.MasterServer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { LOG.info("Starting the AM!!!!"); Options opts = new Options(); opts.addOption("app_attempt_id", true, "App Attempt ID. Not to be used " + "unless for testing purposes"); CommandLine cl = new GnuParser().parse(opts, args); ApplicationAttemptId appAttemptID;// w ww.ja v a 2 s . co m Map<String, String> envs = System.getenv(); if (cl.hasOption("app_attempt_id")) { String appIdStr = cl.getOptionValue("app_attempt_id", ""); appAttemptID = ConverterUtils.toApplicationAttemptId(appIdStr); } else if (envs.containsKey(ApplicationConstants.Environment.CONTAINER_ID.name())) { ContainerId containerId = ConverterUtils .toContainerId(envs.get(ApplicationConstants.Environment.CONTAINER_ID.name())); appAttemptID = containerId.getApplicationAttemptId(); LOG.info("appAttemptID from env:" + appAttemptID.toString()); } else { LOG.error("appAttemptID is not specified for storm master"); throw new Exception("appAttemptID is not specified for storm master"); } @SuppressWarnings("rawtypes") Map storm_conf = Config.readStormConfig(null); Util.rmNulls(storm_conf); YarnConfiguration hadoopConf = new YarnConfiguration(); final String host = InetAddress.getLocalHost().getHostName(); storm_conf.put("nimbus.host", host); StormAMRMClient rmClient = new StormAMRMClient(appAttemptID, storm_conf, hadoopConf); rmClient.init(hadoopConf); rmClient.start(); BlockingQueue<Container> launcherQueue = new LinkedBlockingQueue<Container>(); MasterServer server = new MasterServer(storm_conf, rmClient); try { final int port = Utils.getInt(storm_conf.get(Config.MASTER_THRIFT_PORT)); final String target = host + ":" + port; InetSocketAddress addr = NetUtils.createSocketAddr(target); RegisterApplicationMasterResponse resp = rmClient.registerApplicationMaster(addr.getHostName(), port, null); LOG.info("Got a registration response " + resp); LOG.info("Max Capability " + resp.getMaximumResourceCapability()); rmClient.setMaxResource(resp.getMaximumResourceCapability()); LOG.info("Starting HB thread"); server.initAndStartHeartbeat(rmClient, launcherQueue, (Integer) storm_conf.get(Config.MASTER_HEARTBEAT_INTERVAL_MILLIS)); LOG.info("Starting launcher"); initAndStartLauncher(rmClient, launcherQueue); rmClient.startAllSupervisors(); LOG.info("Starting Master Thrift Server"); server.serve(); LOG.info("StormAMRMClient::unregisterApplicationMaster"); rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "AllDone", null); } finally { if (server.isServing()) { LOG.info("Stop Master Thrift Server"); server.stop(); } LOG.info("Stop RM client"); rmClient.stop(); } System.exit(0); }
From source file:com.g3net.tool.CollectionUtils.java
public static void main(String[] args) { Integer[] ints = new Integer[] { 1, 2, 3, 4, 5 }; Integer[] bb = new Integer[] { 4, 5 }; Integer[] bb2 = new Integer[] { 4, 5, 7 }; Map map = new HashMap(); map.put("aa", ints); map.put("bb", "66666"); map.put("cc", "eee"); Map map2 = new HashMap(); map2.put("aa", ints); map2.put("bb", 3); }
From source file:com.wordnik.swagger.testframework.JavaTestCaseExecutor.java
/** * Follow the following argument pattern * Arguments in calling this method://from ww w . j av a2 s . co m * ApiServerURL * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { JavaTestCaseExecutor runner = new JavaTestCaseExecutor(); String apiServer = args[1]; String servicePackageName = args[2]; String apiKey = args[3]; String authToken = args[4]; String resource = args[5]; String httpMethod = args[6]; String suggestedMethodName = args[7]; Map<String, String> queryAndPathParameters = new HashMap<String, String>(); String postData = null; if (args.length > 8 && args[8].length() > 0) { String[] qpTuple = args[8].split("~"); for (String tuple : qpTuple) { String[] nameValue = tuple.split("="); queryAndPathParameters.put(nameValue[0], nameValue[1]); } } if (args.length > 9) { postData = args[9]; } queryAndPathParameters.put("authToken", authToken); ApiKeyAuthTokenBasedSecurityHandler securityHandler = new ApiKeyAuthTokenBasedSecurityHandler(apiKey, authToken); APIInvoker aAPIInvoker = APIInvoker.initialize(securityHandler, apiServer, true); runner.executeTestCase(resource, servicePackageName, suggestedMethodName, queryAndPathParameters, postData); }
From source file:com.example.CcsClient.java
public static void main(String[] args) { final String projectId = "813916479990"; final String password = ""; //final String toRegId = "APA91bGtjDTQ3SAb69VfzW6FaBy6Wq-5KqX9T1qu7LX-DKHu8FNpqzgaoZ8oR4OQ8fRmues4q3rW7FgyrSB19l4RiTiIPyHNHjGXy3VpbbxlmgVZEmrTeO7uKDg0NRNHvPNt9VK9K9Ol"; final String toRegId = "APA91bGY4dIfSQXSKtJWMURy2QpJl9yyivYezFDD03kURk0x8EaVj31zmxALgjmg0bVh9eoGCwc5BWNXQh0CFZ9inFk1BJR2WBPLT8MT9ZvXCgX7wRchLlC0GgfxclqIux3vOLHNDiRJ"; //final String toRegId = "APA91bGNKqkUQsqv3-Yjh2f84U8Z9v4z6hQ1XUy2g9pDztwGcB28SITCZFBPKgUGVJOvu-oYUyt--fdKiEuxq45vJRZjPYrvYUXQOe9Q0xmBpwofNUTjVNitQW3A1D16rlN0xeoszsZa"; CcsClient ccsClient = CcsClient.prepareClient(projectId, password, true); try {/*from w w w. j a va2 s.c o m*/ ccsClient.connect(); } catch (XMPPException e) { e.printStackTrace(); // Send a sample hello downstream message to a device. String messageId = ccsClient.getRandomMessageId(); Map<String, String> payload = new HashMap<String, String>(); payload.put("message", "Simple sample sessage"); String collapseKey = "sample"; Long timeToLive = 10000L; Boolean delayWhileIdle = true; //ccsClient.send(createJsonMessage(toRegId, messageId, payload, collapseKey, // timeToLive, delayWhileIdle)); //Content content = createContent(); } }