本文整理汇总了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");
}
}
示例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);
}
}
示例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);
}