下面列出了org.apache.commons.lang3.mutable.MutableLong#setValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
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);
}
}
}
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();
}
}
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;
}
}