Tabnine Logo
CachingOrcDataSource
Code IndexAdd Tabnine to your IDE (free)

How to use
CachingOrcDataSource
in
io.prestosql.orc

Best Java code snippets using io.prestosql.orc.CachingOrcDataSource (Showing top 12 results out of 315)

origin: prestosql/presto

@Override
public void readFully(long position, byte[] buffer, int bufferOffset, int length)
    throws IOException
{
  if (position < cachePosition) {
    throw new IllegalArgumentException(String.format("read request (offset %d length %d) is before cache (offset %d length %d)", position, length, cachePosition, cacheLength));
  }
  if (position >= cachePosition + cacheLength) {
    readCacheAt(position);
  }
  if (position + length > cachePosition + cacheLength) {
    throw new IllegalArgumentException(String.format("read request (offset %d length %d) partially overlaps cache (offset %d length %d)", position, length, cachePosition, cacheLength));
  }
  System.arraycopy(cache, toIntExact(position - cachePosition), buffer, bufferOffset, length);
}
origin: prestosql/presto

@Override
public void readFully(long position, byte[] buffer)
    throws IOException
{
  readFully(position, buffer, 0, buffer.length);
}
origin: io.prestosql/presto-orc

CachingOrcDataSource cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(3);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(3, 60)));
cachingOrcDataSource.readCacheAt(63);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(63, 8 * 1048576)));
cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(62); // read at the end of a stripe
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(3, 60)));
cachingOrcDataSource.readCacheAt(63);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(63, 8 * 1048576)));
cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(3);
origin: prestosql/presto

@VisibleForTesting
static OrcDataSource wrapWithCacheIfTinyStripes(OrcDataSource dataSource, List<StripeInformation> stripes, DataSize maxMergeDistance, DataSize tinyStripeThreshold)
{
  if (dataSource instanceof CachingOrcDataSource) {
    return dataSource;
  }
  for (StripeInformation stripe : stripes) {
    if (stripe.getTotalLength() > tinyStripeThreshold.toBytes()) {
      return dataSource;
    }
  }
  return new CachingOrcDataSource(dataSource, createTinyStripesRangeFinder(stripes, maxMergeDistance, tinyStripeThreshold));
}
origin: prestosql/presto

CachingOrcDataSource cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(3);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(3, 60)));
cachingOrcDataSource.readCacheAt(63);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(63, 8 * 1048576)));
cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(62); // read at the end of a stripe
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(3, 60)));
cachingOrcDataSource.readCacheAt(63);
assertEquals(testingOrcDataSource.getLastReadRanges(), ImmutableList.of(new DiskRange(63, 8 * 1048576)));
cachingOrcDataSource = new CachingOrcDataSource(
    testingOrcDataSource,
    createTinyStripesRangeFinder(
        maxMergeDistance,
        tinyStripeThreshold));
cachingOrcDataSource.readCacheAt(3);
origin: io.prestosql/presto-orc

@VisibleForTesting
static OrcDataSource wrapWithCacheIfTinyStripes(OrcDataSource dataSource, List<StripeInformation> stripes, DataSize maxMergeDistance, DataSize tinyStripeThreshold)
{
  if (dataSource instanceof CachingOrcDataSource) {
    return dataSource;
  }
  for (StripeInformation stripe : stripes) {
    if (stripe.getTotalLength() > tinyStripeThreshold.toBytes()) {
      return dataSource;
    }
  }
  return new CachingOrcDataSource(dataSource, createTinyStripesRangeFinder(stripes, maxMergeDistance, tinyStripeThreshold));
}
origin: io.prestosql/presto-orc

private static OrcDataSource wrapWithCacheIfTiny(OrcDataSource dataSource, DataSize maxCacheSize)
{
  if (dataSource instanceof CachingOrcDataSource) {
    return dataSource;
  }
  if (dataSource.getSize() > maxCacheSize.toBytes()) {
    return dataSource;
  }
  DiskRange diskRange = new DiskRange(0, toIntExact(dataSource.getSize()));
  return new CachingOrcDataSource(dataSource, desiredOffset -> diskRange);
}
origin: io.prestosql/presto-orc

@Override
public void readFully(long position, byte[] buffer, int bufferOffset, int length)
    throws IOException
{
  if (position < cachePosition) {
    throw new IllegalArgumentException(String.format("read request (offset %d length %d) is before cache (offset %d length %d)", position, length, cachePosition, cacheLength));
  }
  if (position >= cachePosition + cacheLength) {
    readCacheAt(position);
  }
  if (position + length > cachePosition + cacheLength) {
    throw new IllegalArgumentException(String.format("read request (offset %d length %d) partially overlaps cache (offset %d length %d)", position, length, cachePosition, cacheLength));
  }
  System.arraycopy(cache, toIntExact(position - cachePosition), buffer, bufferOffset, length);
}
origin: io.prestosql/presto-orc

@Override
public void readFully(long position, byte[] buffer)
    throws IOException
{
  readFully(position, buffer, 0, buffer.length);
}
origin: prestosql/presto

private static OrcDataSource wrapWithCacheIfTiny(OrcDataSource dataSource, DataSize maxCacheSize)
{
  if (dataSource instanceof CachingOrcDataSource) {
    return dataSource;
  }
  if (dataSource.getSize() > maxCacheSize.toBytes()) {
    return dataSource;
  }
  DiskRange diskRange = new DiskRange(0, toIntExact(dataSource.getSize()));
  return new CachingOrcDataSource(dataSource, desiredOffset -> diskRange);
}
origin: io.prestosql/presto-orc

@Override
public <K> Map<K, OrcDataSourceInput> readFully(Map<K, DiskRange> diskRanges)
    throws IOException
{
  ImmutableMap.Builder<K, OrcDataSourceInput> builder = ImmutableMap.builder();
  // Assumption here: all disk ranges are in the same region. Therefore, serving them in arbitrary order
  // will not result in eviction of cache that otherwise could have served any of the DiskRanges provided.
  for (Map.Entry<K, DiskRange> entry : diskRanges.entrySet()) {
    DiskRange diskRange = entry.getValue();
    byte[] buffer = new byte[diskRange.getLength()];
    readFully(diskRange.getOffset(), buffer);
    builder.put(entry.getKey(), new OrcDataSourceInput(Slices.wrappedBuffer(buffer).getInput(), buffer.length));
  }
  return builder.build();
}
origin: prestosql/presto

@Override
public <K> Map<K, OrcDataSourceInput> readFully(Map<K, DiskRange> diskRanges)
    throws IOException
{
  ImmutableMap.Builder<K, OrcDataSourceInput> builder = ImmutableMap.builder();
  // Assumption here: all disk ranges are in the same region. Therefore, serving them in arbitrary order
  // will not result in eviction of cache that otherwise could have served any of the DiskRanges provided.
  for (Map.Entry<K, DiskRange> entry : diskRanges.entrySet()) {
    DiskRange diskRange = entry.getValue();
    byte[] buffer = new byte[diskRange.getLength()];
    readFully(diskRange.getOffset(), buffer);
    builder.put(entry.getKey(), new OrcDataSourceInput(Slices.wrappedBuffer(buffer).getInput(), buffer.length));
  }
  return builder.build();
}
io.prestosql.orcCachingOrcDataSource

Most used methods

  • <init>
  • readCacheAt
  • readFully

Popular in Java

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (Timer)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now