Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 package org.apache.hadoop.hbase.regionserver;
 import java.util.List;
Store flusher interface. Turns a snapshot of memstore into a set of store files (usually one). Custom implementation can be provided.
 abstract class StoreFlusher {
   protected Configuration conf;
   protected Store store;
   public StoreFlusher(Configuration confStore store) {
     this. = conf;
     this. = store;

Turns a snapshot of memstore into a set of store files.

snapshot Memstore snapshot.
cacheFlushSeqNum Log cache flush sequence number.
snapshotTimeRangeTracker Time range tracker from the memstore pertaining to the snapshot.
flushedSize Out parameter for the size of the KVs flushed.
status Task that represents the flush operation and may be updated with status.
List of files written. Can be empty; must not be null.
   public abstract List<PathflushSnapshot(SortedSet<KeyValuesnapshotlong cacheFlushSeqNum,
       TimeRangeTracker snapshotTimeRangeTrackerAtomicLong flushedSizeMonitoredTask status)
       throws IOException;
   protected void finalizeWriter(StoreFile.Writer writerlong cacheFlushSeqNum,
       MonitoredTask statusthrows IOException {
     // Write out the log sequence number that corresponds to this output
     // hfile. Also write current time in metadata as minFlushTime.
     // The hfile is current up to and including cacheFlushSeqNum.
     status.setStatus("Flushing " +  + ": appending metadata");
     status.setStatus("Flushing " +  + ": closing flushed file");

Creates the scanner for flushing snapshot. Also calls coprocessors.

The scanner; null if coprocessor is canceling the flush.
   protected InternalScanner createScanner(SortedSet<KeyValuesnapshot,
       long smallestReadPointthrows IOException {
     KeyValueScanner memstoreScanner =
         new CollectionBackedScanner(snapshot.getComparator());
     InternalScanner scanner = null;
     if (.getCoprocessorHost() != null) {
       scanner = .getCoprocessorHost().preFlushScannerOpen(memstoreScanner);
     if (scanner == null) {
       Scan scan = new Scan();
       scanner = new StoreScanner(.getScanInfo(), scan,
           Collections.singletonList(memstoreScanner), .,
    assert scanner != null;
    if (.getCoprocessorHost() != null) {
      try {
        return .getCoprocessorHost().preFlush(scanner);
      } catch (IOException ioe) {
        throw ioe;
    return scanner;

Performs memstore flush, writing data from scanner into sink.

scanner Scanner to get data from.
sink Sink to write data to. Could be StoreFile.Writer.
smallestReadPoint Smallest read point used for the flush.
Bytes flushed.
  protected long performFlush(InternalScanner scanner,
      Compactor.CellSink sinklong smallestReadPointthrows IOException {
    int compactionKVMax =
    List<Cellkvs = new ArrayList<Cell>();
    boolean hasMore;
    long flushed = 0;
    do {
      hasMore =;
      if (!kvs.isEmpty()) {
        for (Cell c : kvs) {
          // If we know that this KV is going to be included always, then let us
          // set its memstoreTS to 0. This will help us save space when writing to
          // disk.
          KeyValue kv = KeyValueUtil.ensureKeyValue(c);
          if (kv.getMvccVersion() <= smallestReadPoint) {
            // let us not change the original KV. It could be in the memstore
            // changing its memstoreTS could affect other threads/scanners.
            kv = kv.shallowCopy();
          flushed += MemStore.heapSizeChange(kvtrue);
    } while (hasMore);
    return flushed;
New to GrepCode? Check out our FAQ X