當前位置: 首頁>>代碼示例>>Java>>正文


Java NavigableMap.entrySet方法代碼示例

本文整理匯總了Java中java.util.NavigableMap.entrySet方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigableMap.entrySet方法的具體用法?Java NavigableMap.entrySet怎麽用?Java NavigableMap.entrySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.NavigableMap的用法示例。


在下文中一共展示了NavigableMap.entrySet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleQueryResult

import java.util.NavigableMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<Map<String, String>> handleQueryResult(Object result, DataStoreMsg msg,
        DataStoreConnection connection) {

    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    Map<String, String> map = null;
    for (NavigableMap<byte[], byte[]> entrys : (List<NavigableMap<byte[], byte[]>>) result) {
        map = new HashMap<String, String>();
        for (Entry<byte[], byte[]> entry : entrys.entrySet()) {
            map.put(new String(entry.getKey()), new String(entry.getValue()));
        }
        list.add(map);
    }
    return list;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:17,代碼來源:LogDataAdapter.java

示例2: testEntrySet

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    NavigableMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:TreeSubMapTest.java

示例3: testDescendingEntrySet

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * entrySet contains all pairs
 */
public void testDescendingEntrySet() {
    NavigableMap map = dmap5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(m1) && e.getValue().equals("A")) ||
                   (e.getKey().equals(m2) && e.getValue().equals("B")) ||
                   (e.getKey().equals(m3) && e.getValue().equals("C")) ||
                   (e.getKey().equals(m4) && e.getValue().equals("D")) ||
                   (e.getKey().equals(m5) && e.getValue().equals("E")));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:TreeSubMapTest.java

示例4: mapRow

