Example usage for java.lang Long MIN_VALUE

List of usage examples for java.lang Long MIN_VALUE

Introduction

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

Prototype

long MIN_VALUE

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

Click Source Link

Document

A constant holding the minimum value a long can have, -263.

Usage

From source file:com.netbase.insightapi.clientlib.InsightAPIQuery.java

/**
 * Sets the query to be restricted to a specific alert date range. The
 * operation removes any existing alert date range. If d1 is Long.MIN_VALUE,
 * nothing else is done. If d2 is Long.MAX_VALUE, the endpoint of the range
 * is not set.//from  w ww.j  a va 2s .co m
 * 
 * @param d1
 * @param d2
 */
public void setAlertDateRange(long d1, long d2) {
    setAlertDateRange(d1 == Long.MIN_VALUE ? null : new java.util.Date(d1),
            d2 == Long.MAX_VALUE ? null : new java.util.Date(d2));
}

From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java

/**
 * @param fileName//  ww  w .j ava2s  . c om
 * @param urlStr
 * @param isSiteFile
 * @param propChgListener
 */
public void transferFile(final String fileName, final String urlStr, final boolean isSiteFile,
        final PropertyChangeListener propChgListener) {

    final String prgName = HttpLargeFileTransfer.class.toString();

    final File file = new File(fileName);
    if (file.exists()) {
        final long fileSize = file.length();
        if (fileSize > 0) {
            SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
                protected String errorMsg = null;
                protected FileInputStream fis = null;
                protected OutputStream fos = null;
                protected int nChunks = 0;

                /* (non-Javadoc)
                 * @see javax.swing.SwingWorker#doInBackground()
                 */
                @Override
                protected Integer doInBackground() throws Exception {
                    try {
                        Thread.sleep(100);
                        fis = new FileInputStream(file);

                        nChunks = (int) (fileSize / MAX_CHUNK_SIZE);
                        if (fileSize % MAX_CHUNK_SIZE > 0) {
                            nChunks++;
                        }

                        byte[] buf = new byte[BUFFER_SIZE];
                        long bytesRemaining = fileSize;

                        String clientID = String.valueOf((long) (Long.MIN_VALUE * Math.random()));

                        URL url = new URL(urlStr);

                        UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);

                        for (int i = 0; i < nChunks; i++) {
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                            if (i == nChunks - 1) {
                                Thread.sleep(500);
                                int x = 0;
                                x++;
                            }

                            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                            conn.setRequestMethod("PUT");
                            conn.setDoOutput(true);
                            conn.setDoInput(true);
                            conn.setUseCaches(false);

                            int chunkSize = (int) ((bytesRemaining > MAX_CHUNK_SIZE) ? MAX_CHUNK_SIZE
                                    : bytesRemaining);
                            bytesRemaining -= chunkSize;

                            conn.setRequestProperty("Content-Type", "application/octet-stream");
                            conn.setRequestProperty("Content-Length", String.valueOf(chunkSize));

                            conn.setRequestProperty(CLIENT_ID_HEADER, clientID);
                            conn.setRequestProperty(FILE_NAME_HEADER, fileName);
                            conn.setRequestProperty(FILE_CHUNK_COUNT_HEADER, String.valueOf(nChunks));
                            conn.setRequestProperty(FILE_CHUNK_HEADER, String.valueOf(i));
                            conn.setRequestProperty(SERVICE_NUMBER, "10");
                            conn.setRequestProperty(IS_SITE_FILE, Boolean.toString(isSiteFile));

                            fos = conn.getOutputStream();

                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, (int)((double)chunkSize / BUFFER_SIZE));
                            int cnt = 0;
                            int bytesRead = 0;
                            while (bytesRead < chunkSize) {
                                int read = fis.read(buf);
                                if (read == -1) {
                                    break;

                                } else if (read > 0) {
                                    bytesRead += read;
                                    fos.write(buf, 0, read);
                                }
                                cnt++;
                                //firePropertyChange(prgName, cnt-1, cnt);
                            }
                            fos.close();

                            if (conn.getResponseCode() != HttpServletResponse.SC_OK) {
                                System.err.println(
                                        conn.getResponseMessage() + " " + conn.getResponseCode() + " ");
                                BufferedReader in = new BufferedReader(
                                        new InputStreamReader(conn.getErrorStream()));
                                String line = null;
                                StringBuilder sb = new StringBuilder();
                                while ((line = in.readLine()) != null) {
                                    sb.append(line);
                                    sb.append("\n");
                                }
                                System.out.println(sb.toString());
                                in.close();

                            } else {
                                System.err.println("OK");
                            }
                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                        }

                    } catch (IOException ex) {
                        errorMsg = ex.toString();
                    }

                    //firePropertyChange(prgName, 0, 100);
                    return null;
                }

                @Override
                protected void done() {
                    super.done();

                    UIRegistry.getStatusBar().setProgressDone(prgName);

                    UIRegistry.clearSimpleGlassPaneMsg();

                    if (StringUtils.isNotEmpty(errorMsg)) {
                        UIRegistry.showError(errorMsg);
                    }

                    if (propChgListener != null) {
                        propChgListener.propertyChange(
                                new PropertyChangeEvent(HttpLargeFileTransfer.this, "Done", 0, 1));
                    }
                }
            };

            final JStatusBar statusBar = UIRegistry.getStatusBar();
            statusBar.setIndeterminate(HttpLargeFileTransfer.class.toString(), true);

            UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("Transmitting..."), 24);

            backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(final PropertyChangeEvent evt) {
                    System.out.println(evt.getPropertyName() + "  " + evt.getNewValue());
                    if (prgName.equals(evt.getPropertyName())) {
                        Integer value = (Integer) evt.getNewValue();
                        if (value == Integer.MAX_VALUE) {
                            statusBar.setIndeterminate(prgName, true);
                            UIRegistry.writeSimpleGlassPaneMsg(
                                    getLocalizedMessage("Transfering data into the database."), 24);

                        } else {
                            statusBar.setValue(prgName, value);
                        }
                    }
                }
            });
            backupWorker.execute();

        } else {
            // file doesn't exist
        }
    } else {
        // file doesn't exist
    }
}

