Search in sources :

Example 1 with MutableLong

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;
}
Also used : MutableLong(org.apache.commons.lang.mutable.MutableLong) MultiVersionConcurrencyControl(org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl) TraceScope(org.apache.htrace.TraceScope) InterruptedIOException(java.io.InterruptedIOException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) IOException(java.io.IOException)

Example 2 with MutableLong

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);
}
Also used : MutableLong(org.apache.commons.lang.mutable.MutableLong) AbstractColumnStatisticsCollector(com.linkedin.pinot.core.segment.creator.AbstractColumnStatisticsCollector) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) HashBiMap(com.google.common.collect.HashBiMap)

Example 3 with MutableLong

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);
    }
}
Also used : VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) MutableLong(org.apache.commons.lang.mutable.MutableLong) VCFHeader(htsjdk.variant.vcf.VCFHeader)

Example 4 with MutableLong

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;
}
Also used : DataRow(org.knime.core.data.DataRow) ColumnBufferedDataTableSorter(org.knime.core.data.sort.ColumnBufferedDataTableSorter) MutableLong(org.apache.commons.lang.mutable.MutableLong) ExecutionContext(org.knime.core.node.ExecutionContext) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SortingConsumer(org.knime.core.data.sort.SortingConsumer)

Example 5 with MutableLong

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();
}
Also used : MutableLong(org.apache.commons.lang.mutable.MutableLong)

Aggregations

MutableLong (org.apache.commons.lang.mutable.MutableLong)37 IOException (java.io.IOException)11 HashMap (java.util.HashMap)8 Map (java.util.Map)7 ArrayList (java.util.ArrayList)5 Path (org.apache.hadoop.fs.Path)5 ObjectMapperString (com.datatorrent.common.util.ObjectMapperString)3 DefaultPartition (com.datatorrent.api.DefaultPartition)2 IncompatibleVersionException (com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException)2 TupleRecorder (com.datatorrent.stram.debug.TupleRecorder)2 Stopwatch (com.google.common.base.Stopwatch)2 VCFHeader (htsjdk.variant.vcf.VCFHeader)2 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)2 BufferedReader (java.io.BufferedReader)2 URI (java.net.URI)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 BasicCounters (org.apache.apex.malhar.lib.counters.BasicCounters)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 JSONObject (org.codehaus.jettison.json.JSONObject)2