import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
public TraceAnnotationDto mapRow(Result res, int rowNum) throws Exception {
    String rowKey = new String(res.getRow());
    NavigableMap<byte[], byte[]> familyMap = res.getFamilyMap(TABLE_ANNOTATION_COLUMN_FAMILY.getBytes());


    String[] ss = rowKey.split("_");
    String iface = ss[0];
    String method = ss[1];
    String type = ss[2];
    long timestamp = Long.parseLong(ss[3]);

    String traceId = "", value = "";
    for (Map.Entry<byte[], byte[]> entry : familyMap.entrySet()) {
        traceId = new String(entry.getKey());
        value = new String(entry.getValue());
    }

    TraceAnnotationDto tad = new TraceAnnotationDto();
    tad.setRowKey(rowKey).setIface(iface).setMethod(method).setType(type).setTimestamp(timestamp);
    tad.setTraceId(traceId).setValue(value);
    return tad;
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:24,代碼來源:TraceAnnotationDto.java

示例5: mapRow

import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
public TraceDto mapRow(Result res, int rowNum) throws Exception {

    String traceId = new String(res.getRow());
    NavigableMap<byte[], byte[]> data = res.getFamilyMap(Constants.TABLE_TRACE_COLUMN_FAMILY.getBytes());

    String spanId;
    JSONObject spanDetail;
    TreeMap<String, JSONObject> map = new TreeMap<>();
    Set<Map.Entry<byte[], byte[]>> spanEntrySet = data.entrySet();
    for (Map.Entry<byte[], byte[]> entry : spanEntrySet) {
        spanId = new String(entry.getKey());
        spanDetail = JSON.parseObject(new String(entry.getValue()));
        map.put(spanId, spanDetail);
    }
    Set<Map.Entry<String, JSONObject>> spans = map.entrySet();


    TraceDto rtn = new TraceDto();
    rtn.setTraceId(traceId).setSpans(spans);
    return rtn;
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:23,代碼來源:TraceDto.java

示例6: getFamilyMap

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * Map of qualifiers to values.
 * <p>
 * Returns a Map of the form: <code>Map&lt;qualifier,value&gt;</code>
 * @param family column family to get
 * @return map of qualifiers to values
 */
public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family) {
  if(this.familyMap == null) {
    getMap();
  }
  if(isEmpty()) {
    return null;
  }
  NavigableMap<byte[], byte[]> returnMap =
    new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
  NavigableMap<byte[], NavigableMap<Long, byte[]>> qualifierMap =
    familyMap.get(family);
  if(qualifierMap == null) {
    return returnMap;
  }
  for(Map.Entry<byte[], NavigableMap<Long, byte[]>> entry :
    qualifierMap.entrySet()) {
    byte [] value =
      entry.getValue().get(entry.getValue().firstKey());
    returnMap.put(entry.getKey(), value);
  }
  return returnMap;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:30,代碼來源:Result.java

示例7: asMap

import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
public NavigableMap<String, T> asMap() {
    NavigableMap<String, ? super T> delegateMap = delegate.asMap();

    NavigableMap<String, T> filtered = new TreeMap<String, T>();
    for (Map.Entry<String, ? super T> entry : delegateMap.entrySet()) {
        T obj = filter.filter(entry.getValue());
        if (obj != null) {
            filtered.put(entry.getKey(), obj);
        }
    }

    return filtered;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:15,代碼來源:DefaultNamedDomainObjectCollection.java

示例8: scan

import java.util.NavigableMap; //導入方法依賴的package包/類
public void scan(Connection connection, TableName tableName) throws IOException {
    Table table = null;
    try {
        table = connection.getTable(tableName);
        ResultScanner rs = null;
        try {
            //Scan scan = new Scan(Bytes.toBytes("u120000"), Bytes.toBytes("u200000"));
            rs = table.getScanner(new Scan());
            for(Result r:rs){
                NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> navigableMap = r.getMap();
                for(Map.Entry<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> entry : navigableMap.entrySet()){
                    logger.info("row:{} key:{}", Bytes.toString(r.getRow()), Bytes.toString(entry.getKey()));
                    NavigableMap<byte[], NavigableMap<Long, byte[]>> map =entry.getValue();
                    for(Map.Entry<byte[], NavigableMap<Long, byte[]>> en:map.entrySet()){
                        System.out.print(Bytes.toString(en.getKey())+"##");
                        NavigableMap<Long, byte[]> ma = en.getValue();
                        for(Map.Entry<Long, byte[]>e: ma.entrySet()){
                            System.out.print(e.getKey()+"###");
                            System.out.println(Bytes.toString(e.getValue()));
                        }
                    }
                }
            }
        } finally {
            if(rs!=null) {
                rs.close();
            }
        }
    } finally {
        if(table!=null) {
            table.close();
        }
    }
}
 
開發者ID:TFdream,項目名稱:hbase-tutorials,代碼行數:35,代碼來源:HBaseCrudDemo.java

示例9: onAfterCoalesce

import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void onAfterCoalesce(Iterable<Increment> increments) {
  for (Increment inc : increments) {
    byte[] row = inc.getRow();
    Map<byte[], NavigableMap<byte[], Long>> families = null;
    try {
      families = (Map<byte[], NavigableMap<byte[], Long>>)
          refGetFamilyMap.invoke(inc);
    } catch (Exception e) {
      Throwables.propagate(e);
    }
    for (byte[] family : families.keySet()) {
      NavigableMap<byte[], Long> qualifiers = families.get(family);
      for (Map.Entry<byte[], Long> entry : qualifiers.entrySet()) {
        byte[] qualifier = entry.getKey();
        Long count = entry.getValue();
        StringBuilder b = new StringBuilder(20);
        b.append(new String(row, Charsets.UTF_8));
        b.append(':');
        b.append(new String(qualifier, Charsets.UTF_8));
        String key = b.toString();
        Assert.assertEquals("Expected counts don't match observed for " + key,
            expectedCounts.get(key), count);
      }
    }
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:29,代碼來源:TestHBaseSink.java

示例10: init

import java.util.NavigableMap; //導入方法依賴的package包/類
private void init() {
  logger.debug("Getting region locations");
  try {
    HTable table = new HTable(storagePluginConfig.getHBaseConf(), hbaseScanSpec.getTableName());
    this.hTableDesc = table.getTableDescriptor();
    NavigableMap<HRegionInfo, ServerName> regionsMap = table.getRegionLocations();
    statsCalculator = new TableStatsCalculator(table, hbaseScanSpec, storagePlugin.getContext().getConfig(), storagePluginConfig);

    boolean foundStartRegion = false;
    regionsToScan = new TreeMap<HRegionInfo, ServerName>();
    for (Entry<HRegionInfo, ServerName> mapEntry : regionsMap.entrySet()) {
      HRegionInfo regionInfo = mapEntry.getKey();
      if (!foundStartRegion && hbaseScanSpec.getStartRow() != null && hbaseScanSpec.getStartRow().length != 0 && !regionInfo.containsRow(hbaseScanSpec.getStartRow())) {
        continue;
      }
      foundStartRegion = true;
      regionsToScan.put(regionInfo, mapEntry.getValue());
      scanSizeInBytes += statsCalculator.getRegionSizeInBytes(regionInfo.getRegionName());
      if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) {
        break;
      }
    }

    table.close();
  } catch (IOException e) {
    throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e);
  }
  verifyColumns();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:30,代碼來源:HBaseGroupScan.java

示例11: determineFirstPlayer

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * Determines the player who should be play first, according to the Scrabble rules
 *
 * @param bag     The bag of the Scrabble game
 * @param players The players of the Scrabble game
 *
 * @return the player who should play first
 * @throws EmptyBagException if the bag is empty
 */
protected PlayerInterface determineFirstPlayer(BagInterface bag, List<PlayerInterface> players) throws EmptyBagException {
    NavigableMap<LetterInterface, PlayerInterface> playersDrawing = new TreeMap<>((o1, o2) -> o1.toString().compareTo(o2.toString()));

    for (PlayerInterface player : players) {
        playersDrawing.put(bag.drawLetter(), player);
    }

    for (NavigableMap.Entry<LetterInterface, PlayerInterface> playerDrawing : playersDrawing.entrySet()) {
        bag.putBackLetter(playerDrawing.getKey());
    }

    return playersDrawing.firstEntry().getValue();
}
 
開發者ID:Chrisp1tv,項目名稱:ScrabbleGame,代碼行數:23,代碼來源:Scrabble.java

示例12: testClientPoolRoundRobin

import java.util.NavigableMap; //導入方法依賴的package包/類
@Test
public void testClientPoolRoundRobin() throws IOException {
  final TableName tableName = TableName.valueOf("testClientPoolRoundRobin");

  int poolSize = 3;
  int numVersions = poolSize * 2;
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_CLIENT_IPC_POOL_TYPE, "round-robin");
  conf.setInt(HConstants.HBASE_CLIENT_IPC_POOL_SIZE, poolSize);

  Table table = TEST_UTIL.createTable(tableName, new byte[][] { FAMILY }, conf, Integer.MAX_VALUE);

  final long ts = EnvironmentEdgeManager.currentTime();
  Get get = new Get(ROW);
  get.addColumn(FAMILY, QUALIFIER);
  get.setMaxVersions();

  for (int versions = 1; versions <= numVersions; versions++) {
    Put put = new Put(ROW);
    put.add(FAMILY, QUALIFIER, ts + versions, VALUE);
    table.put(put);

    Result result = table.get(get);
    NavigableMap<Long, byte[]> navigableMap = result.getMap().get(FAMILY)
        .get(QUALIFIER);

    assertEquals("The number of versions of '" + FAMILY + ":" + QUALIFIER
        + " did not match " + versions, versions, navigableMap.size());
    for (Map.Entry<Long, byte[]> entry : navigableMap.entrySet()) {
      assertTrue("The value at time " + entry.getKey()
          + " did not match what was put",
          Bytes.equals(VALUE, entry.getValue()));
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:36,代碼來源:TestFromClientSide.java

示例13: assertAllOnLine

import java.util.NavigableMap; //導入方法依賴的package包/類
private void assertAllOnLine(final HTable t) throws IOException {
  NavigableMap<HRegionInfo, ServerName> regions = t.getRegionLocations();
  for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
    byte [] startkey = e.getKey().getStartKey();
    Scan s = new Scan(startkey);
    ResultScanner scanner = t.getScanner(s);
    Result r = scanner.next();
    org.junit.Assert.assertTrue(r != null && r.size() > 0);
    scanner.close();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TestLoadAndSwitchEncodeOnDisk.java

示例14: transformResultAndAddToList

import java.util.NavigableMap; //導入方法依賴的package包/類
private void transformResultAndAddToList(Result result, List<MDPoint> found) {
  NavigableMap<byte[], byte[]> map = result.getFamilyMap(MDHBaseAdmin.SECONDARY_FAMILY);
  if (map == null) return;
  for (Entry<byte[], byte[]> entry : map.entrySet()) {
    MDPoint p = toPoint(entry.getKey(), entry.getValue());
    found.add(p);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:MDBucket.java

示例15: getAllRegionLocations

import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
public List<HRegionLocation> getAllRegionLocations() throws IOException {
  NavigableMap<HRegionInfo, ServerName> locations =
      MetaScanner.allTableRegions(this.connection, getName());
  ArrayList<HRegionLocation> regions = new ArrayList<>(locations.size());
  for (Entry<HRegionInfo, ServerName> entry : locations.entrySet()) {
    regions.add(new HRegionLocation(entry.getKey(), entry.getValue()));
  }
  return regions;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:11,代碼來源:HRegionLocator.java


注:本文中的java.util.NavigableMap.entrySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。