Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Integer MAX_VALUE.

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:annis.visualizers.component.AbstractDotVisualizer.java

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
    try {//from w  ww  .j  a  va2 s .  c  o  m

        final PipedOutputStream out = new PipedOutputStream();
        final PipedInputStream in = new PipedInputStream(out);

        new Thread(new Runnable() {
            @Override
            public void run() {
                writeOutput(visInput, out);
            }
        }).start();

        String fileName = "dotvis_" + new Random().nextInt(Integer.MAX_VALUE) + ".png";
        StreamResource resource = new StreamResource(new StreamResource.StreamSource() {

            @Override
            public InputStream getStream() {
                return in;
            }
        }, fileName);

        Embedded emb = new Embedded("", resource);
        emb.setMimeType("image/png");
        emb.setSizeFull();
        emb.setStandby("loading image");
        emb.setAlternateText("DOT graph visualization");
        return new ImagePanel(emb);

    } catch (IOException ex) {
        log.error(null, ex);
    }
    return new ImagePanel(new Embedded());
}

From source file:io.druid.segment.serde.LargeColumnSupportedComplexColumnSerializerTest.java

@Test
public void testSanity() throws IOException {

    HyperUniquesSerdeForTest serde = new HyperUniquesSerdeForTest(Hashing.murmur3_128());
    int[] cases = { 1000, 5000, 10000, 20000 };
    int[] columnSizes = { Integer.MAX_VALUE, Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 4, 5000 * Longs.BYTES,
            2500 * Longs.BYTES };/*  w ww . j av a2 s.co m*/

    for (int columnSize : columnSizes) {
        for (int aCase : cases) {
            File tmpFile = FileUtils.getTempDirectory();
            HyperLogLogCollector baseCollector = HyperLogLogCollector.makeLatestCollector();
            try (IOPeon peon = new TmpFileIOPeon(); FileSmoosher v9Smoosher = new FileSmoosher(tmpFile)) {

                LargeColumnSupportedComplexColumnSerializer serializer = LargeColumnSupportedComplexColumnSerializer
                        .createWithColumnSize(peon, "test", serde.getObjectStrategy(), columnSize);

                serializer.open();
                for (int i = 0; i < aCase; i++) {
                    HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector();
                    byte[] hashBytes = fn.hashLong(i).asBytes();
                    collector.add(hashBytes);
                    baseCollector.fold(collector);
                    serializer.serialize(collector);
                }
                serializer.close();

                try (final SmooshedWriter channel = v9Smoosher.addWithSmooshedWriter("test",
                        serializer.getSerializedSize())) {
                    serializer.writeToChannel(channel, v9Smoosher);
                }
            }

            SmooshedFileMapper mapper = Smoosh.map(tmpFile);
            final ColumnBuilder builder = new ColumnBuilder().setType(ValueType.COMPLEX)
                    .setHasMultipleValues(false).setFileMapper(mapper);
            serde.deserializeColumn(mapper.mapFile("test"), builder);

            Column column = builder.build();
            ComplexColumn complexColumn = column.getComplexColumn();
            HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector();

            for (int i = 0; i < aCase; i++) {
                collector.fold((HyperLogLogCollector) complexColumn.getRowValue(i));
            }
            Assert.assertEquals(baseCollector.estimateCardinality(), collector.estimateCardinality(), 0.0);
        }
    }
}

From source file:com.netflix.curator.framework.recipes.queue.TestDistributedDelayQueue.java

@Test
public void testLateAddition() throws Exception {
    Timing timing = new Timing();
    DistributedDelayQueue<Long> queue = null;
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
            timing.connection(), new RetryOneTime(1));
    client.start();/*from  w w w. j av a  2 s. c  om*/
    try {
        BlockingQueueConsumer<Long> consumer = new BlockingQueueConsumer<Long>(
                Mockito.mock(ConnectionStateListener.class));
        queue = QueueBuilder.builder(client, consumer, new LongSerializer(), "/test").buildDelayQueue();
        queue.start();

        queue.put(1L, System.currentTimeMillis() + Integer.MAX_VALUE); // never come out
        Long value = consumer.take(1, TimeUnit.SECONDS);
        Assert.assertNull(value);

        queue.put(2L, System.currentTimeMillis());
        value = consumer.take(timing.seconds(), TimeUnit.SECONDS);
        Assert.assertEquals(value, Long.valueOf(2));

        value = consumer.take(1, TimeUnit.SECONDS);
        Assert.assertNull(value);
    } finally {
        IOUtils.closeQuietly(queue);
        IOUtils.closeQuietly(client);
    }
}

