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


Java KeyValue.getKey方法代码示例

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


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

示例1: next

import org.mellowtech.core.collections.KeyValue; //导入方法依赖的package包/类
@Override
public KeyValue<A, BlobPointer> next() {
  KeyValue <A,B> n = iter.next();
  if(n == null) return null;
  int size = valueCodec.byteSize(n.getValue());
  try{
    long fpos = fc.size();
    BlobPointer bp = new BlobPointer(fpos, size);
    ByteBuffer bb = valueCodec.to(n.getValue()); bb.flip();
    fc.write(bb, fpos);
    return new KeyValue <>(n.getKey(),bp);
  } catch(IOException e){
    throw new Error("could not store");
  }
  
}
 
开发者ID:msvens,项目名称:mellowtech-core,代码行数:17,代码来源:BlobMapCreateIterator.java

示例2: rebuildIndex

import org.mellowtech.core.collections.KeyValue; //导入方法依赖的package包/类
@Override
public void rebuildIndex() throws IOException, UnsupportedOperationException {
  //just return if there are no value blocks
  if (values.size() == 0) {
    size = 0;
    rightPtr = newBlock(mapped).bNo;
    idx.clear();
    return;
  }
  idx.clear();
  rightPtr = 0;

  BBuffer<KeyValue<A,B>> tmp;
  @SuppressWarnings("unchecked")
  HybridTree.FirstLastKey<A>[] blocks = new HybridTree.FirstLastKey[values.size()];
  Iterator<Record> iter = values.iterator();
  int i = 0;
  int s = 0;
  while (iter.hasNext()) {
    Record r = iter.next();
    tmp = new BBuffer<>(ByteBuffer.wrap(r.data), kvCodec);
    if(tmp.getNumberOfElements() == 0)
      break;
    KeyValue<A,B> first = tmp.getFirst();
    KeyValue<A,B> last = tmp.getLast();
    HybridTree.FirstLastKey<A> sl =
        new HybridTree.FirstLastKey<>(first.getKey(), last.getKey(), r.record);
    blocks[i] = sl;
    i++;
    s += tmp.getNumberOfElements();
  }
  if(blocks[0] == null)
    return;
  //Sort the blocks and set all initial values
  Arrays.sort(blocks);
  size = 0;
  rightPtr = blocks[0].bNo;
  size = s;

  for (i = 0; i < blocks.length - 1; i++) {
    HybridTree.FirstLastKey<A> left = blocks[i];
    HybridTree.FirstLastKey<A> right = blocks[i + 1];

    A sep = generateSeparator(left.last, right.first);
    addPointer(sep, right.bNo);
  }
}
 
开发者ID:msvens,项目名称:mellowtech-core,代码行数:48,代码来源:HybridTree.java

示例3: rebuildIndex

import org.mellowtech.core.collections.KeyValue; //导入方法依赖的package包/类
@Override
public void rebuildIndex() throws IOException {
  //just return if there are no value blocks
  if (valueFile.size() == 0) {
    truncate();
    return;
  }

  BBuffer<KeyValue<A,B>> tmp;
  SmallLarge[] blocks = new SmallLarge[valueFile.size()];
  Iterator<Record> iter = valueFile.iterator();
  int i = 0;
  int s = 0;
  while (iter.hasNext()) {
    Record r = iter.next();
    tmp = new BBuffer<>(ByteBuffer.wrap(r.data), kvCodec);
    KeyValue<A,B> first = tmp.getFirst();
    KeyValue<A,B> last = tmp.getLast();
    SmallLarge sl = new SmallLarge<>(first.getKey(), last.getKey(), r.record);
    blocks[i] = sl;
    i++;
    s += tmp.getNumberOfElements();
  }

  //Sort the blocks and set all initial values
  Arrays.sort(blocks);
  leafLevel = -1;
  size = 0;
  rootPage = blocks[0].bNo;
  size = s;
  idxFile.clear();
  IdxBlock<A>[] levels = (IdxBlock<A>[]) new IdxBlock<?>[20];
  for (i = 0; i < blocks.length - 1; i++) {
    SmallLarge<A> left = blocks[i];
    SmallLarge<A> right = blocks[i + 1];
    BTreeKey<A> sep = generateSeparator(left.large, right.small);
    sep.leftNode = left.bNo;
    insertSeparator(sep, levels, 0, right.bNo);
  }
  if (levels[0] != null)
    writeIndexBlocks(levels);
}
 
开发者ID:msvens,项目名称:mellowtech-core,代码行数:43,代码来源:BTreeImp.java


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