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.chinamobile.bcbsp.partition.RangeWritePartition.java

/**
 * This method is used to partition graph vertexes. Every vertex in the
 * split is partitioned to the local staff.
 * @param recordReader The recordreader of the split.
 * @throws IOException The io exception/*  w  w w.jav a2 s.  c o  m*/
 * @throws InterruptedException The Interrupted Exception
 */
@Override
public void write(RecordReader recordReader) throws IOException, InterruptedException {
    int headNodeNum = 0;
    int local = 0;
    int lost = 0;
    int partitionid = this.staff.getPartition();
    int maxid = Integer.MIN_VALUE;
    try {
        while (recordReader != null && recordReader.nextKeyValue()) {
            headNodeNum++;
            Text key = new Text(recordReader.getCurrentKey().toString());
            Text value = new Text(recordReader.getCurrentValue().toString());
            Text vertexID = this.recordParse.getVertexID(key);
            if (vertexID != null) {
                local++;
                int vertexid = Integer.parseInt(vertexID.toString());
                if (vertexid > maxid) {
                    maxid = vertexid;
                }
                Vertex vertex = this.recordParse.recordParse(key.toString(), value.toString());
                this.staff.getGraphData().addForAll(vertex);
            } else {
                lost++;
                continue;
            }
        }
        if (lost == 0) {
            counter.put(maxid, partitionid);
            this.ssrc.setDirFlag(new String[] { "3" });
            this.ssrc.setCounter(counter);
            HashMap<Integer, Integer> rangerouter = this.sssc.rangerouter(ssrc);
            this.staff.setRangeRouter(rangerouter);
        }
        LOG.info("The number of vertices that were read from the input file: " + headNodeNum);
        LOG.info("The number of vertices that were put into the partition: " + local);
        LOG.info("The number of verteices in the partition that cound not be" + " parsed:" + lost);
    } catch (IOException e) {
        throw e;
    } catch (InterruptedException e) {
        throw e;
    }
}

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

@Test
public void testBestOffset2() {
    //int v = -3358711;
    int offset = -205;
    int v = offset << 14 | 0;
    IntArrayList list = new IntArrayList(1);
    list.add(v);/*from w  w w .j av  a  2 s . com*/
    //list.add((offset+1) << 14 | 0);
    assertEquals(-205, getBestOffset(list, Integer.MIN_VALUE, 14, 3));
    System.out.println(v >> 14);

}

From source file:com.sisrni.managedbean.FacultadMB.java

/** 
 * Metodo para guardar una instancia de 'Facultad' en la tabla 
 * correspondiente de la base de datos//from  ww w  . j  av a2s  . com
 */
public void guardarFacultad() {
    String msg = "Facultad Almacenada Exitosamente!";
    try {
        facultad.setIdFacultad(Integer.MIN_VALUE);
        facultad.setIdOrganismo(organismoService.findById(organismo.getIdOrganismo()));
        facultadService.save(facultad);
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_INFO, "Guardado!!", msg));

    } catch (Exception e) {
        JsfUtil.addErrorMessage("Error al Guardar Facultad!");
        e.printStackTrace();
    }
    cargarFacultad();
}

From source file:com.ethlo.kfka.sse.EventController.java

@RequestMapping(value = "/v1/events", method = RequestMethod.GET)
public SseEmitter event(@RequestHeader(value = "Last-Event-ID", required = false) String lastEventIdHeader,
        @RequestParam(required = true, value = "topic") String topic,
        @RequestParam(required = false, value = "rewind") Integer rewind,
        @RequestParam(required = false, value = "lastEventId") Long lastEventIdOverride) throws IOException {
    final SseEmitter sseEmitter = new SseEmitter();
    final Emitter emitter = new Emitter(sseEmitter);

    logger.debug("Opening emitter {}", emitter.hashCode());
    this.emitters.add(emitter);

    final Long lastEventId = lastEventIdOverride != null ? lastEventIdOverride
            : (lastEventIdHeader != null ? Long.parseLong(lastEventIdHeader) : null);

    final KfkaPredicate p = new KfkaPredicate().topic(topic);
    if (lastEventId != null) {
        p.messageId(lastEventId + 1);/*from w  ww  .  j a  v a2s.  c  o m*/
        p.relativeOffset(Integer.MIN_VALUE + 10);
    } else {
        final int offset = rewind != null ? Math.abs(rewind) * -1 : -20;
        p.relativeOffset(offset);
    }

    final KfkaMessageListener l = kfkaManager.addListener((msg) -> {
        try {
            emitter.emit(msg);
        } catch (IOException exc) {
            throw Throwables.propagate(exc);
        }
    }, p);

    emitter.setListener(l);

    // Remove on completion
    sseEmitter.onCompletion(new Runnable() {
        @Override
        public void run() {
            logger.debug("Emitter {} closed", emitter.hashCode());
            emitters.remove(emitter);
            kfkaManager.removeListener(emitter.getListener());
        }
    });

    return sseEmitter;
}

