当前位置: 首页>>代码示例>>Java>>正文


Java NavigableMap.isEmpty方法代码示例

本文整理汇总了Java中java.util.NavigableMap.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableMap.isEmpty方法的具体用法?Java NavigableMap.isEmpty怎么用?Java NavigableMap.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.NavigableMap的用法示例。


在下文中一共展示了NavigableMap.isEmpty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public Entry filter(Entry entry) {
  NavigableMap<byte[], Integer> scopes = entry.getKey().getScopes();
  if (scopes == null || scopes.isEmpty()) {
    return null;
  }
  ArrayList<Cell> cells = entry.getEdit().getCells();
  int size = cells.size();
  for (int i = size - 1; i >= 0; i--) {
    Cell cell = cells.get(i);
    // The scope will be null or empty if
    // there's nothing to replicate in that WALEdit
    if (!scopes.containsKey(cell.getFamily())
        || scopes.get(cell.getFamily()) == HConstants.REPLICATION_SCOPE_LOCAL) {
      cells.remove(i);
    }
  }
  if (cells.size() < size / 2) {
    cells.trimToSize();
  }
  return entry;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ScopeWALEntryFilter.java

示例2: OverlaidGaugeCsvAnalyzer

import java.util.NavigableMap; //导入方法依赖的package包/类
public OverlaidGaugeCsvAnalyzer(NavigableMap<String, GaugeCsvAnalyzer> labeled_analyzers) {

        if (labeled_analyzers.isEmpty()) {
            throw new IllegalArgumentException("at least one analyser must be given");
        }
        this.labeled_analyzers = labeled_analyzers;
        final GaugeCsvAnalyzer first_analyzer = labeled_analyzers.firstEntry().getValue();
        chart_title = first_analyzer.getChartTitle();
        y_axis_label = first_analyzer.getYAxisLabel();
        name = first_analyzer.getName();
    }
 
开发者ID:stacs-srg,项目名称:shabdiz,代码行数:12,代码来源:OverlaidGaugeCsvAnalyzer.java

示例3: getUidNext

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Returns UIDNEXT value of the folder.
 * 
 * @return UIDNEXT value.
 */
@Override
public long getUidNext()
{
    NavigableMap<Long, FileInfo> search = getFolderStatus().search; 
    return search.isEmpty() ? 1 : search.lastKey() + 1;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:AlfrescoImapFolder.java

示例4: CyclicIteration

import java.util.NavigableMap; //导入方法依赖的package包/类
/** Construct an {@link Iterable} object,
 * so that an {@link Iterator} can be created  
 * for iterating the given {@link NavigableMap}.
 * The iteration begins from the starting key exclusively.
 */
public CyclicIteration(NavigableMap<K, V> navigablemap, K startingkey) {
  if (navigablemap == null || navigablemap.isEmpty()) {
    this.navigablemap = null;
    this.tailmap = null;
  }
  else {
    this.navigablemap = navigablemap;
    this.tailmap = navigablemap.tailMap(startingkey, false); 
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:CyclicIteration.java

示例5: addInterval

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Add a resource for the specified interval
 * 
 * @param reservationInterval the interval for which the resource is to be
 *          added
 * @param capacity the resource to be added
 * @return true if addition is successful, false otherwise
 */
public boolean addInterval(ReservationInterval reservationInterval,
    ReservationRequest capacity) {
  Resource totCap =
      Resources.multiply(capacity.getCapability(),
          (float) capacity.getNumContainers());
  if (totCap.equals(ZERO_RESOURCE)) {
    return true;
  }
  writeLock.lock();
  try {
    long startKey = reservationInterval.getStartTime();
    long endKey = reservationInterval.getEndTime();
    NavigableMap<Long, Resource> ticks =
        cumulativeCapacity.headMap(endKey, false);
    if (ticks != null && !ticks.isEmpty()) {
      Resource updatedCapacity = Resource.newInstance(0, 0, 0);
      Entry<Long, Resource> lowEntry = ticks.floorEntry(startKey);
      if (lowEntry == null) {
        // This is the earliest starting interval
        cumulativeCapacity.put(startKey, totCap);
      } else {
        updatedCapacity = Resources.add(lowEntry.getValue(), totCap);
        // Add a new tick only if the updated value is different
        // from the previous tick
        if ((startKey == lowEntry.getKey())
            && (isSameAsPrevious(lowEntry.getKey(), updatedCapacity))) {
          cumulativeCapacity.remove(lowEntry.getKey());
        } else {
          cumulativeCapacity.put(startKey, updatedCapacity);
        }
      }
      // Increase all the capacities of overlapping intervals
      Set<Entry<Long, Resource>> overlapSet =
          ticks.tailMap(startKey, false).entrySet();
      for (Entry<Long, Resource> entry : overlapSet) {
        updatedCapacity = Resources.add(entry.getValue(), totCap);
        entry.setValue(updatedCapacity);
      }
    } else {
      // This is the first interval to be added
      cumulativeCapacity.put(startKey, totCap);
    }
    Resource nextTick = cumulativeCapacity.get(endKey);
    if (nextTick != null) {
      // If there is overlap, remove the duplicate entry
      if (isSameAsPrevious(endKey, nextTick)) {
        cumulativeCapacity.remove(endKey);
      }
    } else {
      // Decrease capacity as this is end of the interval
      cumulativeCapacity.put(endKey, Resources.subtract(cumulativeCapacity
          .floorEntry(endKey).getValue(), totCap));
    }
    return true;
  } finally {
    writeLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:67,代码来源:RLESparseResourceAllocation.java

示例6: buildReplicateWALEntryRequest

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Create a new ReplicateWALEntryRequest from a list of HLog entries
 *
 * @param entries the HLog entries to be replicated
 * @param encodedRegionName alternative region name to use if not null
 * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values
 * found.
 */
public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>
    buildReplicateWALEntryRequest(final Entry[] entries, byte[] encodedRegionName) {
  // Accumulate all the KVs seen in here.
  List<List<? extends Cell>> allCells = new ArrayList<List<? extends Cell>>(entries.length);
  int size = 0;
  WALProtos.FamilyScope.Builder scopeBuilder = WALProtos.FamilyScope.newBuilder();
  AdminProtos.WALEntry.Builder entryBuilder = AdminProtos.WALEntry.newBuilder();
  AdminProtos.ReplicateWALEntryRequest.Builder builder =
    AdminProtos.ReplicateWALEntryRequest.newBuilder();
  HBaseProtos.UUID.Builder uuidBuilder = HBaseProtos.UUID.newBuilder();
  for (Entry entry: entries) {
    entryBuilder.clear();
    // TODO: this duplicates a lot in WALKey#getBuilder
    WALProtos.WALKey.Builder keyBuilder = entryBuilder.getKeyBuilder();
    WALKey key = entry.getKey();
    keyBuilder.setEncodedRegionName(
      ByteStringer.wrap(encodedRegionName == null
          ? key.getEncodedRegionName()
          : encodedRegionName));
    keyBuilder.setTableName(ByteStringer.wrap(key.getTablename().getName()));
    keyBuilder.setLogSequenceNumber(key.getLogSeqNum());
    keyBuilder.setWriteTime(key.getWriteTime());
    if (key.getNonce() != HConstants.NO_NONCE) {
      keyBuilder.setNonce(key.getNonce());
    }
    if (key.getNonceGroup() != HConstants.NO_NONCE) {
      keyBuilder.setNonceGroup(key.getNonceGroup());
    }
    for(UUID clusterId : key.getClusterIds()) {
      uuidBuilder.setLeastSigBits(clusterId.getLeastSignificantBits());
      uuidBuilder.setMostSigBits(clusterId.getMostSignificantBits());
      keyBuilder.addClusterIds(uuidBuilder.build());
    }
    if(key.getOrigLogSeqNum() > 0) {
      keyBuilder.setOrigSequenceNumber(key.getOrigLogSeqNum());
    }
    WALEdit edit = entry.getEdit();
    NavigableMap<byte[], Integer> scopes = key.getScopes();
    if (scopes != null && !scopes.isEmpty()) {
      for (Map.Entry<byte[], Integer> scope: scopes.entrySet()) {
        scopeBuilder.setFamily(ByteStringer.wrap(scope.getKey()));
        WALProtos.ScopeType scopeType =
            WALProtos.ScopeType.valueOf(scope.getValue().intValue());
        scopeBuilder.setScopeType(scopeType);
        keyBuilder.addScopes(scopeBuilder.build());
      }
    }
    List<Cell> cells = edit.getCells();
    // Add up the size.  It is used later serializing out the cells.
    for (Cell cell: cells) {
      size += CellUtil.estimatedSerializedSizeOf(cell);
    }
    // Collect up the cells
    allCells.add(cells);
    // Write out how many cells associated with this entry.
    entryBuilder.setAssociatedCellCount(cells.size());
    builder.addEntry(entryBuilder.build());
  }
  return new Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>(builder.build(),
    getCellScanner(allCells, size));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:70,代码来源:ReplicationProtbufUtil.java


注:本文中的java.util.NavigableMap.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。