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


Java LeveldbIterator.seek方法代码示例

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


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

示例1: loadTokenMasterKeys

import org.apache.hadoop.yarn.server.utils.LeveldbIterator; //导入方法依赖的package包/类
private int loadTokenMasterKeys(TimelineServiceState state)
    throws IOException {
  byte[] base = KeyBuilder.newInstance().add(TOKEN_MASTER_KEY_ENTRY_PREFIX)
      .getBytesForLookup();
  int numKeys = 0;
  LeveldbIterator iterator = null;
  try {
    for (iterator = new LeveldbIterator(db), iterator.seek(base);
        iterator.hasNext(); iterator.next()) {
      byte[] k = iterator.peekNext().getKey();
      if (!prefixMatches(base, base.length, k)) {
        break;
      }
      byte[] v = iterator.peekNext().getValue();
      loadTokenMasterKeyData(state, v);
      ++numKeys;
    }
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
  return numKeys;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:LeveldbTimelineStateStore.java

示例2: loadTokens

import org.apache.hadoop.yarn.server.utils.LeveldbIterator; //导入方法依赖的package包/类
private int loadTokens(TimelineServiceState state) throws IOException {
  byte[] base = KeyBuilder.newInstance().add(TOKEN_ENTRY_PREFIX)
      .getBytesForLookup();
  int numTokens = 0;
  LeveldbIterator iterator = null;
  try {
    for (iterator = new LeveldbIterator(db), iterator.seek(base);
        iterator.hasNext(); iterator.next()) {
      byte[] k = iterator.peekNext().getKey();
      if (!prefixMatches(base, base.length, k)) {
        break;
      }
      byte[] v = iterator.peekNext().getValue();
      loadTokenData(state, v);
      ++numTokens;
    }
  } catch (DBException e) {
    throw new IOException(e);
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
  return numTokens;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:LeveldbTimelineStateStore.java

示例3: getEntityTypes

import org.apache.hadoop.yarn.server.utils.LeveldbIterator; //导入方法依赖的package包/类
@VisibleForTesting
List<String> getEntityTypes() throws IOException {
  LeveldbIterator iterator = null;
  try {
    iterator = getDbIterator(false);
    List<String> entityTypes = new ArrayList<String>();
    iterator.seek(ENTITY_ENTRY_PREFIX);
    while (iterator.hasNext()) {
      byte[] key = iterator.peekNext().getKey();
      if (key[0] != ENTITY_ENTRY_PREFIX[0]) {
        break;
      }
      KeyParser kp = new KeyParser(key,
          ENTITY_ENTRY_PREFIX.length);
      String entityType = kp.getNextString();
      entityTypes.add(entityType);
      byte[] lookupKey = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX)
          .add(entityType).getBytesForLookup();
      if (lookupKey[lookupKey.length - 1] != 0x0) {
        throw new IOException("Found unexpected end byte in lookup key");
      }
      lookupKey[lookupKey.length - 1] = 0x1;
      iterator.seek(lookupKey);
    }
    return entityTypes;
  } catch(DBException e) {
    throw new IOException(e);            	
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:LeveldbTimelineStore.java

示例4: deleteKeysWithPrefix

import org.apache.hadoop.yarn.server.utils.LeveldbIterator; //导入方法依赖的package包/类
/**
 * Finds all keys in the db that have a given prefix and deletes them on
 * the given write batch.
 */
private void deleteKeysWithPrefix(WriteBatch writeBatch, byte[] prefix,
    LeveldbIterator iterator) {
  for (iterator.seek(prefix); iterator.hasNext(); iterator.next()) {
    byte[] key = iterator.peekNext().getKey();
    if (!prefixMatches(prefix, prefix.length, key)) {
      break;
    }
    writeBatch.delete(key);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:LeveldbTimelineStore.java

示例5: getDomains

import org.apache.hadoop.yarn.server.utils.LeveldbIterator; //导入方法依赖的package包/类
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  LeveldbIterator iterator = null;
  try {
    byte[] prefix = KeyBuilder.newInstance()
        .add(OWNER_LOOKUP_PREFIX).add(owner).getBytesForLookup();
    List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
    for (iterator = new LeveldbIterator(db), iterator.seek(prefix);
        iterator.hasNext();) {
      byte[] key = iterator.peekNext().getKey();
      if (!prefixMatches(prefix, prefix.length, key)) {
        break;
      }
      // Iterator to parse the rows of an individual domain
      KeyParser kp = new KeyParser(key, prefix.length);
      String domainId = kp.getNextString();
      byte[] prefixExt = KeyBuilder.newInstance().add(OWNER_LOOKUP_PREFIX)
          .add(owner).add(domainId).getBytesForLookup();
      TimelineDomain domainToReturn =
          getTimelineDomain(iterator, domainId, prefixExt);
      if (domainToReturn != null) {
        domains.add(domainToReturn);
      }
    }
    // Sort the domains to return
    Collections.sort(domains, new Comparator<TimelineDomain>() {
      @Override
      public int compare(
          TimelineDomain domain1, TimelineDomain domain2) {
         int result = domain2.getCreatedTime().compareTo(
             domain1.getCreatedTime());
         if (result == 0) {
           return domain2.getModifiedTime().compareTo(
               domain1.getModifiedTime());
         } else {
           return result;
         }
      }
    });
    TimelineDomains domainsToReturn = new TimelineDomains();
    domainsToReturn.addDomains(domains);
    return domainsToReturn;
  } catch(DBException e) {
    throw new IOException(e);            	
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:50,代码来源:LeveldbTimelineStore.java


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