From source file:io.macgyver.neorx.rest.NeoRxClientTest.java

@Test
public void testIntParam() {
    NeoRxClient c = new NeoRxClient();

    Assert.assertEquals(JsonNodeType.NUMBER,
            c.createParameters("abc", Integer.MAX_VALUE).get("abc").getNodeType());
}

From source file:com.mapr.synth.samplers.IntegerSampler.java

@Override
public JsonNode sample() {
    synchronized (this) {
        int r = power >= 0 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
        if (power >= 0) {
            for (int i = 0; i <= power; i++) {
                r = Math.min(r, min + base.nextInt(max - min));
            }/* w w  w . java 2s .c o  m*/
        } else {
            int n = -power;
            for (int i = 0; i <= n; i++) {
                r = Math.max(r, min + base.nextInt(max - min));
            }
        }
        return new IntNode(r);
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.graph.VisualizationTest.java

public static void showGraph(Graph graph, File outputFile) throws IOException {
    graph.addAttribute("ui.antialias", true);
    graph.addAttribute("ui.stylesheet", "edge {fill-color:grey; shape: cubic-curve;} ");

    // min and max ratio
    int minRatio = Integer.MAX_VALUE;
    int maxRatio = Integer.MIN_VALUE;
    for (Node node : graph) {
        // get ratio
        int ratio = node.getOutDegree() - node.getInDegree() + 100;

        minRatio = Math.min(ratio, minRatio);
        maxRatio = Math.max(ratio, maxRatio);
    }/*from ww w .  j  a v  a  2  s  . co m*/

    for (Node node : graph) {
        // parse cluster node IDs back to sorted set
        SortedSet<String> clusterNodesIDs = new TreeSet<>(
                Arrays.asList(node.getAttribute(Step6GraphTransitivityCleaner.NODE_ATTR_CLUSTERED_ARGS)
                        .toString().replaceAll("^\\[", "").replaceAll("\\]$", "").split(", ")));

        // get longest out-coming transition path

        // get ratio
        int ratio = node.getOutDegree() - node.getInDegree() + 100;

        String color = mapValueToColor(minRatio, maxRatio, ratio);
        int size = (node.getOutDegree() + 10) * 2;

        int maxTransitivityScore = computeMaxTransitivityScore(graph, node);

        node.addAttribute("ui.style", String.format("fill-color: %s; size: %dpx;", color, size));
        node.addAttribute("ui.label",
                String.format("%d/%d/%d", node.getInDegree(), node.getOutDegree(), maxTransitivityScore));
    }

    final int RES = 450;
    Viewer viewer = graph.display();
    ViewPanel panel = viewer.getDefaultView();
    panel.setSize(RES, RES);

    FileSinkImages pic = new FileSinkImages(FileSinkImages.OutputType.PNG, FileSinkImages.Resolutions.HD720);

    pic.setLayoutPolicy(FileSinkImages.LayoutPolicy.COMPUTED_FULLY_AT_NEW_IMAGE);
    pic.setResolution(RES, RES);

    pic.writeAll(graph, outputFile.getAbsolutePath());
}

From source file:de.xwic.appkit.core.remote.server.ParameterProvider.java

/**
 * @param request/*from   w  ww  .java 2  s  .c  o m*/
 * @throws IOException
 */
public ParameterProvider(final HttpServletRequest request) throws IOException {
    this.request = request;

    multipart = isMultipart(request);

    if (multipart) {
        int maxPostSize = Integer.MAX_VALUE; // 2gb
        //         int maxPostSize = 1024 * 5120; // 5mb
        int memoryUsage = 1024 * 1024;

        Upload upload = new Upload(request, getUploadDir(), maxPostSize, memoryUsage);
        multiPartParams = unmodifiable(upload.getParams());
        files = unmodifiable(upload.getFiles());
    } else {
        multiPartParams = Collections.emptyMap();
        files = Collections.emptyMap();
    }
}

From source file:it.drwolf.ridire.utility.IndexQuery.java

public IndexQuery(String[] args) {
    this.createOptions();
    this.parseOptions(args);
    try {/*ww w . j av  a2 s.  c om*/
        IndexReader indexReader = IndexReader.open(new MMapDirectory(new File(this.dirName)));
        IndexSearcher indexSearcher = new IndexSearcher(indexReader);
        TermQuery tqLemma = new TermQuery(new Term("lemma", this.term));
        TopDocs results = indexSearcher.search(tqLemma, Integer.MAX_VALUE);
        System.out.println("Total results: " + results.totalHits);
        for (int i = 0; i < results.totalHits; i++) {
            Document d = indexReader.document(results.scoreDocs[i].doc);
            String sketch = d.get("sketch");
            System.out.println(sketch);
        }
    } catch (CorruptIndexException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.mnxfst.stream.pipeline.element.script.ScriptEvaluatorPipelineElementTest.java

/**
 * This is not a test case but more a kind of a sandbox for fiddling around with the script engine
 *///  w  w w.j a va2 s.co m
@Test
public void testEvaluateScriptWithReturn() throws Exception {

    ScriptEngineManager factory = new ScriptEngineManager();
    ScriptEngine engine = factory.getEngineByName("JavaScript");
    StringWriter writer = new StringWriter();
    PrintWriter pw = new PrintWriter(writer, true);
    engine.getContext().setWriter(pw);

    engine.eval(new FileReader("/home/mnxfst/git/stream-analyzer/src/main/resources/spahql.js"));

    String script = "var result0 = '1';var result1 = '2';";
    engine.eval(script);
    StringBuffer sb = writer.getBuffer();
    System.out.println("StringBuffer contains: " + sb + " - " + engine.get("test"));
    System.out.println(engine.get("content"));

    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        String content = (String) engine.get("result" + i);
        if (StringUtils.isBlank(content))
            break;
        System.out.println(content);
    }

    ObjectMapper mapper = new ObjectMapper();
    StreamEventMessage message = new StreamEventMessage();
    message.setIdentifier("test-id");
    message.setOrigin("test-origin");
    message.setTimestamp("2014-03-05");
    message.setEvent("10");
    //      message.addCustomAttribute("test-key-1", "3");
    //      message.addCustomAttribute("test-key-2", "value-1");
    //      message.addCustomAttribute("test-key-3", "19");
    //      message.addCustomAttribute("errors", (String)engine.get("test"));

    String json = mapper.writeValueAsString(message);
    System.out.println(json);
    StreamEventMessage msg = mapper.readValue(json, StreamEventMessage.class);
    System.out.println(message.getCustomAttributes().get("json"));

}

From source file:com.ineunet.knife.core.query.QueryParamParser.java

public QueryParamParser(QueryParameters queryParameters) {
    int start;/*from w w  w. j  a v  a 2 s .  co m*/
    int rows;
    if (queryParameters instanceof DataTableParams) {
        DataTableParams dataTableParam = (DataTableParams) queryParameters;
        start = dataTableParam.getStart();
        rows = dataTableParam.getLength();
    } else {
        int page = queryParameters.getPage();
        rows = queryParameters.getRows();

        if (page == Pageable.NON_PAGEABLE) {
            page = 1;
            rows = Integer.MAX_VALUE;
        }
        start = (page - 1) * rows;
    }

    String orderBy = null;
    if (queryParameters.getSort() != null) {
        orderBy = queryParameters.getSort();

        if (queryParameters.getOrder() != null && "desc".equals(queryParameters.getOrder().toLowerCase())) {
            orderBy = String.format("%s %s", orderBy, DESC);
        } else {
            orderBy = String.format("%s %s", orderBy, ASC);
        }
    }

    this.start = start;
    this.rows = rows;
    this.orderBy = orderBy;
}