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.linkedin.pinot.core.realtime.impl.dictionary.MutableDictionaryTest.java

private void testMutableDictionary(MutableDictionary dictionary, FieldSpec.DataType dataType) {
    Map<Object, Integer> valueToDictId = new HashMap<>();
    int numEntries = 0;
    for (int i = 0; i < NUM_ENTRIES; i++) {
        Object value = makeRandomObjectOfType(dataType);
        if (valueToDictId.containsKey(value)) {
            Assert.assertEquals(dictionary.indexOf(value), (int) valueToDictId.get(value));
        } else {/*from  w w  w .  j  a  va2s  . co m*/
            dictionary.index(value);
            int dictId = dictionary.indexOf(value);
            Assert.assertEquals(dictId, numEntries++);
            valueToDictId.put(value, dictId);
        }
    }
    if (dataType == FieldSpec.DataType.INT) {
        Object value = new Integer(Integer.MIN_VALUE);
        if (valueToDictId.containsKey(value)) {
            Assert.assertEquals(dictionary.indexOf(value), (int) valueToDictId.get(value));
        } else {
            dictionary.index(value);
            int dictId = dictionary.indexOf(value);
            Assert.assertEquals(dictId, numEntries++);
            valueToDictId.put(value, dictId);
        }
    }
}

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

private Ranges convertAnnotationsToRanges(String annotationFilename, DoubleIndexedIdentifier ids,
        ConcatSortedAlignmentReader input) throws IOException {
    Ranges ranges = new Ranges();
    if (annotationFilename == null)
        return null;
    Object2ObjectMap<String, ObjectList<Annotation>> annotations = CompactAlignmentToAnnotationCountsMode
            .readAnnotations(annotationFilename);
    Object2IntMap<String> starts = new Object2IntLinkedOpenHashMap<String>();
    Object2IntMap<String> ends = new Object2IntLinkedOpenHashMap<String>();
    Object2IntMap<String> refIndices = new Object2IntLinkedOpenHashMap<String>();
    starts.defaultReturnValue(Integer.MAX_VALUE);
    ends.defaultReturnValue(Integer.MIN_VALUE);

    for (ObjectList<Annotation> value : annotations.values()) {

        for (Annotation ann : value) {

            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            String chromosome = ann.getChromosome();
            String id = ann.getId();
            min = starts.getInt(id);//from ww  w  .j  av a  2 s . com
            max = ends.getInt(id);

            starts.put(id, Math.min(min, ann.getStart()));
            ends.put(id, Math.max(max, ann.getEnd()));

            assert chromosome != null : " annotation must contain non null chromosome.";

        }
    }
    for (final String id : starts.keySet()) {
        final Range range = new Range();
        final int referenceIndex = refIndices.getInt(id);
        range.min = starts.getInt(id);
        range.max = ends.getInt(id);
        ranges.add(range, referenceIndex);
    }

    ranges.order();
    return ranges;
}

From source file:mondrian.rolap.MemberCacheHelper.java

public synchronized void flushCache() {
    mapMemberToChildren.clear();/*from w  w  w .j  ava 2 s  .  co  m*/
    mapKeyToMember.clear();
    mapLevelToMembers.clear();
    mapParentToNamedChildren.clear();
    // We also need to clear the approxRowCount of each level.
    for (Level level : rolapHierarchy.getLevels()) {
        ((RolapLevel) level).setApproxRowCount(Integer.MIN_VALUE);
    }
}

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

@Test
public void testSimple() throws Exception {
    List<Integer> nums = new ArrayList<Integer>();

    Timing timing = new Timing();
    DistributedPriorityQueue<Integer> queue = null;
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
            timing.connection(), new RetryOneTime(1));
    client.start();//from  w  ww. j a v a 2s.  com
    try {
        final CountDownLatch hasConsumedLatch = new CountDownLatch(1);
        final CountDownLatch okToConsumeLatch = new CountDownLatch(1);
        BlockingQueueConsumer<Integer> consumer = new BlockingQueueConsumer<Integer>(
                Mockito.mock(ConnectionStateListener.class)) {
            @Override
            public void consumeMessage(Integer message) throws Exception {
                hasConsumedLatch.countDown();
                okToConsumeLatch.await();
                super.consumeMessage(message);
            }
        };
        queue = QueueBuilder.builder(client, consumer, new IntSerializer(), "/test").buildPriorityQueue(0);
        queue.start();

        nums.add(Integer.MIN_VALUE);
        queue.put(Integer.MIN_VALUE, Integer.MIN_VALUE); // the queue background thread will be blocking with the first item - make sure it's the lowest value
        Assert.assertTrue(timing.awaitLatch(hasConsumedLatch));

        Random random = new Random();
        for (int i = 0; i < 100; ++i) {
            int priority = random.nextInt();
            nums.add(priority);
            queue.put(priority, priority);
        }

        while (queue.getCache().getData().children.size() < (nums.size() - 1)) // -1 because the first message has already been consumed
        {
            timing.sleepABit(); // wait for the cache to catch up
        }
        okToConsumeLatch.countDown();

        assertOrdering(consumer, nums.size());
    } catch (AssertionError e) {
        StringBuilder message = new StringBuilder(e.getMessage());
        for (int i : nums) {
            message.append(i).append("\t").append(DistributedPriorityQueue.priorityToString(i)).append("\n");
        }
        Assert.fail(message.toString());
    } finally {
        IOUtils.closeQuietly(queue);
        IOUtils.closeQuietly(client);
    }
}

