@Override public SortedOplogWriter createWriter() throws IOException { synchronized (metadata) { metadata.clear(); } data.set(new ConcurrentSkipListMap<byte[], byte[]>( config.getComparator().toBytesComparator())); return new NoFileWriter(); }
@Override public SortedIterator<ByteBuffer> scan( byte[] from, boolean fromInclusive, byte[] to, boolean toInclusive, boolean ascending, MetadataFilter filter) throws IOException { SerializedComparator sc = factory.getConfiguration().getComparator(); sc = ascending ? sc : ReversingSerializedComparator.reverse(sc); List<SortedIterator<ByteBuffer>> scans = new ArrayList<SortedIterator<ByteBuffer>>(); Collection<TrackedReference<SortedOplogReader>> soplogs; rwlock.readLock().lock(); try { scans.add(getCurrent().scan(from, fromInclusive, to, toInclusive, ascending, filter)); for (SortedBuffer<Integer> sb : unflushed) { scans.add(sb.scan(from, fromInclusive, to, toInclusive, ascending, filter)); } soplogs = compactor.getActiveReaders(from, to); } finally { rwlock.readLock().unlock(); } for (TrackedReference<SortedOplogReader> tr : soplogs) { scans.add(tr.get().scan(from, fromInclusive, to, toInclusive, ascending, filter)); } return new MergedIterator(sc, soplogs, scans); }
public SortedBuffer(SortedOplogConfiguration config, T tag) { assert config != null; assert tag != null; this.tag = tag; buffer = new ConcurrentSkipListMap<byte[], byte[]>( config.getComparator().toBytesComparator()); stats = new BufferStats(); metadata = new EnumMap<Metadata, byte[]>(Metadata.class); String name = config.getName() + "#" + tag; logger = ComponentLogWriter.getSoplogLogWriter(name, LogService.logger()); }
public HFileSortedOplogWriter() throws IOException { HFileContext hcontext = new HFileContextBuilder() .withBlockSize(sopConfig.getBlockSize()) .withBytesPerCheckSum(sopConfig.getBytesPerChecksum()) .withChecksumType(HFileSortedOplogFactory.convertChecksum( sopConfig.getChecksum())) .withCompression(HFileSortedOplogFactory.convertCompression( sopConfig.getCompression())) .withDataBlockEncoding(HFileSortedOplogFactory.convertEncoding( sopConfig.getKeyEncoding()).getDataBlockEncoding()) .build(); writer = HFile.getWriterFactory(hconf, hcache) .withPath(fs, path) .withFileContext(hcontext) .withComparator(sopConfig.getComparator()) .create(); bfw = sopConfig.isBloomFilterEnabled() ? // BloomFilterFactory.createGeneralBloomAtWrite(hconf, hcache, BloomType.ROW, // 0, writer, sopConfig.getComparator()) BloomFilterFactory.createGeneralBloomAtWrite(hconf, hcache, BloomType.ROW, 0, writer) : null; }
@Override public SerializedComparator getComparator() { return factory.getConfiguration().getComparator(); }