當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。