Java Code Examples for org.apache.commons.lang3.mutable.MutableLong#setValue()

The following examples show how to use org.apache.commons.lang3.mutable.MutableLong#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StateTracker.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
void bucketAccessed(long bucketId)
{
  long now = System.currentTimeMillis();
  if (accessedBucketIds.add(bucketId) || now - lastUpdateAccessTime > updateAccessTimeInterval) {
    synchronized (bucketLastAccess) {
      for (long id : accessedBucketIds) {
        MutableLong lastAccessTime = bucketLastAccess.get(id);
        if (lastAccessTime != null) {
          lastAccessTime.setValue(now);
        } else {
          bucketLastAccess.put(id, new MutableLong(now));
        }
      }
    }
    accessedBucketIds.clear();
    lastUpdateAccessTime = now;
  }
}
 
Example 2
Source File: Convol.java    From ij-ridgedetection with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute gauss mask 0.
 *
 * @param num
 *            the num
 * @param sigma
 *            the sigma
 * @return the double[]
 */
/*
 * num ist eigentlich pointer - aufrufende Funkion nimmt an, dass num geändert
 * wird. Übergebe es deswegen als MutableDouble aus CommonsLang
 */
public double[] compute_gauss_mask_0(MutableLong num, double sigma) {

	int i, n;
	double limit;
	double[] h;

	limit = LinesUtil.MASK_SIZE(LinesUtil.MAX_SIZE_MASK_0, sigma); /* Error < 0.001 on each side */
	n = (int) limit;
	h = new double[2 * n + 1];
	for (i = -n + 1; i <= n - 1; i++)
		h[n + i] = phi0(-i + 0.5, sigma) - phi0(-i - 0.5, sigma);
	h[0] = 1.0 - phi0(n - 0.5, sigma);
	h[2 * n] = phi0(-n + 0.5, sigma);
	num.setValue(n);
	return h;
}
 
Example 3
Source File: Convol.java    From ij-ridgedetection with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute gauss mask 1.
 *
 * @param num
 *            the num
 * @param sigma
 *            the sigma
 * @return the double[]
 */
/*
 * num ist eigentlich pointer - aufrufende Funkion nimmt an, dass num geändert
 * wird. Übergebe es deswegen als MutableDouble aus CommonsLang
 */
public double[] compute_gauss_mask_1(MutableLong num, double sigma) {
	int i, n;
	double limit;
	double[] h;

	limit = LinesUtil.MASK_SIZE(LinesUtil.MAX_SIZE_MASK_1, sigma); /* Error < 0.001 on each side */
	n = (int) limit;
	h = new double[2 * n + 1];

	for (i = -n + 1; i <= n - 1; i++)
		h[n + i] = phi1(-i + 0.5, sigma) - phi1(-i - 0.5, sigma);
	h[0] = -phi1(n - 0.5, sigma);
	h[2 * n] = phi1(-n + 0.5, sigma);
	num.setValue(n);
	return h;
}
 
Example 4
Source File: Convol.java    From ij-ridgedetection with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute gauss mask 2.
 *
 * @param num
 *            the num
 * @param sigma
 *            the sigma
 * @return the double[]
 */
/*
 * num ist eigentlich pointer - aufrufende Funkion nimmt an, dass num geändert
 * wird. Übergebe es deswegen als MutableDouble aus CommonsLang
 */
public double[] compute_gauss_mask_2(MutableLong num, double sigma) {
	int i, n;
	double limit;
	double[] h;

	limit = LinesUtil.MASK_SIZE(LinesUtil.MAX_SIZE_MASK_2, sigma); /* Error < 0.001 on each side */
	n = (int) limit;
	h = new double[2 * n + 1];

	for (i = -n + 1; i <= n - 1; i++)
		h[n + i] = phi2(-i + 0.5, sigma) - phi2(-i - 0.5, sigma);
	h[0] = -phi2(n - 0.5, sigma);
	h[2 * n] = phi2(-n + 0.5, sigma);
	num.setValue(n);
	return h;
}
 
