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.citrixonline.android.utils.LocalAndroidSdk.java

public File lastFolderModified(File dir) {
    File[] files = dir.listFiles(new FileFilter() {
        public boolean accept(File file) {
            return file.isDirectory();
        }//  www .  j  ava2  s  .com
    });
    long lastMod = Long.MIN_VALUE;
    File choice = null;
    for (File file : files) {
        if (file.lastModified() > lastMod) {
            choice = file;
            lastMod = file.lastModified();
        }
    }
    return choice;
}

From source file:com.slytechs.utils.region.FlexRegion.java

public final void changeHappened() {
    if (this.changeId == Long.MAX_VALUE) {
        this.changeId = Long.MIN_VALUE;
    } else {// w w w  .  j  a  v a 2  s  .  c om
        this.changeId++;
    }
}

From source file:com.adstrosoftware.notificationcompass.CompassService.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
        if (previousEventTimeStamp == Long.MIN_VALUE
                || (event.timestamp - previousEventTimeStamp) > DELAY_IN_NS) {
            previousEventTimeStamp = event.timestamp;

            float[] orientation = new float[3];
            float[] rotationMatrix = new float[16];
            float[] remappedRotationMatrix = new float[16];

            SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values);

            if (event.values[0] <= -45) {
                SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Z,
                        remappedRotationMatrix);
            } else {
                remappedRotationMatrix = rotationMatrix;
            }/*from  w ww .  j ava2 s  .c  o m*/

            SensorManager.getOrientation(remappedRotationMatrix, orientation);

            Notification notification;

            double azimuth = Math.toDegrees(orientation[0]);

            if (BuildConfig.DEBUG) {
                Log.d(TAG, "Azimuth = " + azimuth);
            }

            if (azimuth <= (NORTH + ANGLE) && azimuth >= (NORTH - ANGLE)) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "NORTH");
                notification = buildNotification(R.string.north, R.drawable.ic_stat_north, azimuth);
            } else if (azimuth <= (NORTH_EAST + ANGLE) && azimuth > 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "NORTH_EAST");
                notification = buildNotification(R.string.north_east, R.drawable.ic_stat_north_east, azimuth);
            } else if (azimuth >= (NORTH_WEST - ANGLE) && azimuth < 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "NORTH_WEST");
                notification = buildNotification(R.string.north_west, R.drawable.ic_stat_north_west, azimuth);
            } else if (azimuth <= (EAST + ANGLE) && azimuth > 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "EAST");
                notification = buildNotification(R.string.east, R.drawable.ic_stat_east, azimuth);
            } else if (azimuth >= (WEST - ANGLE) && azimuth < 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "WEST");
                notification = buildNotification(R.string.west, R.drawable.ic_stat_west, azimuth);
            } else if (azimuth <= (SOUTH_EAST + ANGLE) && azimuth > 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "SOUTH_EAST");
                notification = buildNotification(R.string.south_east, R.drawable.ic_stat_south_east, azimuth);
            } else if (azimuth >= (SOUTH_WEST - ANGLE) && azimuth < 0) {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "SOUTH_WEST");
                notification = buildNotification(R.string.south_west, R.drawable.ic_stat_south_west, azimuth);
            } else {
                if (BuildConfig.DEBUG)
                    Log.d(TAG, "SOUTH");
                notification = buildNotification(R.string.south, R.drawable.ic_stat_south, azimuth);
            }

            notificationManager.notify(NOTIFICATION_ID, notification);
        }
    }
}

From source file:com.fullmeadalchemist.mustwatch.ui.log.form.LogFormFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(LogFormViewModel.class);

    Bundle bundle = this.getArguments();
    long batchId = bundle.getLong(BATCH_ID, Long.MIN_VALUE);
    if (batchId != Long.MIN_VALUE) {
        viewModel.logEntry.batchId = batchId;
        this.batchId = batchId;
        Log.i(TAG, String.format("Created LogEntry with Batch ID %d", batchId));

    } else {//from ww  w .  j  a va  2s.  co m
        Log.e(TAG, "No Batch ID was received. Redirecting back to Batch list.");
        navigationController.navigateToBatches();
    }

    updateUiDateTime();
    initClickListeners();
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(datePickerMessageReceiver,
            new IntentFilter(DATE_SET_EVENT));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(timePickerMessageReceiver,
            new IntentFilter(TIME_SET_EVENT));
}

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 {//from w w w. j a va  2 s. c  o  m
            this.channel.close();
        } catch (Throwable t) {
        }
    }

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