From source file:com.digipom.manteresting.android.processor.json.NailsJsonProcessor.java

@Override
public ArrayList<ContentProviderOperation> parse(JSONObject response, Meta meta) throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final TreeSet<Integer> nailIds = new TreeSet<Integer>();
    final Cursor nails = resolver.query(ManterestingContract.Nails.CONTENT_URI, new String[] { Nails.NAIL_ID },
            null, null, Nails.NAIL_ID + " DESC");
    int greatestOfExisting = Integer.MIN_VALUE;

    if (nails != null && !nails.isClosed()) {
        try {/*  w w  w. j  a  v  a  2  s  .  co  m*/
            nails.moveToFirst();

            final int idColumn = nails.getColumnIndex(Nails.NAIL_ID);

            while (!nails.isAfterLast()) {
                final int nailId = nails.getInt(idColumn);
                nailIds.add(nailId);
                greatestOfExisting = nailId > greatestOfExisting ? nailId : greatestOfExisting;
                nails.moveToNext();
            }
        } finally {
            if (nails != null) {
                nails.close();
            }
        }
    }

    final JSONArray objects = response.getJSONArray("objects");
    int smallestOfNew = Integer.MAX_VALUE;

    for (int i = 0; i < objects.length(); i++) {
        final JSONObject nailObject = objects.getJSONObject(i);

        final boolean isPrivate = nailObject.getJSONObject("workbench").getBoolean("private");

        if (!isPrivate) {
            final ContentProviderOperation.Builder builder = ContentProviderOperation
                    .newInsert(Nails.CONTENT_URI);
            final int nailId = nailObject.getInt("id");
            smallestOfNew = nailId < smallestOfNew ? nailId : smallestOfNew;

            builder.withValue(Nails.NAIL_ID, nailId);
            builder.withValue(Nails.NAIL_JSON, nailObject.toString());

            batch.add(builder.build());
            nailIds.add(nailId);
        }
    }

    // If more than LIMIT were fetched, and this was the initial fetch, then
    // we flush everything in the DB before adding the new nails (as
    // otherwise we would introduce a gap).
    if (meta.nextOffset == meta.nextLimit // For initial fetch
            && smallestOfNew > greatestOfExisting) {
        if (LoggerConfig.canLog(Log.DEBUG)) {
            Log.d(TAG, "Flushing all existing nails on initial fetch, so as to avoid a gap.");
        }

        resolver.delete(Nails.CONTENT_URI, null, null);
    } else {
        // If more than 500 nails, find the 500th biggest and delete those
        // after it.
        if (nailIds.size() > MAX_COUNT) {
            Iterator<Integer> it = nailIds.descendingIterator();

            for (int i = 0; i < MAX_COUNT; i++) {
                it.next();
            }

            final Integer toDelete = it.next();

            if (LoggerConfig.canLog(Log.DEBUG)) {
                Log.d(TAG, "deleting from nails where NAIL_ID is less than or equal to " + toDelete);
            }

            SelectionBuilder selectionBuilder = new SelectionBuilder();
            selectionBuilder.where(ManterestingContract.Nails.NAIL_ID + " <= ?",
                    new String[] { String.valueOf(toDelete) });
            resolver.delete(ManterestingContract.Nails.CONTENT_URI, selectionBuilder.getSelection(),
                    selectionBuilder.getSelectionArgs());
        }
    }

    return batch;
}

From source file:org.crazydog.util.spring.NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 *
 * @param number      the number to convert
 * @param targetClass the target class to convert to
 * @return the converted number/*from   w  ww.  j a  v  a2 s  .c o m*/
 * @throws IllegalArgumentException if the target class is not supported
 *                                  (i.e. not a standard Number subclass as included in the JDK)
 * @see Byte
 * @see Short
 * @see Integer
 * @see Long
 * @see BigInteger
 * @see Float
 * @see Double
 * @see BigDecimal
 */
