List of usage examples for org.apache.hadoop.conf Configuration getFloat
public float getFloat(String name, float defaultValue)
name
property as a float
. From source file:auction.AuctionVertex.java
License:Apache License
@Override public void compute(Iterable<AuctionMessage> messages) throws IOException { Context context = getContext(); Configuration conf = context.getConfiguration(); double epsilon = (double) conf.getFloat("EPSILON", 0); int max = conf.getInt("MAX", Integer.MAX_VALUE); if (epsilon == 0) { epsilon = Double.MIN_VALUE; }//from w ww.jav a 2 s.com // //even supersteps are bidding steps // //odd supersteps are updating steps long superstep = getSuperstep(); //System.out.printf("Step: %d, ID: %d Value: %s\n", superstep, getId().get(), getValue().toString()); if (superstep == max) { voteToHalt(); } else if (superstep % 2 == 0) { // /////////////update the benefits based on the messages////////////////////// System.out.println("\t starting"); for (AuctionMessage message : messages) { if (message.getBid() != -Double.MAX_VALUE && message.getBid() != Double.MAX_VALUE) { System.out.printf("\t\told benefit %s\n", String.valueOf(getValue().getBenefit((int) message.getSender().get()))); getValue().setBenefit((int) message.getSender().get(), getValue().getBenefit((int) message.getSender().get()) - message.getBid()); System.out.printf("\t\tnew benefit %s\n", String.valueOf(getValue().getBenefit((int) message.getSender().get()))); } else if (message.getBid() == Double.MAX_VALUE) { System.out.printf("\t\told column %s\n", String.valueOf(getValue().getColOwned().toString())); getValue().setColOwned(message.getSender()); System.out.printf("\t\tnew column %s\n", String.valueOf(getValue().getColOwned().toString())); } else { System.out.printf("\tunowned now\n"); getValue().setColOwned(-1); } } System.out.println("updated prices"); // //only bid where you don't have a column already if (getValue().getColOwned().get() == -1) { System.out.println("\t preparing for loop"); // //should store a max and a max column - and then when we re-calculate test /////////////////////get Max ///////////////////////////////////////////// double[] maxBenefit = { -Double.MAX_VALUE, -Double.MAX_VALUE }; long[] maxIdx = { -1, -1 }; for (int i = 0; i < getValue().N; i++) { if (getValue().getBenefit(i) > maxBenefit[0]) { maxBenefit[1] = maxBenefit[0]; maxBenefit[0] = getValue().getBenefit(i); maxIdx[1] = maxIdx[0]; maxIdx[0] = (long) i; } else if (getValue().getBenefit(i) > maxBenefit[1]) { maxBenefit[1] = getValue().getBenefit(i); maxIdx[1] = (long) i; } } // //System.out.printf("\tmax1: %s\n", String.valueOf(maxBenefit[0])); // //System.out.printf("\tmax2: %s\n", String.valueOf(maxBenefit[1])); // //System.out.printf("\tmax1: %s\n", String.valueOf(maxIdx[0])); // //System.out.printf("\tmax2: %s\n", String.valueOf(maxIdx[1])); // //System.out.println("got maxes"); //////////////////get bid//////////////////////////////////////////////// double bidValue = maxBenefit[0] - maxBenefit[1] + epsilon; System.out.printf("\tbid value:%s\n", String.valueOf(bidValue)); System.out.printf("\tbid on:%s\n", String.valueOf(maxIdx[0])); System.out.println("Got bid"); ///////////////////send bid///////////////////////////////////////////// to.set(maxIdx[0]); bid.set(getId(), bidValue); sendMessage(to, bid); System.out.println("sent bid"); } voteToHalt(); System.out.println("voted to halt"); } else { ///////////////////////get the maximum bid double maxBid = -Double.MAX_VALUE; long maxIdx = -1; // //System.out.println("starting mesage loop"); for (AuctionMessage message : messages) { if (message.getBid() > maxBid) { maxBid = message.getBid(); maxIdx = message.getSender().get(); System.out.printf("\tnew Bid: %s\n", String.valueOf(maxBid)); System.out.printf("\tnew winner: %s\n", String.valueOf(maxIdx)); } } // //System.out.println("got hihest message"); if (maxIdx != -1) { System.out.println("need to update"); /////////////////send a message to the winner//////////////////////////// to.set(maxIdx); bid.set(getId(), Double.MAX_VALUE); sendMessage(to, bid); System.out.printf("\tsending message to winner %s\n", String.valueOf(maxIdx)); System.out.println("sent message to winner"); ////////////////send a message to the loser////////////////////////////// if (getValue().getRowOwnedBy().get() != -1) { bid.set(getId(), -Double.MAX_VALUE); sendMessage(getValue().getRowOwnedBy(), bid); System.out.printf("\tsending message to loser %s\n", String.valueOf(getValue().getRowOwnedBy())); System.out.println("sent message to loser"); } ///////////////////update the price/////////////////////////////////////// getValue().setPrice(maxBid + getValue().getPrice()); getValue().setRowOwnedBy(maxIdx); System.out.printf("\tset the price to: %s\n", String.valueOf(getValue().getPrice())); System.out.printf("\tset ownership to: %s\n", String.valueOf(getValue().getRowOwnedBy().toString())); System.out.println("updated the price"); //////////////////send a message to all indicating the price change///////// for (int i = 0; i < getValue().N; i++) { to.set(i); bid.set(getId(), maxBid); sendMessage(to, bid); System.out.printf("\tsent priceChange: %s message to row %s\n", String.valueOf(maxBid), String.valueOf(i)); } System.out.println("sent message to all"); } voteToHalt(); System.out.println("voted to halt"); } }
From source file:be.ugent.intec.halvade.utils.HalvadeConf.java
License:Open Source License
public static double getSCC(Configuration conf, boolean isRNA) { if (isRNA)// w w w. ja va2s . c o m return conf.getFloat(scc, DEFAULT_RNA_SCC); else return conf.getFloat(scc, DEFAULT_DNA_SCC); }
From source file:be.ugent.intec.halvade.utils.HalvadeConf.java
License:Open Source License
public static double getSEC(Configuration conf, boolean isRNA) { if (isRNA)// w w w .j ava 2 s.co m return conf.getFloat(sec, DEFAULT_RNA_SEC); else return conf.getFloat(sec, DEFAULT_DNA_SEC); }
From source file:com.alibaba.wasp.master.balancer.BaseLoadBalancer.java
License:Apache License
@Override public void setConf(Configuration conf) { this.slop = conf.getFloat("hbase.entityGroups.slop", (float) 0.2); if (slop < 0) slop = 0;//from w w w .j av a 2s . c om else if (slop > 1) slop = 1; this.config = conf; }
From source file:com.blm.orc.MemoryManager.java
License:Apache License
/** * Create the memory manager./*from w ww .j a v a 2 s . co m*/ * @param conf use the configuration to find the maximum size of the memory * pool. */ MemoryManager(Configuration conf) { HiveConf.ConfVars poolVar = HiveConf.ConfVars.HIVE_ORC_FILE_MEMORY_POOL; double maxLoad = conf.getFloat(poolVar.varname, poolVar.defaultFloatVal); totalMemoryPool = Math.round(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() * maxLoad); }
From source file:com.elex.dmp.lda.CachingCVB0Mapper.java
License:Apache License
@Override protected void setup(Context context) throws IOException, InterruptedException { log.info("Retrieving configuration"); Configuration conf = context.getConfiguration(); float eta = conf.getFloat(CVB0Driver.TERM_TOPIC_SMOOTHING, Float.NaN); float alpha = conf.getFloat(CVB0Driver.DOC_TOPIC_SMOOTHING, Float.NaN); long seed = conf.getLong(CVB0Driver.RANDOM_SEED, 1234L); numTopics = conf.getInt(CVB0Driver.NUM_TOPICS, -1); int numTerms = conf.getInt(CVB0Driver.NUM_TERMS, -1); int numUpdateThreads = conf.getInt(CVB0Driver.NUM_UPDATE_THREADS, 1); int numTrainThreads = conf.getInt(CVB0Driver.NUM_TRAIN_THREADS, 4); maxIters = conf.getInt(CVB0Driver.MAX_ITERATIONS_PER_DOC, 10); float modelWeight = conf.getFloat(CVB0Driver.MODEL_WEIGHT, 1.0f); log.info("Initializing read model"); TopicModel readModel;/*from w w w .j av a 2s. c o m*/ Path[] modelPaths = CVB0Driver.getModelPaths(conf); if (modelPaths != null && modelPaths.length > 0) { readModel = new TopicModel(conf, eta, alpha, null, numUpdateThreads, modelWeight, modelPaths); } else { log.info("No model files found"); readModel = new TopicModel(numTopics, numTerms, eta, alpha, RandomUtils.getRandom(seed), null, numTrainThreads, modelWeight); } log.info("Initializing write model"); TopicModel writeModel = modelWeight == 1 ? new TopicModel(numTopics, numTerms, eta, alpha, null, numUpdateThreads) : readModel; log.info("Initializing model trainer"); modelTrainer = new ModelTrainer(readModel, writeModel, numTrainThreads, numTopics, numTerms); modelTrainer.start(); }
From source file:com.elex.dmp.lda.CachingCVB0PerplexityMapper.java
License:Apache License
@Override protected void setup(Context context) throws IOException, InterruptedException { MemoryUtil.startMemoryLogger(5000);//from www . j a va 2s .c o m log.info("Retrieving configuration"); Configuration conf = context.getConfiguration(); float eta = conf.getFloat(CVB0Driver.TERM_TOPIC_SMOOTHING, Float.NaN); float alpha = conf.getFloat(CVB0Driver.DOC_TOPIC_SMOOTHING, Float.NaN); long seed = conf.getLong(CVB0Driver.RANDOM_SEED, 1234L); random = RandomUtils.getRandom(seed); numTopics = conf.getInt(CVB0Driver.NUM_TOPICS, -1); int numTerms = conf.getInt(CVB0Driver.NUM_TERMS, -1); int numUpdateThreads = conf.getInt(CVB0Driver.NUM_UPDATE_THREADS, 1); int numTrainThreads = conf.getInt(CVB0Driver.NUM_TRAIN_THREADS, 4); maxIters = conf.getInt(CVB0Driver.MAX_ITERATIONS_PER_DOC, 10); float modelWeight = conf.getFloat(CVB0Driver.MODEL_WEIGHT, 1.0f); testFraction = conf.getFloat(CVB0Driver.TEST_SET_FRACTION, 0.1f); log.info("Initializing read model"); TopicModel readModel; Path[] modelPaths = CVB0Driver.getModelPaths(conf); if (modelPaths != null && modelPaths.length > 0) { readModel = new TopicModel(conf, eta, alpha, null, numUpdateThreads, modelWeight, modelPaths); } else { log.info("No model files found"); readModel = new TopicModel(numTopics, numTerms, eta, alpha, RandomUtils.getRandom(seed), null, numTrainThreads, modelWeight); } log.info("Initializing model trainer"); modelTrainer = new ModelTrainer(readModel, null, numTrainThreads, numTopics, numTerms); log.info("Initializing topic vector"); topicVector = new DenseVector(new double[numTopics]); }
From source file:com.facebook.hive.orc.OrcConf.java
License:Open Source License
public static float getFloatVar(Configuration conf, ConfVars var) { return conf.getFloat(var.varname, var.defaultFloatVal); }
From source file:com.facebook.hiveio.conf.FloatConfOption.java
License:Apache License
/** * Lookup value/*from w w w . ja v a 2s .c om*/ * @param conf Configuration * @return value for key, or defaultValue if not present */ public float get(Configuration conf) { return conf.getFloat(getKey(), defaultValue); }
From source file:com.github.ygf.pagerank.PageRank.java
License:Apache License
public int run(String[] args) throws Exception { if (args.length != 3) { System.out.println("Usage: PageRank <links-simple-sorted.txt> <titles-dir> <output-dir>"); ToolRunner.printGenericCommandUsage(System.out); return 2; }//w w w . j a v a 2 s.co m Path linksFile = new Path(args[0]); Path titlesDir = new Path(args[1]); Path outputDir = new Path(args[2]); Configuration conf = getConf(); // Do not create _SUCCESS files. MapFileOutputFormat.getReaders calls // try to read the _SUCCESS as another MapFile dir. conf.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false"); // Default values of the parameters of the algorithm. conf.setInt("pagerank.block_size", conf.getInt("pagerank.block_size", 10000)); conf.setInt("pagerank.max_iterations", conf.getInt("pagerank.max_iterations", 2)); conf.setFloat("pagerank.damping_factor", conf.getFloat("pagerank.damping_factor", 0.85f)); conf.setInt("pagerank.top_results", conf.getInt("pagerank.top_results", 100)); conf.set("pagerank.titles_dir", titlesDir.toString()); int numPages = getNumPages(conf, titlesDir); conf.setLong("pagerank.num_pages", numPages); createTransitionMatrix(conf, linksFile, outputDir); int maxIters = Integer.parseInt(conf.get("pagerank.max_iterations")); for (int iter = 1; iter <= maxIters; iter++) { conf.setInt("pagerank.iteration", iter); pageRankIteration(iter, conf, outputDir); cleanPreviousIteration(iter, conf, outputDir); } summarizeResults(maxIters, conf, outputDir); return 0; }