From source file:com.thinkbiganalytics.spark.validation.HCatDataType.java

private HCatDataType(Class clazz) {

    this.convertibleType = clazz;
    if (clazz == Date.class || clazz == Timestamp.class || clazz == byte[].class) {
        this.isnumeric = false;
    } else {/*from   w  w  w.  java  2s  . c  om*/
        this.isnumeric = true;
        BigDecimal minDecimal = new BigDecimal(Long.MIN_VALUE);
        BigDecimal maxDecimal = new BigDecimal(Long.MAX_VALUE);
        if (clazz == BigInteger.class) {
            this.min = minDecimal.toBigInteger();
            this.max = maxDecimal.toBigInteger();
        } else if (clazz == BigDecimal.class) {
            this.min = null;
            this.max = null;
        } else {
            throw new RuntimeException("Invalid class for constructor " + clazz.getCanonicalName());
        }
    }

}

From source file:org.apache.drill.exec.physical.impl.orderedpartitioner.TestOrderedPartitionExchange.java

/**
 * Starts two drillbits and runs a physical plan with a Mock scan, project, OrderedParititionExchange, Union Exchange,
 * and sort. The final sort is done first on the partition column, and verifies that the partitions are correct, in that
 * all rows in partition 0 should come in the sort order before any row in partition 1, etc. Also verifies that the standard
 * deviation of the size of the partitions is less than one tenth the mean size of the partitions, because we expect all
 * the partitions to be roughly equal in size.
 * @throws Exception/*from   ww w . j a  v  a  2s . c o m*/
 */
@Test
public void twoBitTwoExchangeRun() throws Exception {
    RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();

    try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
            Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
            DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) {

        bit1.run();
        bit2.run();
        client.connect();
        List<QueryDataBatch> results = client.runQuery(
                org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL,
                Files.toString(FileUtils.getResourceAsFile("/sender/ordered_exchange.json"), Charsets.UTF_8));
        int count = 0;
        List<Integer> partitionRecordCounts = Lists.newArrayList();
        for (QueryDataBatch b : results) {
            if (b.getData() != null) {
                int rows = b.getHeader().getRowCount();
                count += rows;
                RecordBatchLoader loader = new RecordBatchLoader(
                        new BootStrapContext(DrillConfig.create()).getAllocator());
                loader.load(b.getHeader().getDef(), b.getData());
                BigIntVector vv1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader
                        .getValueVectorId(new SchemaPath("col1", ExpressionPosition.UNKNOWN)).getFieldIds())
                        .getValueVector();
                Float8Vector vv2 = (Float8Vector) loader.getValueAccessorById(Float8Vector.class, loader
                        .getValueVectorId(new SchemaPath("col2", ExpressionPosition.UNKNOWN)).getFieldIds())
                        .getValueVector();
                IntVector pVector = (IntVector) loader.getValueAccessorById(IntVector.class,
                        loader.getValueVectorId(new SchemaPath("partition", ExpressionPosition.UNKNOWN))
                                .getFieldIds())
                        .getValueVector();
                long previous1 = Long.MIN_VALUE;
                double previous2 = Double.MIN_VALUE;
                int partPrevious = -1;
                long current1 = Long.MIN_VALUE;
                double current2 = Double.MIN_VALUE;
                int partCurrent = -1;
                int partitionRecordCount = 0;
                for (int i = 0; i < rows; i++) {
                    previous1 = current1;
                    previous2 = current2;
                    partPrevious = partCurrent;
                    current1 = vv1.getAccessor().get(i);
                    current2 = vv2.getAccessor().get(i);
                    partCurrent = pVector.getAccessor().get(i);
                    Assert.assertTrue(current1 >= previous1);
                    if (current1 == previous1) {
                        Assert.assertTrue(current2 <= previous2);
                    }
                    if (partCurrent == partPrevious || partPrevious == -1) {
                        partitionRecordCount++;
                    } else {
                        partitionRecordCounts.add(partitionRecordCount);
                        partitionRecordCount = 0;
                    }
                }
                partitionRecordCounts.add(partitionRecordCount);
                loader.clear();
            }

            b.release();
        }
        double[] values = new double[partitionRecordCounts.size()];
        int i = 0;
        for (Integer rc : partitionRecordCounts) {
            values[i++] = rc.doubleValue();
        }
        StandardDeviation stdDev = new StandardDeviation();
        Mean mean = new Mean();
        double std = stdDev.evaluate(values);
        double m = mean.evaluate(values);
        System.out.println("mean: " + m + " std dev: " + std);
        //Assert.assertTrue(std < 0.1 * m);
        assertEquals(31000, count);
    }
}

