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.caseystella.analytics.outlier.streaming.mad.SketchyMovingMADIntegrationTest.java

@Test
public void runAccuracyBenchmark() throws IOException {
    Map<String, List<String>> benchmarks = JSONUtil.INSTANCE.load(
            new FileInputStream(new File(new File(benchmarkRoot), "combined_labels.json")),
            new TypeReference<Map<String, List<String>>>() {
            });//from w  w w .  j av  a 2 s  .  c o  m
    Assert.assertTrue(benchmarks.size() > 0);
    Map<ConfusionMatrix.ConfusionEntry, Long> overallConfusionMatrix = new HashMap<>();
    DescriptiveStatistics globalExpectedScores = new DescriptiveStatistics();
    long total = 0;
    for (Map.Entry<String, List<String>> kv : benchmarks.entrySet()) {
        File dataFile = new File(new File(benchmarkRoot), kv.getKey());
        File plotFile = new File(new File(benchmarkRoot), kv.getKey() + ".dat");
        Assert.assertTrue(dataFile.exists());
        Set<Long> expectedOutliers = Sets.newHashSet(Iterables.transform(kv.getValue(), STR_TO_TS));
        OutlierRunner runner = new OutlierRunner(outlierConfig, extractorConfigStr);
        final long[] numObservations = { 0L };
        final long[] lastTimestamp = { Long.MIN_VALUE };
        final DescriptiveStatistics timeDiffStats = new DescriptiveStatistics();
        final Map<Long, Outlier> outlierMap = new HashMap<>();
        final PrintWriter pw = new PrintWriter(plotFile);
        List<Outlier> outliers = runner.run(dataFile, 1, EnumSet.of(Severity.SEVERE_OUTLIER),
                new Function<Map.Entry<DataPoint, Outlier>, Void>() {
                    @Nullable
                    @Override
                    public Void apply(@Nullable Map.Entry<DataPoint, Outlier> kv) {
                        DataPoint dataPoint = kv.getKey();
                        Outlier outlier = kv.getValue();
                        pw.println(dataPoint.getTimestamp() + " " + outlier.getDataPoint().getValue() + " "
                                + ((outlier.getSeverity() == Severity.SEVERE_OUTLIER) ? "outlier" : "normal"));
                        outlierMap.put(dataPoint.getTimestamp(), outlier);
                        numObservations[0] += 1;
                        if (lastTimestamp[0] != Long.MIN_VALUE) {
                            timeDiffStats.addValue(dataPoint.getTimestamp() - lastTimestamp[0]);
                        }
                        lastTimestamp[0] = dataPoint.getTimestamp();
                        return null;
                    }
                });
        pw.close();
        total += numObservations[0];
        Set<Long> calculatedOutliers = Sets
                .newHashSet(Iterables.transform(outliers, OutlierRunner.OUTLIER_TO_TS));
        double stdDevDiff = Math.sqrt(timeDiffStats.getVariance());
        System.out.println("Running data from " + kv.getKey() + " - E[time delta]: "
                + ConfusionMatrix.timeConversion((long) timeDiffStats.getMean()) + ", StdDev[time delta]: "
                + ConfusionMatrix.timeConversion((long) stdDevDiff) + " mean: " + runner.getMean());
        Map<ConfusionMatrix.ConfusionEntry, Long> confusionMatrix = ConfusionMatrix.getConfusionMatrix(
                expectedOutliers, calculatedOutliers, numObservations[0], (long) timeDiffStats.getMean(), 3 //stdDevDiff > 30000?0:3
                , outlierMap, globalExpectedScores);

        ConfusionMatrix.printConfusionMatrix(confusionMatrix);
        overallConfusionMatrix = ConfusionMatrix.merge(overallConfusionMatrix, confusionMatrix);
    }
    System.out.println("Really ran " + total);
    ConfusionMatrix.printConfusionMatrix(overallConfusionMatrix);
    ConfusionMatrix.printStats("Global Expected Outlier Scores", globalExpectedScores);
}

From source file:com.linkedin.pinot.query.pruner.SegmentPrunerTest.java

