001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.regionserver;
019
020import org.apache.hadoop.hbase.util.ClassSize;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * CSLMImmutableSegment is an abstract class that extends the API supported by a {@link Segment},
025 * and {@link ImmutableSegment}. This immutable segment is working with CellSet with
026 * ConcurrentSkipListMap (CSLM) delegatee.
027 */
028@InterfaceAudience.Private
029public class CSLMImmutableSegment extends ImmutableSegment {
030  public static final long DEEP_OVERHEAD_CSLM =
031    ImmutableSegment.DEEP_OVERHEAD + ClassSize.CONCURRENT_SKIPLISTMAP;
032
033  /**
034   * ------------------------------------------------------------------------ Copy C-tor to be used
035   * when new CSLMImmutableSegment is being built from a Mutable one. This C-tor should be used when
036   * active MutableSegment is pushed into the compaction pipeline and becomes an ImmutableSegment.
037   */
038  protected CSLMImmutableSegment(Segment segment, MemStoreSizing memstoreSizing) {
039    super(segment);
040    // update the segment metadata heap size
041    long indexOverhead = -MutableSegment.DEEP_OVERHEAD + DEEP_OVERHEAD_CSLM;
042    incMemStoreSize(0, indexOverhead, 0, 0); // CSLM is always on-heap
043    if (memstoreSizing != null) {
044      memstoreSizing.incMemStoreSize(0, indexOverhead, 0, 0);
045    }
046  }
047
048  @Override
049  protected long indexEntrySize() {
050    return ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY;
051  }
052
053  @Override
054  protected boolean canBeFlattened() {
055    return true;
056  }
057}