From source file:org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionPolicy.java

/**
 * We receive store files sorted in ascending order by seqId then scan the list of files. If the
 * current file has a maxTimestamp older than last known maximum, treat this file as it carries
 * the last known maximum. This way both seqId and timestamp are in the same order. If files carry
 * the same maxTimestamps, they are ordered by seqId. We then reverse the list so they are ordered
 * by seqId and maxTimestamp in descending order and build the time windows. All the out-of-order
 * data into the same compaction windows, guaranteeing contiguous compaction based on sequence id.
 *//*from  w ww  .j a v a 2s  . c  o  m*/
public CompactionRequest selectMinorCompaction(ArrayList<StoreFile> candidateSelection, boolean mayUseOffPeak,
        boolean mayBeStuck) throws IOException {
    long now = EnvironmentEdgeManager.currentTime();
    long oldestToCompact = getOldestToCompact(comConf.getDateTieredMaxStoreFileAgeMillis(), now);

    List<Pair<StoreFile, Long>> storefileMaxTimestampPairs = Lists
            .newArrayListWithCapacity(candidateSelection.size());
    long maxTimestampSeen = Long.MIN_VALUE;
    for (StoreFile storeFile : candidateSelection) {
        // if there is out-of-order data,
        // we put them in the same window as the last file in increasing order
        maxTimestampSeen = Math.max(maxTimestampSeen,
                storeFile.getMaximumTimestamp() == null ? Long.MIN_VALUE : storeFile.getMaximumTimestamp());
        storefileMaxTimestampPairs.add(new Pair<StoreFile, Long>(storeFile, maxTimestampSeen));
    }
    Collections.reverse(storefileMaxTimestampPairs);

    CompactionWindow window = getIncomingWindow(now);
    int minThreshold = comConf.getDateTieredIncomingWindowMin();
    PeekingIterator<Pair<StoreFile, Long>> it = Iterators
            .peekingIterator(storefileMaxTimestampPairs.iterator());
    while (it.hasNext()) {
        if (window.compareToTimestamp(oldestToCompact) < 0) {
            break;
        }
        int compResult = window.compareToTimestamp(it.peek().getSecond());
        if (compResult > 0) {
            // If the file is too old for the window, switch to the next window
            window = window.nextEarlierWindow();
            minThreshold = comConf.getMinFilesToCompact();
        } else {
            // The file is within the target window
            ArrayList<StoreFile> fileList = Lists.newArrayList();
            // Add all files in the same window. For incoming window
            // we tolerate files with future data although it is sub-optimal
            while (it.hasNext() && window.compareToTimestamp(it.peek().getSecond()) <= 0) {
                fileList.add(it.next().getFirst());
            }
            if (fileList.size() >= minThreshold) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Processing files: " + fileList + " for window: " + window);
                }
                DateTieredCompactionRequest request = generateCompactionRequest(fileList, window, mayUseOffPeak,
                        mayBeStuck, minThreshold);
                if (request != null) {
                    return request;
                }
            }
        }
    }
    // A non-null file list is expected by HStore
    return new CompactionRequest(Collections.<StoreFile>emptyList());
}