private IndexSegment getIndexSegment(final String resourceName) {
    return new IndexSegment() {

        @Override/*from  w  w w . ja  v  a2  s.co m*/
        public String getSegmentName() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public SegmentMetadata getSegmentMetadata() {
            return new SegmentMetadata() {

                @Override
                public int getTotalAggregateDocs() {
                    return 0;
                }

                @Override
                public Map<String, String> toMap() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getVersion() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public int getTotalDocs() {
                    // TODO Auto-generated method stub
                    return 0;
                }

                @Override
                public Interval getTimeInterval() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public Duration getTimeGranularity() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getShardingKey() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public Schema getSchema() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getTableName() {
                    return resourceName;
                }

                @Override
                public String getName() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getIndexType() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getIndexDir() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public String getCrc() {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public long getIndexCreationTime() {
                    // TODO Auto-generated method stub
                    return 0;
                }

                @Override
                public long getPushTime() {
                    return Long.MIN_VALUE;
                }

                @Override
                public long getRefreshTime() {
                    return Long.MIN_VALUE;
                }

                @Override
                public boolean hasDictionary(String columnName) {
                    // TODO Auto-generated method stub
                    return false;
                }

                @Override
                public boolean close() {
                    // TODO Auto-generated method stub
                    return false;
                }

                @Override
                public boolean hasStarTree() {
                    return false;
                }
            };
        }

        @Override
        public StarTreeIndexNode getStarTreeRoot() {
            return null;
        }

        @Override
        public IndexType getIndexType() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public DataSource getDataSource(String columnName) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public String[] getColumnNames() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public String getAssociatedDirectory() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public void destroy() {
            // TODO Auto-generated method stub
        }

        @Override
        public int getTotalDocs() {
            // TODO Auto-generated method stub
            return 0;
        }
    };
}

From source file:it.mb.whatshare.GCMIntentService.java

private void readWhitelist() {
    File whitelist = new File(getFilesDir(), MainActivity.INBOUND_DEVICES_FILENAME);
    // if whitelist doesn't exist, don't bother
    long lastModified = whitelist.exists() ? whitelist.lastModified() : Long.MIN_VALUE;

    if (lastCheckedWhitelist < lastModified) {
        FileInputStream fis = null;
        try {/*from ww w  . j a va  2s. c o m*/
            fis = openFileInput(MainActivity.INBOUND_DEVICES_FILENAME);
            ObjectInputStream ois = new ObjectInputStream(fis);
            Object read = ois.readObject();

            @SuppressWarnings("unchecked")
            List<PairedDevice> devices = (ArrayList<PairedDevice>) read;
            senderWhitelist = new HashSet<String>();
            for (PairedDevice device : devices) {
                try {
                    senderWhitelist.add(String.valueOf(device.id.hashCode()));
                } catch (NullPointerException e) {
                    // backward compatibility... devices didn't have an ID
                    senderWhitelist.add(String.valueOf(device.name.hashCode()));
                }
            }
        } catch (FileNotFoundException e) {
            // it's ok, no whitelist, all messages are rejected
        } catch (StreamCorruptedException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO here the error should be notified I guess
            e.printStackTrace();
        } finally {
            if (fis != null)
                try {
                    fis.close();
                } catch (IOException e) {
                    // can't do much...
                    e.printStackTrace();
                }
        }
        // whatever happens, don't keep checking for nothing
        lastCheckedWhitelist = lastModified;
    }
}

From source file:org.mitre.mpf.wfm.camel.JobCompleteProcessorImpl.java

@Override
public void wfmProcess(Exchange exchange) throws WfmProcessingException {
    Long jobId = exchange.getIn().getHeader(MpfHeaders.JOB_ID, Long.class);
    assert jobId != null : String.format("The header '%s' (value=%s) was not set or is not a Long.",
            MpfHeaders.JOB_ID, exchange.getIn().getHeader(MpfHeaders.JOB_ID));

    if (jobId == Long.MIN_VALUE) {
        // If we receive a very large negative Job ID, it means an exception was encountered during processing of a job,
        // and none of the provided error handling logic could fix it. Further processing should not be performed.
        log.warn(//  w  w  w .j ava2  s. c o m
                "[Job {}:*:*] An error prevents a job from completing successfully. Please review the logs for additional information.",
                jobId);
    } else {
        String statusString = exchange.getIn().getHeader(MpfHeaders.JOB_STATUS, String.class);
        Mutable<JobStatus> jobStatus = new MutableObject<>(JobStatus.parse(statusString, JobStatus.UNKNOWN));

        markJobStatus(jobId, jobStatus.getValue());

        try {
            markJobStatus(jobId, JobStatus.BUILDING_OUTPUT_OBJECT);

            // NOTE: jobStatus is mutable - it __may__ be modified in createOutputObject!
            createOutputObject(jobId, jobStatus);
        } catch (Exception exception) {
            log.warn("Failed to create the output object for Job {} due to an exception.", jobId, exception);
            jobStatus.setValue(JobStatus.ERROR);
        }

        markJobStatus(jobId, jobStatus.getValue());

        try {
            callback(jobId);
        } catch (Exception exception) {
            log.warn("Failed to make callback (if appropriate) for Job #{}.", jobId);
        }

        // Tear down the job.
        try {
            destroy(jobId);
        } catch (Exception exception) {
            log.warn(
                    "Failed to clean up Job {} due to an exception. Data for this job will remain in the transient data store, but the status of the job has not been affected by this failure.",
                    jobId, exception);
        }

        JobCompleteNotification jobCompleteNotification = new JobCompleteNotification(
                exchange.getIn().getHeader(MpfHeaders.JOB_ID, Long.class));

        for (NotificationConsumer<JobCompleteNotification> consumer : consumers) {
            if (!jobCompleteNotification.isConsumed()) {
                try {
                    consumer.onNotification(this, new JobCompleteNotification(
                            exchange.getIn().getHeader(MpfHeaders.JOB_ID, Long.class)));
                } catch (Exception exception) {
                    log.warn("Completion consumer '{}' threw an exception.", consumer, exception);
                }
            }
        }

        AtmosphereController.broadcast(new JobStatusMessage(jobId, 100, jobStatus.getValue(), new Date()));
        jobProgressStore.setJobProgress(jobId, 100.0f);
        log.info("[Job {}:*:*] Job complete!", jobId);
    }
}

From source file:org.apache.click.util.RequestTypeConverter.java

/**
 * Return the converted value for the given value object and target type.
 *
 * @param value the value object to convert
 * @param toType the target class type to convert the value to
 * @return a converted value into the specified type
 *///www  .  j av  a 2 s. c  o  m
protected Object convertValue(Object value, Class<?> toType) {
    Object result = null;

    if (value != null) {

        // If array -> array then convert components of array individually
        if (value.getClass().isArray() && toType.isArray()) {
            Class<?> componentType = toType.getComponentType();

            result = Array.newInstance(componentType, Array.getLength(value));

            for (int i = 0, icount = Array.getLength(value); i < icount; i++) {
                Array.set(result, i, convertValue(Array.get(value, i), componentType));
            }

        } else {
            if ((toType == Integer.class) || (toType == Integer.TYPE)) {
                result = Integer.valueOf((int) OgnlOps.longValue(value));

            } else if ((toType == Double.class) || (toType == Double.TYPE)) {
                result = new Double(OgnlOps.doubleValue(value));

            } else if ((toType == Boolean.class) || (toType == Boolean.TYPE)) {
                result = Boolean.valueOf(value.toString());

            } else if ((toType == Byte.class) || (toType == Byte.TYPE)) {
                result = Byte.valueOf((byte) OgnlOps.longValue(value));

            } else if ((toType == Character.class) || (toType == Character.TYPE)) {
                result = Character.valueOf((char) OgnlOps.longValue(value));

            } else if ((toType == Short.class) || (toType == Short.TYPE)) {
                result = Short.valueOf((short) OgnlOps.longValue(value));

            } else if ((toType == Long.class) || (toType == Long.TYPE)) {
                result = Long.valueOf(OgnlOps.longValue(value));

            } else if ((toType == Float.class) || (toType == Float.TYPE)) {
                result = new Float(OgnlOps.doubleValue(value));

            } else if (toType == BigInteger.class) {
                result = OgnlOps.bigIntValue(value);

            } else if (toType == BigDecimal.class) {
                result = bigDecValue(value);

            } else if (toType == String.class) {
                result = OgnlOps.stringValue(value);

            } else if (toType == java.util.Date.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.util.Date(time);
                }

            } else if (toType == java.sql.Date.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Date(time);
                }

            } else if (toType == java.sql.Time.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Time(time);
                }

            } else if (toType == java.sql.Timestamp.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Timestamp(time);
                }
            }
        }

    } else {
        if (toType.isPrimitive()) {
            result = OgnlRuntime.getPrimitiveDefaultValue(toType);
        }
    }
    return result;
}

