Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

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

Usage

From source file:com.couchbase.shell.CouchbaseBucketCommands.java

@CliCommand(value = GETPING, help = "Retreive a document from the server for a perioud and count the time.")
public String getping(
        @CliOption(mandatory = true, key = { "",
                "key" }, help = "The unique name of the key in this bucket") String key,
        @CliOption(key = "runs", help = "The number of pings to perform", unspecifiedDefaultValue = "10") String runs,
        @CliOption(key = "delay", help = "Time to sleep between pings", unspecifiedDefaultValue = "0") String delay) {
    try {/*from   ww w.j  a va  2s .  co m*/
        int totalRuns = Integer.parseInt(runs);
        int del = Integer.parseInt(delay);

        StringBuilder builder = new StringBuilder();
        long total = 0;
        long totalMin = Integer.MAX_VALUE;
        long totalMax = Integer.MIN_VALUE;
        for (int i = 0; i < totalRuns; i++) {
            long start = System.nanoTime();
            OperationFuture<CASValue<Object>> future = shell.get(key);
            future.get();
            long end = System.nanoTime();
            builder.append(formatStatusLine(future.getStatus()));
            CASValue<Object> data = future.get();
            if (future.getStatus().isSuccess()) {
                builder.append(", CAS: " + data.getCas());
            }
            long diff = end - start;
            total += diff;
            builder.append(", Time: " + TimeUnit.NANOSECONDS.toMicros(diff) + "s");
            if (diff < totalMin) {
                totalMin = diff;
            }
            if (diff > totalMax) {
                totalMax = diff;
            }
            builder.append("\n");
            Thread.sleep(del);
        }
        builder.append("Total: " + TimeUnit.NANOSECONDS.toMicros(total) + "s");
        builder.append(", Average: " + TimeUnit.NANOSECONDS.toMicros(total / totalRuns) + "s");
        builder.append(", Min: " + TimeUnit.NANOSECONDS.toMicros(totalMin) + "s");
        builder.append(", Max: " + TimeUnit.NANOSECONDS.toMicros(totalMax) + "s");
        return builder.toString();
    } catch (Exception ex) {
        return "Could not get document " + key + " because of an error! ";
    }
}

From source file:com.haulmont.chile.core.datatypes.impl.AdaptiveNumberDatatype.java

protected void checkIntegerRange(String value, Number result) throws ParseException {
    if ((result instanceof Long || result instanceof Double)
            && (result.longValue() > Integer.MAX_VALUE || result.longValue() < Integer.MIN_VALUE))
        throw new ParseException(String.format("Integer range exceeded: \"%s\"", value), 0);
}

From source file:com.streamsets.pipeline.stage.origin.jdbc.table.AllTypesIT.java

