use of org.apache.commons.lang.mutable.MutableLong in project hbase by apache.
the class AbstractFSWAL method stampSequenceIdAndPublishToRingBuffer.
protected long stampSequenceIdAndPublishToRingBuffer(HRegionInfo hri, WALKey key, WALEdit edits, boolean inMemstore, RingBuffer<RingBufferTruck> ringBuffer) throws IOException {
if (this.closed) {
throw new IOException("Cannot append; log is closed, regionName = " + hri.getRegionNameAsString());
}
TraceScope scope = Trace.startSpan(implClassName + ".append");
MutableLong txidHolder = new MutableLong();
MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(() -> {
txidHolder.setValue(ringBuffer.next());
});
long txid = txidHolder.longValue();
try {
FSWALEntry entry = new FSWALEntry(txid, key, edits, hri, inMemstore);
entry.stampRegionSequenceId(we);
ringBuffer.get(txid).load(entry, scope.detach());
} finally {
ringBuffer.publish(txid);
}
return txid;
}
use of org.apache.commons.lang.mutable.MutableLong in project pinot by linkedin.
the class SegmentIndexCreationDriverImpl method handlePostCreation.
private void handlePostCreation() throws Exception {
final String timeColumn = config.getTimeColumnName();
segmentName = config.getSegmentNameGenerator().getSegmentName(segmentStats.getColumnProfileFor(timeColumn));
// Write the index files to disk
indexCreator.setSegmentName(segmentName);
indexCreator.seal();
LOGGER.info("Finished segment seal!");
// Delete the directory named after the segment name, if it exists
final File outputDir = new File(config.getOutDir());
final File segmentOutputDir = new File(outputDir, segmentName);
if (segmentOutputDir.exists()) {
FileUtils.deleteDirectory(segmentOutputDir);
}
// Move the temporary directory into its final location
FileUtils.moveDirectory(tempIndexDir, segmentOutputDir);
// Delete the temporary directory
FileUtils.deleteQuietly(tempIndexDir);
// Compute CRC
final long crc = CrcUtils.forAllFilesInFolder(segmentOutputDir).computeCrc();
// Persist creation metadata to disk
persistCreationMeta(segmentOutputDir, crc);
Map<String, MutableLong> nullCountMap = recordReader.getNullCountMap();
if (nullCountMap != null) {
for (Map.Entry<String, MutableLong> entry : nullCountMap.entrySet()) {
AbstractColumnStatisticsCollector columnStatisticsCollector = segmentStats.getColumnProfileFor(entry.getKey());
columnStatisticsCollector.setNumInputNullValues(entry.getValue().intValue());
}
}
convertFormatIfNeeded(segmentOutputDir);
LOGGER.info("Driver, record read time : {}", totalRecordReadTime);
LOGGER.info("Driver, stats collector time : {}", totalStatsCollectorTime);
LOGGER.info("Driver, indexing time : {}", totalIndexTime);
}
use of org.apache.commons.lang.mutable.MutableLong in project gatk-protected by broadinstitute.
the class Concordance method onTraversalStart.
@Override
public void onTraversalStart() {
Set<VCFHeaderLine> defaultToolHeaderLines = getDefaultToolVCFHeaderLines();
for (final ConcordanceState state : ConcordanceState.values()) {
snpCounts.put(state, new MutableLong(0));
indelCounts.put(state, new MutableLong(0));
}
if (truePositivesAndFalseNegativesVcf != null) {
truePositivesAndFalseNegativesVcfWriter = createVCFWriter(truePositivesAndFalseNegativesVcf);
final VCFHeader truthHeader = getTruthHeader();
truthHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
defaultToolHeaderLines.forEach(truthHeader::addMetaDataLine);
truePositivesAndFalseNegativesVcfWriter.writeHeader(truthHeader);
}
if (truePositivesAndFalsePositivesVcf != null) {
truePositivesAndFalsePositivesVcfWriter = createVCFWriter(truePositivesAndFalsePositivesVcf);
final VCFHeader evalHeader = getEvalHeader();
defaultToolHeaderLines.forEach(evalHeader::addMetaDataLine);
evalHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
truePositivesAndFalsePositivesVcfWriter.writeHeader(evalHeader);
}
if (filteredTrueNegativesAndFalseNegativesVcf != null) {
filteredTrueNegativesAndFalseNegativesVcfWriter = createVCFWriter(filteredTrueNegativesAndFalseNegativesVcf);
final VCFHeader evalHeader = getEvalHeader();
evalHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
defaultToolHeaderLines.forEach(evalHeader::addMetaDataLine);
filteredTrueNegativesAndFalseNegativesVcfWriter.writeHeader(evalHeader);
}
}
use of org.apache.commons.lang.mutable.MutableLong in project knime-core by knime.
the class StatisticCalculator method evaluate.
/**
* @param dataTable actual data table to compute the
* @param exec execution context
* @return a potential warnings message or <code>null</code>
* @throws CanceledExecutionException if the user cancels the execution
*/
public String evaluate(final BufferedDataTable dataTable, final ExecutionContext exec) throws CanceledExecutionException {
for (Statistic stat : m_statistics) {
stat.beforeEvaluation(dataTable.size());
}
if (!m_colToSortOn.isEmpty()) {
ColumnBufferedDataTableSorter columnDataTableSorter;
try {
columnDataTableSorter = new ColumnBufferedDataTableSorter(dataTable.getDataTableSpec(), dataTable.size(), m_colToSortOn.toArray(new String[m_colToSortOn.size()]));
} catch (InvalidSettingsException e) {
throw new RuntimeException("Error on initialize the sorting", e);
}
exec.setMessage("Sorting Data.");
final Iterator<DataRow> it = dataTable.iterator();
final MutableLong count = new MutableLong();
final ExecutionContext evalProgress = exec.createSubExecutionContext(0.3);
final int[] specMapping = createSpecMapping(dataTable.getSpec(), m_colToSortOn.toArray(new String[m_colToSortOn.size()]));
columnDataTableSorter.sort(dataTable, exec.createSubExecutionContext(0.7), new SortingConsumer() {
@Override
public void consume(final DataRow defaultRow) {
DataRow next = it.next();
evalProgress.setProgress(count.longValue() / (double) dataTable.size(), "Processing Row: " + next.getKey());
count.increment();
for (Statistic stat : m_statistics) {
stat.consumeRow(new OverwritingRow(next, defaultRow, specMapping));
}
}
});
} else {
exec.setMessage("Evaluating statistics.");
long count = 0;
for (DataRow currRow : dataTable) {
exec.setProgress(count++ / (double) dataTable.size(), "Processing Row: " + currRow.getKey());
for (Statistic stat : m_statistics) {
stat.consumeRow(currRow);
}
}
}
StringBuilder warnings = new StringBuilder();
for (Statistic stat : m_statistics) {
String warningString = stat.finish();
if (warningString != null) {
warnings.append(warningString);
warnings.append("\n");
}
}
return warnings.length() > 0 ? warnings.toString() : null;
}
use of org.apache.commons.lang.mutable.MutableLong in project bookkeeper by apache.
the class MVCCStoreImpl method deleteUsingIter.
long deleteUsingIter(WriteBatch batch, K key, byte[] rawKey, @Nullable byte[] rawEndKey, List<byte[]> resultKeys, List<MVCCRecord> resultValues, boolean countOnly) {
MutableLong numKvs = new MutableLong(0L);
if (null == rawEndKey) {
MVCCRecord record = getKeyRecord(key, rawKey);
if (null != record) {
if (!countOnly) {
resultKeys.add(rawKey);
resultValues.add(record);
} else {
record.recycle();
}
numKvs.add(1L);
batch.remove(rawKey);
}
} else {
Pair<byte[], byte[]> realRange = getRealRange(rawKey, rawEndKey);
rawKey = realRange.getLeft();
rawEndKey = realRange.getRight();
getKeyRecords(rawKey, rawEndKey, resultKeys, resultValues, numKvs, null, -1, countOnly);
deleteBlind(batch, rawKey, rawEndKey);
}
return numKvs.longValue();
}
Aggregations