From source file:com.izforge.izpack.core.data.DefaultVariablesTest.java

/**
 * Tests the {@link Variables#getInt(String)} and {@link Variables#getInt(String, int)} methods.
 *///from  w ww . jav  a  2  s.  c  o  m
@Test
public void testIntVariables() {
    // check basic set, get
    variables.set("var1", "0");
    variables.set("var2", Integer.toString(Integer.MIN_VALUE));
    variables.set("var3", Integer.toString(Integer.MAX_VALUE));
    assertEquals(0, variables.getInt("var1"));
    assertEquals(Integer.MIN_VALUE, variables.getInt("var2"));
    assertEquals(Integer.MAX_VALUE, variables.getInt("var3"));

    // check when the variable is null
    variables.set("null", null);
    assertEquals(-1, variables.getInt("null"));
    assertEquals(9999, variables.getInt("null", 9999));

    // check when the variable doesn't exist
    assertEquals(-1, variables.getInt("nonExistingVariable"));
    assertEquals(9999, variables.getInt("nonExistingVariable", 9999));

    // check when the variable is not an integer value
    variables.set("notAnInt", "abcdef");
    assertEquals(-1, variables.getInt("notAnInt"));
    assertEquals(9999, variables.getInt("notAnInt", 9999));

    // check behaviour when value < Integer.MIN_VALUE or > Integer.MAX_VALUE
    variables.set("exceed1", Long.toString(Long.MIN_VALUE));
    variables.set("exceed2", Long.toString(Long.MAX_VALUE));

    assertEquals(-1, variables.getInt("exceed1"));
    assertEquals(9999, variables.getInt("exceed1", 9999));
    assertEquals(-1, variables.getInt("exceed2"));
    assertEquals(9999, variables.getInt("exceed2", 9999));
}