From source file:com.netflix.hollow.diffview.effigy.HollowEffigyFactory.java

private HollowEffigy objectEffigy(HollowObjectTypeDataAccess typeDataAccess, int ordinal,
        HollowDiffNodeIdentifier identifier) {
    HollowObjectSchema schema = typeDataAccess.getSchema();
    HollowEffigy effigy = new HollowEffigy(schema.getName());

    for (int i = 0; i < schema.numFields(); i++) {
        String fieldName = schema.getFieldName(i);
        String fieldType = schema.getFieldType(i) == FieldType.REFERENCE ? schema.getReferencedType(i)
                : schema.getFieldType(i).toString();
        HollowDiffNodeIdentifier fieldIdentifier = memoize(
                new HollowDiffNodeIdentifier(identifier, fieldName, fieldType));
        Object fieldValue = null;

        switch (schema.getFieldType(i)) {
        case BOOLEAN:
            fieldValue = typeDataAccess.readBoolean(ordinal, i);
            break;
        case BYTES:
            fieldValue = base64.encodeToString(typeDataAccess.readBytes(ordinal, i));
            break;
        case DOUBLE:
            fieldValue = Double.valueOf(typeDataAccess.readDouble(ordinal, i));
            break;
        case FLOAT:
            fieldValue = Float.valueOf(typeDataAccess.readFloat(ordinal, i));
            break;
        case INT:
            fieldValue = Integer.valueOf(typeDataAccess.readInt(ordinal, i));
            break;
        case LONG:
            long longVal = typeDataAccess.readLong(ordinal, i);
            if (longVal != Long.MIN_VALUE && "Date".equals(typeDataAccess.getSchema().getName()))
                fieldValue = new Date(longVal).toString();
            else/*ww  w . ja v a  2s .c o m*/
                fieldValue = Long.valueOf(typeDataAccess.readLong(ordinal, i));
            break;
        case STRING:
            fieldValue = typeDataAccess.readString(ordinal, i);
            break;
        case REFERENCE:
            fieldValue = effigy(typeDataAccess.getDataAccess(), schema.getReferencedType(i),
                    typeDataAccess.readOrdinal(ordinal, i), fieldIdentifier);
        }

        if (schema.getFieldType(i) == FieldType.REFERENCE)
            effigy.add(new Field(fieldIdentifier, fieldValue));
        else
            effigy.add(memoize(new Field(fieldIdentifier, fieldValue)));
    }

    return effigy;
}

From source file:com.google.android.apps.forscience.whistlepunk.GraphPopulator.java

/**
 * If the graphStatus shows that there are still values that need to be fetched to fill the
 * currently-displayed graph, this method will begin fetching them.
 * <p/>/*from   w  w  w  .  j a v  a  2 s .c om*/
 * Call only on the UI thread.
 */
