754755756757758759760761762763764
DbIterator internalIterator() { mutex.lock(); try { // merge together the memTable, immutableMemTable, and tables in version set MemTableIterator iterator = null; if (immutableMemTable != null) { iterator = immutableMemTable.iterator(); } Version current = versions.getCurrent(); return new DbIterator(memTable.iterator(), iterator, current.getLevel0Files(), current.getLevelIterators(), internalKeyComparator);
13131314131513161317131813191320132113221323
{ Slice record = Slices.allocate(SIZE_OF_LONG + SIZE_OF_INT + updates.getApproximateSize()); final SliceOutput sliceOutput = record.output(); sliceOutput.writeLong(sequenceBegin); sliceOutput.writeInt(updates.size()); updates.forEach(new Handler() { @Override public void put(Slice key, Slice value) { sliceOutput.writeByte(VALUE.getPersistentId());
7980818283848586
} private BlockIterator getNextBlock() { Slice blockHandle = blockIterator.next().getValue(); Block dataBlock = table.openBlock(blockHandle); return dataBlock.iterator(); }
979899100101102103104
125126127128129130131132133134135
DBComparator comparator = options.comparator(); UserComparator userComparator; if (comparator != null) { userComparator = new CustomUserComparator(comparator); }else{ userComparator = new BytewiseComparator(); } internalKeyComparator = new InternalKeyComparator(userComparator); memTable = new MemTable(internalKeyComparator); immutableMemTable = null;
123124125126127128129130131132133
//use custom comparator if set DBComparator comparator = options.comparator(); UserComparator userComparator; if (comparator != null) { userComparator = new CustomUserComparator(comparator); }else{ userComparator = new BytewiseComparator(); } internalKeyComparator = new InternalKeyComparator(userComparator); memTable = new MemTable(internalKeyComparator);
116117118119120121122123124125126
fileChannel = new FileInputStream(tableFile).getChannel(); try { if( Iq80DBFactory.USE_MMAP ) { table = new MMapTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } else { table = new FileChannelTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } } catch (IOException e) { Closeables.closeQuietly(fileChannel); throw e;
114115116117118119120121122123124
String tableFileName = Filename.tableFileName(fileNumber); File tableFile = new File(databaseDir, tableFileName); fileChannel = new FileInputStream(tableFile).getChannel(); try { if( Iq80DBFactory.USE_MMAP ) { table = new MMapTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } else { table = new FileChannelTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } } catch (IOException e) {
495051525354555657585960
cache = CacheBuilder.newBuilder() .maximumSize(tableCacheSize) .removalListener(new RemovalListener<Long, TableAndFile>() { public void onRemoval(RemovalNotification<Long, TableAndFile> notification) { Table table = notification.getValue().getTable(); finalizer.addCleanup(table, table.closer()); } }) .build(new CacheLoader<Long, TableAndFile>() { public TableAndFile load(Long fileNumber) throws IOException {
7778798081828384858687
return getTable(file.getNumber()).getApproximateOffsetOf(key); } private Table getTable(long number) { Table table; try { table = cache.get(number).getTable(); } catch (ExecutionException e) { Throwable cause = e;