From source file:mesclasses.model.Eleve.java

@Override
public int compareTo(Eleve t) {
    return getFullName() == null ? (t.getFullName() == null ? 0 : Integer.MIN_VALUE)
            : (t.getFullName() == null ? Integer.MAX_VALUE : getFullName().compareTo(t.getFullName()));
}

From source file:LongVector.java

/**
 * Searches for the first occurence of the given argument, beginning the
 * search at index, and testing for equality using the equals method.
 * //  w w  w . jav  a 2  s  .  c om
 * @param elem
 *            object to look for
 * @return the index of the first occurrence of the object argument in this
 *         vector at position index or later in the vector; returns -1 if
 *         the object is not found.
 */
public final int indexOf(long elem) {

    for (int i = 0; i < _size; i++) {
        if (_data[i] == elem)
            return i;
    }

    return java.lang.Integer.MIN_VALUE;
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.ChartAxisFactory.java

public static ValueAxis createRangeAxis(RangeAxisConfig rangeAxisConfig, PlotInstance plotInstance)
        throws ChartPlottimeException {
    if (rangeAxisConfig.getValueType() == ValueType.UNKNOWN
            || rangeAxisConfig.getValueType() == ValueType.INVALID) {
        return null;
    } else {//from  w  ww  . j a va  2  s  .  c om
        RangeAxisData rangeAxisData = plotInstance.getPlotData().getRangeAxisData(rangeAxisConfig);

        double initialUpperBound = rangeAxisData.getUpperViewBound();
        double initialLowerBound = rangeAxisData.getLowerViewBound();

        double upperBound = initialUpperBound;
        double lowerBound = initialLowerBound;

        // fetch old zooming
        LinkAndBrushMaster linkAndBrushMaster = plotInstance.getMasterPlotConfiguration()
                .getLinkAndBrushMaster();
        Range axisZoom = linkAndBrushMaster.getRangeAxisZoom(rangeAxisConfig,
                plotInstance.getCurrentPlotConfigurationClone());

        List<ValueSource> valueSources = rangeAxisConfig.getValueSources();
        if (rangeAxisConfig.hasAbsolutStackedPlot()) {
            for (ValueSource valueSource : valueSources) {
                VisualizationType seriesType = valueSource.getSeriesFormat().getSeriesType();
                if (seriesType == VisualizationType.BARS || seriesType == VisualizationType.AREA) {
                    if (valueSource.getSeriesFormat().getStackingMode() == StackingMode.ABSOLUTE) {
                        Pair<Double, Double> minMax = calculateUpperAndLowerBounds(valueSource, plotInstance);
                        if (upperBound < minMax.getSecond()) {
                            upperBound = minMax.getSecond();
                        }
                        if (lowerBound > minMax.getFirst()) {
                            lowerBound = minMax.getFirst();
                        }
                    }
                }
            }
        }

        double margin = upperBound - lowerBound;
        if (lowerBound == upperBound) {
            margin = lowerBound;
        }
        if (margin == 0) {
            margin = 0.1;
        }

        double normalPad = RangeAxisConfig.padFactor * margin;

        if (rangeAxisConfig.isLogarithmicAxis()) {
            if (!rangeAxisConfig.isUsingUserDefinedLowerViewBound()) {
                lowerBound -= RangeAxisConfig.logPadFactor * lowerBound;
            }
            if (!rangeAxisConfig.isUsingUserDefinedUpperViewBound()) {
                upperBound += RangeAxisConfig.logPadFactor * upperBound;
            }
        } else {
            // add margin
            if (!rangeAxisConfig.isUsingUserDefinedLowerViewBound()) {
                lowerBound -= normalPad;
            }
            if (!rangeAxisConfig.isUsingUserDefinedUpperViewBound()) {
                upperBound += normalPad;
            }
        }

        boolean includeZero = false;
        if (isIncludingZero(rangeAxisConfig, initialLowerBound)
                && !rangeAxisConfig.isUsingUserDefinedLowerViewBound()) {
            // if so set lower bound to zero
            lowerBound = 0.0;
            includeZero = true;
        }

        boolean upToOne = false;
        // if there are only relative plots set upper Bound to 1.0
        if (rangeAxisConfig.mustHaveUpperBoundOne(initialUpperBound)
                && !rangeAxisConfig.isUsingUserDefinedUpperViewBound()) {
            upperBound = 1.0;
            upToOne = true;

        }

        if (includeZero && !upToOne) {
            upperBound *= 1.05;
        }

        String label = rangeAxisConfig.getLabel();
        if (label == null) {
            label = I18N.getGUILabel("plotter.unnamed_value_label");
        }

        ValueAxis rangeAxis;

        if (rangeAxisConfig.getValueType() == ValueType.NOMINAL && !valueSources.isEmpty()) {
            // get union of distinct values of all plotValueConfigs on range axis
            int maxValue = Integer.MIN_VALUE;
            for (ValueSource valueSource : rangeAxisData.getRangeAxisConfig().getValueSources()) {
                ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
                double maxValueInSource = valueSourceData.getMaxValue();
                if (maxValueInSource > maxValue) {
                    maxValue = (int) maxValueInSource;
                }
            }
            Vector<String> yValueStrings = new Vector<String>(maxValue);
            yValueStrings.setSize(maxValue + 1);
            ValueSourceData valueSourceData = plotInstance.getPlotData()
                    .getValueSourceData(valueSources.get(0));

            for (int i = 0; i <= maxValue; ++i) {
                yValueStrings.set(i, valueSourceData.getStringForValue(SeriesUsageType.MAIN_SERIES, i));
            }
            String[] yValueStringArray = new String[yValueStrings.size()];
            int i = 0;
            for (String s : yValueStrings) {
                yValueStringArray[i] = s;
                ++i;
            }
            CustomSymbolAxis symbolRangeAxis = new CustomSymbolAxis(null, yValueStringArray);
            symbolRangeAxis.setVisible(true);
            symbolRangeAxis.setAutoRangeIncludesZero(false);

            symbolRangeAxis.saveUpperBound(upperBound, initialUpperBound);
            symbolRangeAxis.saveLowerBound(lowerBound, initialLowerBound);

            symbolRangeAxis.setLabel(label);
            Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont();
            if (axesFont != null) {
                symbolRangeAxis.setLabelFont(axesFont);
                symbolRangeAxis.setTickLabelFont(axesFont);
            }

            // set range if axis has been zoomed before
            if (axisZoom != null) {
                symbolRangeAxis.setRange(axisZoom);
            }
            rangeAxis = symbolRangeAxis;
        } else if (rangeAxisConfig.getValueType() == ValueType.NUMERICAL) {
            NumberAxis numberRangeAxis;
            if (rangeAxisConfig.isLogarithmicAxis()) {
                if (rangeAxisData.getMinYValue() <= 0) {
                    throw new ChartPlottimeException("log_axis_contains_zero", label);
                }
                numberRangeAxis = new CustomLogarithmicAxis(null);
                ((CustomLogarithmicAxis) numberRangeAxis).saveUpperBound(upperBound, initialUpperBound);
                ((CustomLogarithmicAxis) numberRangeAxis).saveLowerBound(lowerBound, initialLowerBound);
            } else {
                numberRangeAxis = new CustomNumberAxis();
                ((CustomNumberAxis) numberRangeAxis).saveUpperBound(upperBound, initialUpperBound);
                ((CustomNumberAxis) numberRangeAxis).saveLowerBound(lowerBound, initialLowerBound);
            }

            numberRangeAxis.setAutoRangeIncludesZero(false);

            numberRangeAxis.setVisible(true);
            numberRangeAxis.setLabel(label);
            Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont();
            if (axesFont != null) {
                numberRangeAxis.setLabelFont(axesFont);
                numberRangeAxis.setTickLabelFont(axesFont);
            }

            // set range if axis has been zoomed before
            if (axisZoom != null) {
                numberRangeAxis.setRange(axisZoom);
            }

            rangeAxis = numberRangeAxis;
        } else if (rangeAxisConfig.getValueType() == ValueType.DATE_TIME) {
            CustomDateAxis dateRangeAxis;
            if (rangeAxisConfig.isLogarithmicAxis()) {
                throw new ChartPlottimeException("logarithmic_not_supported_for_value_type", label,
                        ValueType.DATE_TIME);
            } else {
                dateRangeAxis = new CustomDateAxis();
            }

            dateRangeAxis.saveUpperBound(upperBound, initialUpperBound);
            dateRangeAxis.saveLowerBound(lowerBound, initialLowerBound);

            dateRangeAxis.setVisible(true);
            dateRangeAxis.setLabel(label);
            Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont();
            if (axesFont != null) {
                dateRangeAxis.setLabelFont(axesFont);
            }

            // set range if axis has been zoomed before
            if (axisZoom != null) {
                dateRangeAxis.setRange(axisZoom);
            }

            rangeAxis = dateRangeAxis;
        } else {
            throw new RuntimeException("Unknown value type. This should not happen");
        }

        // configure format
        formatAxis(plotInstance.getCurrentPlotConfigurationClone(), rangeAxis);
        return rangeAxis;
    }
}

From source file:com.buaa.cfs.fs.permission.FsPermission.java

/**
 * Get the user file creation mask (umask)
 * <p>//  w w  w .j  a  v  a 2s  .  co m
 * {@code UMASK_LABEL} config param has umask value that is either symbolic or octal.
 * <p>
 * Symbolic umask is applied relative to file mode creation mask; the permission op characters '+' clears the
 * corresponding bit in the mask, '-' sets bits in the mask.
 * <p>
 * Octal umask, the specified bits are set in the file mode creation mask.
 * <p>
 * {@code DEPRECATED_UMASK_LABEL} config param has umask value set to decimal.
 */
public static FsPermission getUMask(Configuration conf) {
    int umask = DEFAULT_UMASK;

    // To ensure backward compatibility first use the deprecated key.
    // If the deprecated key is not present then check for the new key
    if (conf != null) {
        String confUmask = conf.get(UMASK_LABEL);
        int oldUmask = conf.getInt(DEPRECATED_UMASK_LABEL, Integer.MIN_VALUE);
        try {
            if (confUmask != null) {
                umask = new UmaskParser(confUmask).getUMask();
            }
        } catch (IllegalArgumentException iae) {
            // Provide more explanation for user-facing message
            String type = iae instanceof NumberFormatException ? "decimal" : "octal or symbolic";
            String error = "Unable to parse configuration " + UMASK_LABEL + " with value " + confUmask + " as "
                    + type + " umask.";
            LOG.warn(error);

            // If oldUmask is not set, then throw the exception
            if (oldUmask == Integer.MIN_VALUE) {
                throw new IllegalArgumentException(error);
            }
        }

        if (oldUmask != Integer.MIN_VALUE) { // Property was set with old key
            if (umask != oldUmask) {
                LOG.warn(DEPRECATED_UMASK_LABEL + " configuration key is deprecated. " + "Convert to "
                        + UMASK_LABEL + ", using octal or symbolic umask " + "specifications.");
                // Old and new umask values do not match - Use old umask
                umask = oldUmask;
            }
        }
    }

    return new FsPermission((short) umask);
}

From source file:IntVector.java

/**
 * Searches for the first occurence of the given argument, beginning the
 * search at index, and testing for equality using the equals method.
 * // w w w .j a v  a  2s  .  c  om
 * @param elem
 *            object to look for
 * @return the index of the first occurrence of the object argument in this
 *         vector at position index or later in the vector; returns -1 if
 *         the object is not found.
 */
public final int indexOf(int elem) {

    for (int i = 0; i < _size; i++) {
        if (_data[i] == elem)
            return i;
    }

    return java.lang.Integer.MIN_VALUE;
}

From source file:mobile.tiis.appv2.LoginActivity.java

/**
 * Gets the current registration ID for application on GCM service.
 * <p/>/*from   w  w w.j  a  v a  2s . c  o  m*/
 * If result is empty, the appv2 needs to register.
 *
 * @return registration ID, or empty string if there is no existing
 * registration ID.
 */
private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGCMPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        Log.i(TAG, "Registration not found.");
        return "";
    }
    // Check if appv2 was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // appv2 version.
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(TAG, "App version changed.");
        return "";
    }
    return registrationId;
}