From source file:com.eventsourcing.postgresql.PostgreSQLJournalTest.java

@Test
@SneakyThrows/*  www.j  av a2s  .c om*/
public void serializationValue() {
    assertEquals(serializationResult(TestClass.builder().pByte(Byte.MIN_VALUE).build()).pByte(),
            Byte.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().pByte(Byte.MAX_VALUE).build()).pByte(),
            Byte.MAX_VALUE);

    assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MIN_VALUE).build()).oByte(),
            Byte.MIN_VALUE);
    assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MAX_VALUE).build()).oByte(),
            Byte.MAX_VALUE);

    assertEquals(
            serializationResult(TestClass.builder().pByteArr("Hello, world".getBytes()).build()).pByteArr(),
            "Hello, world".getBytes());
    assertEquals(
            serializationResult(TestClass.builder().oByteArr(toObject(("Hello, world").getBytes())).build())
                    .oByteArr(),
            "Hello, world".getBytes());

    assertEquals(serializationResult(TestClass.builder().pShort(Short.MIN_VALUE).build()).pShort(),
            Short.MIN_VALUE);
    assertEquals((short) serializationResult(TestClass.builder().oShort(Short.MAX_VALUE).build()).oShort(),
            Short.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pInt(Integer.MIN_VALUE).build()).pInt(),
            Integer.MIN_VALUE);
    assertEquals((int) serializationResult(TestClass.builder().oInt(Integer.MAX_VALUE).build()).oInt(),
            Integer.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pLong(Long.MIN_VALUE).build()).pLong(),
            Long.MIN_VALUE);
    assertEquals((long) serializationResult(TestClass.builder().oLong(Long.MAX_VALUE).build()).oLong(),
            Long.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pFloat(Float.MIN_VALUE).build()).pFloat(),
            Float.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().oFloat(Float.MAX_VALUE).build()).oFloat(),
            Float.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pDouble(Double.MIN_VALUE).build()).pDouble(),
            Double.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().oDouble(Double.MAX_VALUE).build()).oDouble(),
            Double.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pBoolean(true).build()).pBoolean(), true);
    assertEquals(serializationResult(TestClass.builder().pBoolean(false).build()).pBoolean(), false);

    assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(true).build()).oBoolean(), true);
    assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(false).build()).oBoolean(), false);

    assertEquals(serializationResult(TestClass.builder().str("Hello, world").build()).str(), "Hello, world");

    UUID uuid = UUID.randomUUID();
    assertEquals(serializationResult(TestClass.builder().uuid(uuid).build()).uuid(), uuid);

    assertEquals(serializationResult(TestClass.builder().e(TestClass.E.B).build()).e(), TestClass.E.B);

    assertEquals(serializationResult(TestClass.builder().value(new SomeValue("test")).build()).value().value(),
            "test");

    assertEquals(serializationResult(TestClass.builder()
            .value1(new SomeValue1(Collections.singletonList(new SomeValue2(new SomeValue("test"))))).build())
                    .value1().value().get(0).value().value(),
            "test");

    ArrayList<List<String>> l = new ArrayList<>();
    ArrayList<String> l1 = new ArrayList<>();
    l1.add("test");
    l.add(l1);
    assertEquals(serializationResult(TestClass.builder().list(l).build()).list().get(0).get(0), "test");

    Map<String, List<String>> map = new HashMap<>();
    LinkedList<String> list = new LinkedList<>(Arrays.asList("Hello"));
    map.put("test", list);
    map.put("anothertest", list);
    assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("test").get(0), "Hello");
    assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("anothertest").get(0),
            "Hello");

    assertFalse(
            serializationResult(TestClass.builder().optional(Optional.empty()).build()).optional().isPresent());
    assertTrue(serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional()
            .isPresent());
    assertEquals(
            serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional().get(),
            "test");

    BigDecimal bigDecimal = new BigDecimal("0.00000000000000000000000000001");
    assertEquals(serializationResult(TestClass.builder().bigDecimal(bigDecimal).build()).bigDecimal(),
            bigDecimal);

    BigInteger bigInteger = new BigInteger("100001");
    assertEquals(serializationResult(TestClass.builder().bigInteger(bigInteger).build()).bigInteger(),
            bigInteger);

    Date date = new Date();
    assertEquals(serializationResult(TestClass.builder().date(date).build()).date(), date);
}