public void requestObservations(final GraphStatus graphStatus, final DataController dataController,
        final FailureListener failureListener, final int resolutionTier, final String sensorId) {
    if (mRequestInFlight) {
        return;
    }
    final TimeRange r = getRequestRange(graphStatus);
    if (r == null) {
        mObservationDisplay.onFinish(mRequestId);
    } else {
        mRequestInFlight = true;
        dataController.getScalarReadings(sensorId, resolutionTier, r, MAX_DATAPOINTS_PER_SENSOR_LOAD,
                MaybeConsumers.chainFailure(failureListener, new FallibleConsumer<ScalarReadingList>() {
                    @Override
                    public void take(ScalarReadingList observations) {
                        mRequestInFlight = false;
                        if (graphStatus.graphIsStillValid()) {
                            final Pair<Range<Long>, Range<Double>> received = addObservationsToDisplay(
                                    observations);
                            if (received.first != null) {
                                mObservationDisplay.addRange(observations, received.second, mRequestId);
                            }
                            addToRequestedTimes(getEffectiveAddedRange(r, received.first));
                            requestObservations(graphStatus, dataController, failureListener, resolutionTier,
                                    sensorId);
                        }
                    }

                    public void addToRequestedTimes(Range<Long> effectiveAdded) {
                        mRequestedTimes = Ranges.span(mRequestedTimes, effectiveAdded);
                    }

                    public Pair<Range<Long>, Range<Double>> addObservationsToDisplay(
                            ScalarReadingList observations) {
                        List<ScalarReading> points = ScalarReading.slurp(observations);
                        long xMin = Long.MAX_VALUE;
                        long xMax = Long.MIN_VALUE;
                        double yMin = Double.MAX_VALUE;
                        double yMax = Double.MIN_VALUE;
                        Range<Long> timeRange = null;
                        Range<Double> valueRange = null;
                        for (ScalarReading point : points) {
                            if (point.getCollectedTimeMillis() < xMin) {
                                xMin = point.getCollectedTimeMillis();
                            }
                            if (point.getCollectedTimeMillis() > xMax) {
                                xMax = point.getCollectedTimeMillis();
                            }
                            if (point.getValue() < yMin) {
                                yMin = point.getValue();
                            }
                            if (point.getValue() > yMax) {
                                yMax = point.getValue();
                            }
                        }
                        if (xMin <= xMax) {
                            timeRange = Range.closed(xMin, xMax);
                        }
                        if (yMin <= yMax) {
                            valueRange = Range.closed(yMin, yMax);
                        }
                        return new Pair<>(timeRange, valueRange);
                    }
                }));
    }
    return;
}

From source file:com.uber.hoodie.utilities.sources.DFSSource.java

@Override
public Pair<Optional<JavaRDD<GenericRecord>>, String> fetchNewData(Optional<String> lastCheckpointStr,
        long maxInputBytes) {

    try {//ww w.  ja  v  a 2  s .co  m
        // obtain all eligible files under root folder.
        List<FileStatus> eligibleFiles = new ArrayList<>();
        RemoteIterator<LocatedFileStatus> fitr = fs
                .listFiles(new Path(config.getString(Config.ROOT_INPUT_PATH_PROP)), true);
        while (fitr.hasNext()) {
            LocatedFileStatus fileStatus = fitr.next();
            if (fileStatus.isDirectory() || IGNORE_FILEPREFIX_LIST.stream()
                    .filter(pfx -> fileStatus.getPath().getName().startsWith(pfx)).count() > 0) {
                continue;
            }
            eligibleFiles.add(fileStatus);
        }
        // sort them by modification time.
        eligibleFiles.sort((FileStatus f1, FileStatus f2) -> Long.valueOf(f1.getModificationTime())
                .compareTo(Long.valueOf(f2.getModificationTime())));

        // Filter based on checkpoint & input size, if needed
        long currentBytes = 0;
        long maxModificationTime = Long.MIN_VALUE;
        List<FileStatus> filteredFiles = new ArrayList<>();
        for (FileStatus f : eligibleFiles) {
            if (lastCheckpointStr.isPresent()
                    && f.getModificationTime() <= Long.valueOf(lastCheckpointStr.get())) {
                // skip processed files
                continue;
            }

            maxModificationTime = f.getModificationTime();
            currentBytes += f.getLen();
            filteredFiles.add(f);
            if (currentBytes >= maxInputBytes) {
                // we have enough data, we are done
                break;
            }
        }

        // no data to read
        if (filteredFiles.size() == 0) {
            return new ImmutablePair<>(Optional.empty(),
                    lastCheckpointStr.isPresent() ? lastCheckpointStr.get() : String.valueOf(Long.MIN_VALUE));
        }

        // read the files out.
        String pathStr = filteredFiles.stream().map(f -> f.getPath().toString())
                .collect(Collectors.joining(","));
        String schemaStr = schemaProvider.getSourceSchema().toString();
        final AvroConvertor avroConvertor = new AvroConvertor(schemaStr);

        return new ImmutablePair<>(
                Optional.of(DFSSource.fromFiles(dataFormat, avroConvertor, pathStr, sparkContext)),
                String.valueOf(maxModificationTime));
    } catch (IOException ioe) {
        throw new HoodieIOException("Unable to read from source from checkpoint: " + lastCheckpointStr, ioe);
    }
}