From source file:com.cinnober.msgcodec.json.JsonValueHandlerTest.java

@Test
public void testSafeInt64DecodeMinValue() throws IOException {
    JsonParser p = f.createParser("\"9223372036854775808\"");
    p.nextToken();/*w w  w.ja va2 s . c o m*/
    assertEquals(Long.MIN_VALUE, JsonValueHandler.UINT64_SAFE.readValue(p).longValue());
}

From source file:edu.kit.rest.usergroupmanagement.test.UserGroupTestService.java

@Override
public IEntityWrapper<? extends IDefaultUserGroup> addGroup(String groupId, String groupName,
        String description, HttpContext hc) {
    UserGroup group = factoryGroupEntity(groupId);
    group.setId(Long.MIN_VALUE);
    group.setGroupName(groupName);//from  w ww  .j a  va2  s. com
    group.setDescription(description);
    groups.add(group);
    return new UserGroupWrapper(group);
}

From source file:io.wcm.testing.mock.aem.MockPage.java

@Override
public long timeUntilValid() {
    if (!hasContent()) {
        return Long.MIN_VALUE;
    }/*from  www . j  a va 2  s  .  co  m*/
    Calendar on = getOnTime();
    Calendar off = getOffTime();
    if (on == null && off == null) {
        return 0L;
    }
    long now = System.currentTimeMillis();
    long timeDiffOn = (on == null) ? 0L : on.getTimeInMillis() - now;
    if (timeDiffOn > 0L) {
        return timeDiffOn;
    }
    long timeDiffOff = (off == null) ? 0L : off.getTimeInMillis() - now;
    if (timeDiffOff < 0L) {
        return timeDiffOff;
    }
    return 0L;
}

From source file:com.facebook.presto.operator.scalar.MathFunctions.java

@Description("absolute value")
@ScalarFunction/*from  w w  w . j  a v  a2  s .c o  m*/
@SqlType(StandardTypes.BIGINT)
public static long abs(@SqlType(StandardTypes.BIGINT) long num) {
    checkCondition(num != Long.MIN_VALUE, NUMERIC_VALUE_OUT_OF_RANGE,
            "Value -9223372036854775808 is out of range for abs(bigint)");
    return Math.abs(num);
}