From source file:com.oembedler.moon.graphql.test.GenericTodoSchemaParserTest.java

@Test
public void updateTodoLongMutation_Success() throws IOException {
    GraphQLQueryTemplate graphQLQueryTemplate = new GraphQLQueryTemplate(graphQLSchemaHolder);

    GraphQLQueryTemplate.MutationQuery mQuery = graphQLQueryTemplate.forMutation("updateTodoLongMutation",
            Long.MIN_VALUE);

    GraphQLRxExecutionResult result = GraphQLQueryExecutor.create(graphQLSchemaHolder).query(mQuery.getQuery())
            .arguments(mQuery.getVariables()).execute();

    Assert.assertTrue(result.getErrors().size() == 0);
    LOGGER.info("Complexity: {}. Result: {}", result.getComplexity(), prettifyPrint(result.getData()));
}

From source file:com.fanniemae.ezpie.common.StringUtilities.java

public static Object toObject(String typeName, String value) {
    if ((value == null) || value.isEmpty()) {
        return "";
    }/*from  w ww.j  av a  2  s  . c  o  m*/

    switch (typeName) {
    case "Boolean":
        return Boolean.parseBoolean(value);
    case "Byte":
    case "SByte":
        return Byte.parseByte(value);
    case "Byte[]":
        return value.toCharArray();
    case "Char":
        return value.charAt(0);
    case "Char[]":
        return value.toCharArray();
    case "DateTime":
        Date dtValue = new Date(Long.parseLong(value));
        if (dtValue == new Date(Long.MIN_VALUE)) {
            return null;
        }
        return dtValue;
    case "Decimal":
    case "Double":
    case "Single":
        return Double.parseDouble(value);
    case "Float":
        return Float.parseFloat(value);
    case "UUID":
        return UUID.fromString(value);
    case "Int":
    case "Integer":
    case "Int16":
    case "Int32":
    case "UInt16":
        return Integer.parseInt(value);
    case "Int64":
    case "Long":
    case "UInt32":
    case "UInt64":
        return Long.parseLong(value);
    case "NCLOB":
        return "NCLOB";
    case "Short":
        return Short.parseShort(value);
    case "String":
        return value;
    case "TimeSpan":
        return value;
    default:
        return null;
    }
}

From source file:org.apache.flink.table.codegen.SortCodeGeneratorTest.java

private Object value1(InternalType type, Random rnd) {
    if (type.equals(InternalTypes.BOOLEAN)) {
        return false;
    } else if (type.equals(InternalTypes.BYTE)) {
        return Byte.MIN_VALUE;
    } else if (type.equals(InternalTypes.SHORT)) {
        return Short.MIN_VALUE;
    } else if (type.equals(InternalTypes.INT)) {
        return Integer.MIN_VALUE;
    } else if (type.equals(InternalTypes.LONG)) {
        return Long.MIN_VALUE;
    } else if (type.equals(InternalTypes.FLOAT)) {
        return Float.MIN_VALUE;
    } else if (type.equals(InternalTypes.DOUBLE)) {
        return Double.MIN_VALUE;
    } else if (type.equals(InternalTypes.STRING)) {
        return BinaryString.fromString("");
    } else if (type instanceof DecimalType) {
        DecimalType decimalType = (DecimalType) type;
        return Decimal.fromBigDecimal(new BigDecimal(Integer.MIN_VALUE), decimalType.precision(),
                decimalType.scale());/* w  w w.  j a  v  a2s.c  om*/
    } else if (type instanceof ArrayType) {
        byte[] bytes = new byte[rnd.nextInt(7) + 1];
        rnd.nextBytes(bytes);
        BinaryArray array = BinaryArray.fromPrimitiveArray(bytes);
        for (int i = 0; i < bytes.length; i++) {
            array.setNullByte(i);
        }
        return array;
    } else if (type.equals(InternalTypes.BINARY)) {
        byte[] bytes = new byte[rnd.nextInt(7) + 1];
        rnd.nextBytes(bytes);
        return bytes;
    } else if (type instanceof RowType) {
        return GenericRow.of(new Object[] { null });
    } else if (type instanceof GenericType) {
        return new BinaryGeneric<>(rnd.nextInt(), IntSerializer.INSTANCE);
    } else {
        throw new RuntimeException("Not support!");
    }
}

From source file:org.kegbot.app.service.CheckinService.java

/**
 * @return {@code true} if state was reset.
 *///  w w w . ja  v a 2s .c om