Example 5
Source File: TestHFileProcedurePrettyPrinter.java    From hbase with Apache License 2.0 6 votes vote down vote up
private List<String> checkOutput(BufferedReader reader, MutableLong putCount,
  MutableLong deleteCount, MutableLong markDeletedCount) throws IOException {
  putCount.setValue(0);
  deleteCount.setValue(0);
  markDeletedCount.setValue(0);
  List<String> fileScanned = new ArrayList<>();
  for (;;) {
    String line = reader.readLine();
    if (line == null) {
      return fileScanned;
    }
    LOG.info(line);
    if (line.contains("V: mark deleted")) {
      markDeletedCount.increment();
    } else if (line.contains("/Put/")) {
      putCount.increment();
    } else if (line.contains("/DeleteFamily/")) {
      deleteCount.increment();
    } else if (line.startsWith("Scanning -> ")) {
      fileScanned.add(line.split(" -> ")[1]);
    } else {
      fail("Unrecognized output: " + line);
    }
  }
}
 
Example 6
Source File: WriteHeavyIncrementObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
private long getUniqueTimestamp(byte[] row) {
  int slot = Bytes.hashCode(row) & mask;
  MutableLong lastTimestamp = lastTimestamps[slot];
  long now = System.currentTimeMillis();
  synchronized (lastTimestamp) {
    long pt = lastTimestamp.longValue() >> 10;
    if (now > pt) {
      lastTimestamp.setValue(now << 10);
    } else {
      lastTimestamp.increment();
    }
    return lastTimestamp.longValue();
  }
}
 
Example 7
Source File: ParquetGroupScanStatistics.java    From Bats with Apache License 2.0 4 votes vote down vote up
public void collect(List<T> metadataList) {
  resetHolders();
  boolean first = true;
  for (T metadata : metadataList) {
    long localRowCount = (long) TableStatisticsKind.ROW_COUNT.getValue(metadata);
    for (Map.Entry<SchemaPath, ColumnStatistics> columnsStatistics : metadata.getColumnsStatistics().entrySet()) {
      SchemaPath schemaPath = columnsStatistics.getKey();
      ColumnStatistics statistics = columnsStatistics.getValue();
      MutableLong emptyCount = new MutableLong();
      MutableLong previousCount = columnValueCounts.putIfAbsent(schemaPath, emptyCount);
      if (previousCount == null) {
        previousCount = emptyCount;
      }
      Long nullsNum = (Long) statistics.getStatistic(ColumnStatisticsKind.NULLS_COUNT);
      if (previousCount.longValue() != GroupScan.NO_COLUMN_STATS && nullsNum != null && nullsNum != GroupScan.NO_COLUMN_STATS) {
        previousCount.add(localRowCount - nullsNum);
      } else {
        previousCount.setValue(GroupScan.NO_COLUMN_STATS);
      }
      ColumnMetadata columnMetadata = SchemaPathUtils.getColumnMetadata(schemaPath, metadata.getSchema());
      TypeProtos.MajorType majorType = columnMetadata != null ? columnMetadata.majorType() : null;
      boolean partitionColumn = checkForPartitionColumn(statistics, first, localRowCount, majorType, schemaPath);
      if (partitionColumn) {
        Object value = partitionValueMap.get(metadata.getLocation(), schemaPath);
        Object currentValue = statistics.getStatistic(ColumnStatisticsKind.MAX_VALUE);
        if (value != null && value != BaseParquetMetadataProvider.NULL_VALUE) {
          if (value != currentValue) {
            partitionColTypeMap.remove(schemaPath);
          }
        } else {
          // the value of a column with primitive type can not be null,
          // so checks that there are really null value and puts it to the map
          if (localRowCount == (long) statistics.getStatistic(ColumnStatisticsKind.NULLS_COUNT)) {
            partitionValueMap.put(metadata.getLocation(), schemaPath, BaseParquetMetadataProvider.NULL_VALUE);
          } else {
            partitionValueMap.put(metadata.getLocation(), schemaPath, currentValue);
          }
        }
      } else {
        partitionColTypeMap.remove(schemaPath);
      }
    }
    this.rowCount += localRowCount;
    first = false;
  }
}