public static ChannelProxy getInstance(String filePath) { return getInstance(filePath, DEFAULT_BUFFER_SIZE); }
this.checksumType = checksumType; try (ChannelProxy proxy = ChannelProxy.getInstance(indexFilePath); DataInputStream stream = new DataInputStream(proxy.getInputStream()))
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); //List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); List<String> componentNames = readLines(tocFile); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); try(ChannelProxy proxy = ChannelProxy.getInstance(descriptor.filenameFor(component))) { if (!proxy.exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } } return components; }
/** * Open a RandomAccessReader (not compressed, not mmapped, no read throttling) that will own its channel. * * @param file File to open for reading * @return new RandomAccessReader that owns the channel opened in this method. */ @SuppressWarnings("resource") public static RandomAccessReader open(String file) { ChannelProxy channel = ChannelProxy.getInstance(file);// //new ChannelProxy(file); try { ChunkReader reader = new SimpleChunkReader(channel, -1, BufferType.ON_HEAP, DEFAULT_BUFFER_SIZE); Rebufferer rebufferer = reader.instantiateRebufferer(); return new RandomAccessReaderWithOwnChannel(rebufferer); } catch (Throwable t) { channel.close(); throw t; } } }
/** * Create metadata about given compressed file including uncompressed data length, chunk size * and list of the chunk offsets of the compressed data. * * This is an expensive operation! Don't create more than one for each * sstable. * * @param dataFilePath Path to the compressed file * * @return metadata about given compressed file. */ public static CompressionMetadata create(String dataFilePath) { Descriptor desc = Descriptor.fromFilename(dataFilePath); ChannelProxy proxy = ChannelProxy.getInstance(dataFilePath); try { return new CompressionMetadata(desc.filenameFor(Component.COMPRESSION_INFO), proxy.size(), desc.version.compressedChecksumType()); } finally { proxy.close(); } }
ChannelProxy proxy = ChannelProxy.getInstance(indexSummaryFilename); DataInputStream iStream = null; try {
channel = ChannelProxy.getInstance(path); //new ChannelProxy(path);