private boolean resetCheckinStateIfNeeded() {
    if (mPrefsHelper.getLastCheckinVersion() == mKegbotVersion) {
        return false;
    }
    mPrefsHelper.setUpdateNeeded(false);
    mPrefsHelper.setUpdateRequired(false);
    mPrefsHelper.setLastCheckinAttempt(Long.MIN_VALUE);
    mPrefsHelper.setLastCheckinSuccess(Long.MIN_VALUE);
    mPrefsHelper.setLastCheckinStatus("unknown");
    return true;
}

From source file:com.alfaariss.oa.engine.tgt.memory.MemoryTGTFactory.java

/**
 * @see com.alfaariss.oa.api.poll.IPollable#poll()
 *///from w w w .  j  a  v  a 2 s  . c  o m
public long poll() throws OAException {
    if (_htTGT != null)
        return _htTGT.size();

    return Long.MIN_VALUE;
}

From source file:com.google.android.gms.internal.zzbti.java

private int zzacf() throws IOException {
    char[] cArr = this.zzcpH;
    int i = this.pos;
    long j = 0;/* ww  w .jav  a  2s  . co m*/
    Object obj = null;
    int i2 = 1;
    int i3 = 0;
    int i4 = 0;
    int i5 = this.limit;
    int i6 = i;
    while (true) {
        Object obj2;
        if (i6 + i4 == i5) {
            if (i4 == cArr.length) {
                return 0;
            }
            if (zzqe(i4 + 1)) {
                i6 = this.pos;
                i5 = this.limit;
            } else if (i3 != 2 && i2 != 0 && (j != Long.MIN_VALUE || obj != null)) {
                if (obj == null) {
                    j = -j;
                }
                this.zzcpL = j;
                this.pos += i4;
                this.zzcpK = 15;
                return 15;
            } else if (i3 == 2 && i3 != 4 && i3 != 7) {
                return 0;
            } else {
                this.zzcpM = i4;
                this.zzcpK = 16;
                return 16;
            }
        }
        char c = cArr[i6 + i4];
        int i7;
        switch (c) {
        case C0394R.styleable.AppCompatTheme_dialogTheme /*43*/:
            if (i3 != 5) {
                return 0;
            }
            i = 6;
            i3 = i2;
            obj2 = obj;
            continue;
        case C0394R.styleable.AppCompatTheme_listDividerAlertDialog /*45*/:
            if (i3 == 0) {
                i = 1;
                i7 = i2;
                obj2 = 1;
                i3 = i7;
                continue;
            } else if (i3 == 5) {
                i = 6;
                i3 = i2;
                obj2 = obj;
                break;
            } else {
                return 0;
            }
        case C0394R.styleable.AppCompatTheme_actionDropDownStyle /*46*/:
            if (i3 != 2) {
                return 0;
            }
            i = 3;
            i3 = i2;
            obj2 = obj;
            continue;
        case C0394R.styleable.AppCompatTheme_searchViewStyle /*69*/:
        case Quests.SELECT_COMPLETED_UNCLAIMED /*101*/:
            if (i3 != 2 && i3 != 4) {
                return 0;
            }
            i = 5;
            i3 = i2;
            obj2 = obj;
            continue;
        default:
            if (c >= '0' && c <= '9') {
                if (i3 != 1 && i3 != 0) {
                    if (i3 != 2) {
                        if (i3 != 3) {
                            if (i3 != 5 && i3 != 6) {
                                i = i3;
                                i3 = i2;
                                obj2 = obj;
                                break;
                            }
                            i = 7;
                            i3 = i2;
                            obj2 = obj;
                            break;
                        }
                        i = 4;
                        i3 = i2;
                        obj2 = obj;
                        break;
                    } else if (j != 0) {
                        long j2 = (10 * j) - ((long) (c - 48));
                        i = (j > -922337203685477580L || (j == -922337203685477580L && j2 < j)) ? 1 : 0;
                        i &= i2;
                        obj2 = obj;
                        j = j2;
                        i7 = i3;
                        i3 = i;
                        i = i7;
                        break;
                    } else {
                        return 0;
                    }
                }
                j = (long) (-(c - 48));
                i = 2;
                i3 = i2;
                obj2 = obj;
                continue;
            } else if (zzc(c)) {
                return 0;
            }
            break;
        }
        if (i3 != 2) {
        }
        if (i3 == 2) {
        }
        this.zzcpM = i4;
        this.zzcpK = 16;
        return 16;
        i4++;
        obj = obj2;
        i2 = i3;
        i3 = i;
    }
}