本文整理匯總了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);
}