@SuppressWarnings("unchecked")
public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass)
        throws IllegalArgumentException {

    org.springframework.util.Assert.notNull(number, "Number must not be null");
    org.springframework.util.Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return (T) number;
    } else if (Byte.class == targetClass) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Byte(number.byteValue());
    } else if (Short.class == targetClass) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Short(number.shortValue());
    } else if (Integer.class == targetClass) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Integer(number.intValue());
    } else if (Long.class == targetClass) {
        BigInteger bigInt = null;
        if (number instanceof BigInteger) {
            bigInt = (BigInteger) number;
        } else if (number instanceof BigDecimal) {
            bigInt = ((BigDecimal) number).toBigInteger();
        }
        // Effectively analogous to JDK 8's BigInteger.longValueExact()
        if (bigInt != null && (bigInt.compareTo(LONG_MIN) < 0 || bigInt.compareTo(LONG_MAX) > 0)) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Long(number.longValue());
    } else if (BigInteger.class == targetClass) {
        if (number instanceof BigDecimal) {
            // do not lose precision - use BigDecimal's own conversion
            return (T) ((BigDecimal) number).toBigInteger();
        } else {
            // original value is not a Big* number - use standard long conversion
            return (T) BigInteger.valueOf(number.longValue());
        }
    } else if (Float.class == targetClass) {
        return (T) new Float(number.floatValue());
    } else if (Double.class == targetClass) {
        return (T) new Double(number.doubleValue());
    } else if (BigDecimal.class == targetClass) {
        // always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return (T) new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:com.devnexus.ting.config.WebFilterConfig.java

@Bean
public FilterRegistrationBean lazyLoadingFilterRegistrationBean() {

    final OpenEntityManagerInViewFilter openEntityManagerInViewFilter = new OpenEntityManagerInViewFilter();
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();

    registrationBean.setFilter(openEntityManagerInViewFilter);
    registrationBean.addUrlPatterns("/s/*");
    registrationBean.addUrlPatterns("/api/*");
    registrationBean.setOrder(Integer.MIN_VALUE);
    return registrationBean;
}

From source file:com.questdb.net.http.handlers.QueryHandlerSmallBufferTest.java

@Test(expected = MalformedChunkCodingException.class)
public void testColumnValueTooLargeForBuffer() throws Exception {
    StringBuilder allChars = new StringBuilder();
    for (char c = Character.MIN_VALUE; c < 0xD800; c++) { //
        allChars.append(c);/*  w  w w. ja v a  2 s. co  m*/
    }

    String allCharString = allChars.toString();
    QueryHandlerTest.generateJournal("xyz", allCharString, 1.900232E-10, 2.598E20, Long.MAX_VALUE,
            Integer.MIN_VALUE, new Timestamp(-102023));
    String query = "select x, id from xyz \n limit 1";
    QueryHandlerTest.download(query, temp);
}

From source file:com.nebhale.devoxx2013.web.GameControllerTest.java

@Test
public void readDoesNotExist() throws Exception {
    this.mockMvc.perform(get("/games/{game}", Integer.MIN_VALUE)).andExpect(status().isNotFound());
}

From source file:it.polimi.diceH2020.SPACE4CloudWS.solvers.solversImpl.QNSolver.QNSolver.java

@Override
protected Pair<Double, Boolean> run(Pair<List<File>, List<File>> pFiles, String remoteName,
        String remoteDirectory) throws Exception {
    File jmtFile = pFiles.getLeft().stream().filter(s -> s.getName().contains(".jsimg")).findFirst().get();

    String jmtFileName = jmtFile.getName();

    String remotePath = remoteDirectory + File.separator + jmtFileName;

    boolean stillNotOk = true;
    for (int i = 0; stillNotOk && i < MAX_ITERATIONS; ++i) {
        logger.info(remoteName + "-> Starting Queuing Net resolution on the server");

        cleanRemoteSubDirectory(remoteDirectory);
        sendFiles(remoteDirectory, pFiles.getLeft());
        sendFiles(remoteDirectory, pFiles.getRight());
        logger.debug(remoteName + "-> Working files sent");

        String command = connSettings.getMaxDuration() == Integer.MIN_VALUE
                ? String.format("java -cp %s jmt.commandline.Jmt sim %s ", connSettings.getSolverPath(),
                        remotePath)/*from   w  w w  . ja  va 2  s .  c o m*/
                : String.format("java -cp %s jmt.commandline.Jmt sim %s -maxtime %d",
                        connSettings.getSolverPath(), remotePath, connSettings.getMaxDuration());

        logger.debug(remoteName + "-> Starting JMT model...");
        List<String> remoteMsg = connector.exec(command, getClass());
        if (remoteMsg.contains("exit-status: 0")) {
            stillNotOk = false;
            logger.info(remoteName + "-> The remote optimization process completed correctly");
        } else {
            logger.debug(remoteName + "-> Remote exit status: " + remoteMsg);
        }
    }

    if (stillNotOk) {
        logger.info(remoteName + "-> Error in remote optimization");
        throw new Exception("Error in the QN server");
    } else {
        File solFile = fileUtility.provideTemporaryFile(jmtFileName + "-result", ".jsim");
        connector.receiveFile(solFile.getAbsolutePath(), remotePath + "-result" + ".jsim", getClass());
        SolutionsWrapper resultObject = SolutionsWrapper.unMarshal(solFile);
        if (fileUtility.delete(solFile))
            logger.debug(solFile + " deleted");

        Double throughput = resultObject.getMeanValue();
        /* This is a workaround for the crazy behavior of the PNML transformation
            * that converts milliseconds to seconds.
            * Here we turn hertz into kilohertz to obtain results consistent
            * with our input.
            */
        if (usingInputModel)
            throughput /= 1000;
        boolean failure = resultObject.isFailed();

        return Pair.of(throughput, failure);
    }
}