private static void populateRecords() {
    Record record = RecordCreator.create();
    LinkedHashMap<String, Field> fields;
    AtomicInteger id_field = new AtomicInteger(0);

    //CHAR_AND_BINARY
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);//from   w  w w .jav a  2s . c o m
    fields.put("char1", Field.create("abcdefghij"));
    fields.put("varchar1", Field.create(UUID.randomUUID().toString()));
    fields.put("clob1", Field.create(UUID.randomUUID().toString()));
    fields.put("varbinary1", Field.create(UUID.randomUUID().toString().getBytes()));
    fields.put("blob1", Field.create(UUID.randomUUID().toString().getBytes()));
    record.set(Field.createListMap(fields));

    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("CHAR_AND_BINARY").getRight().add(record);

    //Date and time
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("date1", Field.create(Field.Type.DATE, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("timestamp1", Field.create(Field.Type.DATETIME, calendar.getTime()));
    fields.put("datetime1", Field.create(Field.Type.DATETIME, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    calendar.set(Calendar.YEAR, 1970);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("time1", Field.create(Field.Type.TIME, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DATE_AND_TIME").getRight().add(record);

    //DIFFERENT_INTS
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("int1", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("int2", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("mediumint1", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("tinyint1", Field.create(Field.Type.SHORT, -128));
    fields.put("smallint1", Field.create(Field.Type.SHORT, Short.MIN_VALUE));
    fields.put("bigint1", Field.create(Field.Type.LONG, Long.MIN_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DIFFERENT_INTS").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("int1", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("int2", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("mediumint1", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("tinyint1", Field.create(Field.Type.SHORT, 127));
    fields.put("smallint1", Field.create(Field.Type.SHORT, Short.MAX_VALUE));
    fields.put("bigint1", Field.create(Field.Type.LONG, Long.MAX_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DIFFERENT_INTS").getRight().add(record);

    //FLOATING_PT_INTS
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("decimal1", Field.create(Field.Type.DECIMAL, new BigDecimal("12.345")));
    fields.put("number1", Field.create(Field.Type.DECIMAL, new BigDecimal("0.12345")));
    fields.put("double1", Field.create(Field.Type.DOUBLE, 123.456));
    fields.put("real1", Field.create(Field.Type.FLOAT, 12.34));
    fields.put("floatdouble1", Field.create(Field.Type.DOUBLE, Double.MAX_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("FLOATING_PT_INTS").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("decimal1", Field.create(Field.Type.DECIMAL, new BigDecimal("-12.345")));
    fields.put("number1", Field.create(Field.Type.DECIMAL, new BigDecimal("-0.12345")));
    fields.put("double1", Field.create(Field.Type.DOUBLE, -123.456));
    fields.put("real1", Field.create(Field.Type.FLOAT, -12.34));
    fields.put("floatdouble1", Field.create(Field.Type.DOUBLE, Double.MIN_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("FLOATING_PT_INTS").getRight().add(record);

    //OTHER_TYPES
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("boolean1", Field.create(Field.Type.BOOLEAN, true));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("OTHER_TYPES").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("boolean1", Field.create(Field.Type.BOOLEAN, false));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("OTHER_TYPES").getRight().add(record);
}

From source file:com.linkedin.pinot.core.realtime.impl.kafka.SimpleConsumerWrapper.java

private SimpleConsumerWrapper(KafkaSimpleConsumerFactory simpleConsumerFactory, String bootstrapNodes,
        String clientId, long connectTimeoutMillis) {
    _simpleConsumerFactory = simpleConsumerFactory;
    _clientId = clientId;//w  w w  .  ja  v a  2 s. c  o m
    _connectTimeoutMillis = connectTimeoutMillis;
    _metadataOnlyConsumer = true;
    _simpleConsumer = null;

    // Topic and partition are ignored for metadata-only consumers
    _topic = null;
    _partition = Integer.MIN_VALUE;

    initializeBootstrapNodeList(bootstrapNodes);
    setCurrentState(new ConnectingToBootstrapNode());
}

From source file:com.google.code.pentahoflashcharts.charts.BarLineChartFactory.java

@SuppressWarnings("unchecked")
public void setupLineRange() {
    int rangeMin = 0;
    int rangeMax = 100;
    int steps = 9;

    String rangeColor = AXIS_COLOR_DEFAULT;
    String rangeGridColor = AXIS_GRID_COLOR_DEFAULT;
    int rangeStroke = 1;

    if (CATEGORY_TYPE.equals(datasetType) || XYZ_TYPE.equals(datasetType)) {
        rangeMin = Integer.MAX_VALUE;
        rangeMax = Integer.MIN_VALUE;
        List nodes = chartNode.selectNodes(LINE_SERIES_SERIES_NODE_LOC);
        List<String> bars = new ArrayList<String>();
        for (Object node : nodes) {
            if (getValue((Node) node) != null) {
                bars.add(getValue((Node) node));
            }//  w  w  w  . jav  a 2s .co m
        }

        for (int c = 0; c < getColumnCount(); c++) {
            String text = getColumnHeader(c);
            if (bars.contains(text)) {
                for (int r = 0; r < getRowCount(); r++) {
                    if (rangeMin > ((Number) getValueAt(r, c)).intValue())
                        rangeMin = ((Number) getValueAt(r, c)).intValue();
                    if (rangeMax < ((Number) getValueAt(r, c)).intValue())
                        rangeMax = ((Number) getValueAt(r, c)).intValue();
                }
            }
        }
    }

    boolean minDefined = false;
    boolean maxDefined = false;

    Node temp = chartNode.selectSingleNode(LINES_RANGE_MINIMUM_NODE_LOC);
    if (getValue(temp) != null) {
        rangeMin = new Integer(getValue(temp)).intValue();
        minDefined = true;
    }

    temp = chartNode.selectSingleNode(LINES_RANGE_MAXIMUM_NODE_LOC);
    if (getValue(temp) != null) {
        rangeMax = new Integer(getValue(temp)).intValue();
        maxDefined = true;
    }

    temp = chartNode.selectSingleNode(LINES_RANGE_COLOR_NODE_LOC);
    if (getValue(temp) != null) {
        rangeColor = getValue(temp);
    }

    temp = chartNode.selectSingleNode(LINES_RANGE_GRID_COLOR_NODE_LOC);
    if (getValue(temp) != null) {
        rangeGridColor = getValue(temp);
    }

    temp = chartNode.selectSingleNode(LINES_RANGE_STROKE_NODE_LOC);
    if (getValue(temp) != null) {
        rangeStroke = Integer.parseInt(getValue(temp));
    }

    temp = chartNode.selectSingleNode(LINE_RANGE_STEPS_NODE_LOC);
    if (getValue(temp) != null) {
        steps = new Integer(getValue(temp)).intValue();
    }

    int diff = rangeMax - rangeMin;

    int chunksize = diff / steps;

    Integer stepforchart = null;
    if (chunksize > 0)
        stepforchart = new Integer(chunksize);

    // Readjust mins/maxs only if they weren't specified
    if (!minDefined) {
        // If actual min is positive, don't go below ZERO
        if (rangeMin >= 0 && rangeMin - chunksize < 0)
            rangeMin = 0;
        else
            rangeMin = rangeMin - chunksize;
    }
    if (!maxDefined) {
        rangeMax = rangeMin + (chunksize * (steps + 2));
    }

    YAxis yaxis = new YAxis();
    yaxis.setRange(rangeMin, rangeMax, stepforchart);
    yaxis.setStroke(rangeStroke);
    yaxis.setColour(rangeColor);
    yaxis.setGridColour(rangeGridColor);
    chart.setYAxisRight(yaxis);
}

From source file:com.milaboratory.core.alignment.ScoringMatrixIO.java

/**
 * Reads BLAST AminoAcid substitution matrix from InputStream
 *
 * @param stream   InputStream/*from   w ww  .j a v  a 2s  .  co  m*/
 * @param alphabet alphabet
 * @param xChars   alphabet letters
 * @return BLAST AminoAcid substitution matrix
 * @throws java.io.IOException
 */
public static int[] readAABlastMatrix(InputStream stream, Alphabet alphabet, char... xChars)
        throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(stream));
    String line;

    //Creating xValues array
    int[] xValues = new int[xChars.length];
    for (int i = 0; i < xValues.length; ++i)
        if ((xValues[i] = alphabet.codeFromSymbol(xChars[i])) == -1)
            throw new IllegalArgumentException("XChar not from this alphabet.");

    //~AminoAcidAlphabet.
    IntArrayList mappings = new IntArrayList(30);

    int alSize = alphabet.size();
    int[] matrix = new int[alSize * alSize];
    Arrays.fill(matrix, Integer.MIN_VALUE);

    String[] cells;
    while ((line = br.readLine()) != null) {
        //Processing comment
        if (line.startsWith("#"))
            continue;

        //Processing header
        if (line.startsWith(" ")) {
            String[] letters = line.trim().split("\\s+");
            for (int i = 0; i < letters.length; ++i)
                mappings.add(getAACode(letters[i], alphabet));
            continue;
        }

        //Processing line with values
        cells = line.trim().split("\\s+");

        //Parsing letter in the first column
        for (int from : getVals(getAACode(cells[0], alphabet), xValues)) {
            for (int i = 1; i < cells.length; ++i)
                for (int to : getVals(mappings.get(i - 1), xValues))
                    matrix[from * alSize + to] = Integer.parseInt(cells[i]);
        }
    }

    //Checking for matrix fullness
    for (int val : matrix)
        if (val == Integer.MIN_VALUE)
            throw new IllegalArgumentException("Some letters are missing in matrix.");

    return matrix;
}

From source file:edu.msu.cme.rdp.alignment.errorcheck.RmPartialSeqs.java

public HashSet<Sequence> checkPartial(PrintStream seqOutstream, PrintStream alignOutstream)
        throws OverlapCheckFailedException, IOException {
    HashSet<Sequence> partialSeqs = new HashSet<Sequence>();
    for (int i = 0; i < seqList.size(); i++) {
        Sequence seqx = seqList.get(i);
        PairwiseAlignment bestResult = null;
        int bestScore = Integer.MIN_VALUE;
        Sequence bestSeqy = null;

        ArrayList<NuclSeqMatch.BestMatch> matchResults = sabCalculator.findTopKMatch(seqx, knn);
        for (NuclSeqMatch.BestMatch match : matchResults) {

            Sequence seqy = refSeqMap.get(match.getBestMatch().getSeqName());
            PairwiseAlignment result = PairwiseAligner.align(seqx.getSeqString().replaceAll("U", "T"),
                    seqy.getSeqString().replaceAll("U", "T"), scoringMatrix, mode);

            if (bestResult == null || result.getScore() >= bestScore) {
                bestResult = result;/* www .  j  a v  a  2  s  .c  o  m*/
                bestScore = result.getScore();
                bestSeqy = seqy;
            }

        }
        double distance = dist.getDistance(bestResult.getAlignedSeqj().getBytes(),
                bestResult.getAlignedSeqi().getBytes(), 0);

        int beginGaps = getBeginGapLength(bestResult.getAlignedSeqi());
        int endGaps = getEndGapLength(bestResult.getAlignedSeqi());
        if ((beginGaps >= this.min_begin_gaps) || (endGaps >= this.min_end_gaps)) {
            partialSeqs.add(seqx);
        } else {
            seqOutstream.println(">" + seqx.getSeqName() + "\t" + seqx.getDesc() + "\n" + seqx.getSeqString());
        }
        if (alignOutstream != null) {
            alignOutstream.println(">\t" + seqx.getSeqName() + "\t" + bestSeqy.getSeqName() + "\t"
                    + String.format("%.3f", distance) + "\tmissingBegin=" + (beginGaps >= this.min_begin_gaps)
                    + "\tmissingEnd=" + (endGaps >= this.min_end_gaps) + "\tbeginGaps=" + beginGaps
                    + "\tendGaps=" + endGaps);
            alignOutstream.print(bestResult.getAlignedSeqi() + "\n");
            alignOutstream.print(bestResult.getAlignedSeqj() + "\n");
        }
    }
    seqOutstream.close();
    if (alignOutstream != null)
        alignOutstream.close();

    return partialSeqs;
}

From source file:edu.cornell.med.icb.goby.modes.ConcatenateCompactReadsMode.java

/**
 * Actually perform the split of the compact reads file between
 * start and end position to the new compact reads file.
 *
 * @throws java.io.IOException//ww w .j  a  va 2s  .co  m
 */
@Override
public void execute() throws IOException {
    if (inputFiles == null || inputFiles.size() == 0) {
        throw new IOException("--input not specified");
    }
    if (StringUtils.isBlank(outputFilename)) {
        throw new IOException("--output not specified");
    }

    if (quickConcat) {
        performQuickConcat();
    } else {

        final ReadsWriter writer = new ReadsWriterImpl(new FileOutputStream(outputFilename));
        writer.setNumEntriesPerChunk(sequencePerChunk);
        final MutableString sequence = new MutableString();

        ReadsReader readsReader = null;
        numberOfReads = 0;
        minReadLength = Integer.MAX_VALUE;
        maxReadLength = Integer.MIN_VALUE;
        int removedByFilterCount = 0;
        try {
            final ProgressLogger progress = new ProgressLogger();
            progress.start("concatenating files");
            progress.displayFreeMemory = true;
            progress.expectedUpdates = inputFiles.size();
            progress.start();
            for (final File inputFile : inputFiles) {

                readsReader = new ReadsReader(inputFile);
                String basename = FilenameUtils.removeExtension(inputFile.getPath());
                String filterFilename = basename + optionalFilterExtension;
                File filterFile = new File(filterFilename);
                ReadSet readIndexFilter = null;
                if (filterFile.exists() && filterFile.canRead()) {
                    readIndexFilter = new ReadSet();
                    readIndexFilter.load(filterFile);
                    LOG.info(String.format("Loaded optional filter %s with %d elements. ", filterFile,
                            readIndexFilter.size()));
                } else {
                    if (optionalFilterExtension != null) {
                        LOG.info("Could not locate filter for filename " + filterFilename);
                    }
                }

                for (final Reads.ReadEntry readEntry : readsReader) {
                    // only concatenate if (1) there is no filter or (2) the read index is in the filter.
                    if (readIndexFilter == null || readIndexFilter.contains(readEntry.getReadIndex())) {
                        final Reads.ReadEntry.Builder readEntryBuilder = Reads.ReadEntry.newBuilder(readEntry);
                        readEntryBuilder.setReadIndex(numberOfReads);
                        writer.appendEntry(readEntryBuilder);
                        minReadLength = Math.min(minReadLength, readEntry.getReadLength());
                        maxReadLength = Math.max(maxReadLength, readEntry.getReadLength());
                        numberOfReads++;
                    } else {
                        removedByFilterCount++;
                    }
                }
                readsReader.close();
                readsReader = null;
                progress.update();
            }
            progress.stop();
        } finally {
            writer.printStats(System.out);
            System.out.println("Number of reads=" + numberOfReads);
            System.out.println("Minimum Read Length=" + minReadLength);
            System.out.println("Maximum Read Length=" + maxReadLength);
            System.out.println("Reads removed by filter=" + removedByFilterCount);
            writer.close();
            if (readsReader != null) {
                readsReader.close();
            }
        }
    }
}

From source file:eu.stratosphere.nephele.io.channels.LocalChannelWithAccessInfo.java

@Override
public void disposeSilently() {

    this.referenceCounter.set(Integer.MIN_VALUE);
    this.reservedWritePosition.set(Long.MIN_VALUE);

    if (this.channel.isOpen()) {
        try {/*w  ww  .j ava 2  s. c  o m*/
            this.channel.close();
        } catch (Throwable t) {
        }
    }

    if (this.deleteOnClose.get()) {
        this.file.delete();
    }
}

From source file:com.hunch.api.HunchResponse.java

static HunchResponse buildFromJSON(JSONObject json) {
    HunchResponse.Builder builder = getBuilder();

    // build the HunchResponse object
    int id = Integer.MIN_VALUE, topicId = Integer.MIN_VALUE;
    int questionId = Integer.MIN_VALUE, order = Integer.MIN_VALUE;
    String text = "";

    try {//from  w  w  w . j  a  v a  2 s.  c  om
        String tId = json.getString("topicId");
        try {
            topicId = Integer.parseInt(tId);
        } catch (NumberFormatException e) {
            if (tId.equals("THAY")) {
                // Teach Hunch About You!
                topicId = THAY_TOPIC_ID;
            } else {
                // some other cause of the NFE
                throw new RuntimeException("Couldn't build HunchResponse!", e);
            }
        }

        id = Integer.parseInt(json.getString("id"));
        questionId = Integer.parseInt(json.getString("questionId"));
        order = Integer.parseInt(json.getString("order"));
        text = json.getString("text");

    } catch (NumberFormatException e) {
        throw new RuntimeException("Couldn't build HunchResponse!", e);
    } catch (JSONException e) {
        throw new RuntimeException("Couldn't build HunchResponse!", e);
    } finally {
        builder.init(json).setId(id).setTopicId(topicId).setQuestionId(questionId).setOrder(order)
                .setText(text);
    }

    return builder.build();
}