Package com.netflix.aegisthus.io.sstable

Examples of com.netflix.aegisthus.io.sstable.OffsetScanner


            long bytesRemaining = length;

            Path compressionPath = new Path(path.getParent(), path.getName().replaceAll("-Data.db",
                    "-CompressionInfo.db"));
            if (!fs.exists(compressionPath)) {
                OffsetScanner scanner = null;
                // Only initialize if we are going to have more than a single
                // split
                Path indexPath = null;
                if (fuzzySplit < length) {
                    indexPath = new Path(path.getParent(), path.getName().replaceAll("-Data.db", "-Index.db"));
                    if (!fs.exists(indexPath)) {
                        fuzzySplit = length;
                    } else {
                        FSDataInputStream fileIn = fs.open(indexPath);
                        scanner = new OffsetScanner(new BufferedInputStream(fileIn), indexPath.getName());
                    }
                }
                long splitStart = 0;
                long indexOffset = 0;
                long newIndexOffset = 0;
                while (splitStart + fuzzySplit < length && scanner != null && scanner.hasNext()) {
                    long splitSize = 0;
                    // The scanner returns an offset from the start of the file.
                    while (splitSize < maxSplitSize && scanner.hasNext()) {
                        Pair<Long, Long> pair = scanner.next();
                        splitSize = pair.left - splitStart;
                        newIndexOffset = pair.right;

                    }
                    int blkIndex = getBlockIndex(blkLocations, splitStart + (splitSize / 2));
                    LOG.debug("split path: {}:{}:{}", path.getName(), splitStart, splitSize);
                    splits.add(new AegSplit(path, splitStart, splitSize, blkLocations[blkIndex].getHosts()));
                    indexOffset = newIndexOffset;
                    bytesRemaining -= splitSize;
                    splitStart += splitSize;
                }
                if (scanner != null) {
                    scanner.close();
                }
            }

            if (bytesRemaining != 0) {
                LOG.debug("end path: {}:{}:{}", path.getName(), length - bytesRemaining, bytesRemaining);
View Full Code Here


      long bytesRemaining = length;

      Path compressionPath = new Path(path.getParent(), path.getName().replaceAll("-Data.db",
                                            "-CompressionInfo.db"));
      if (!fs.exists(compressionPath)) {
        OffsetScanner scanner = null;
        // Only initialize if we are going to have more than a single
        // split
        if (fuzzySplit < length) {
          Path indexPath = new Path(path.getParent(), path.getName().replaceAll("-Data.db", "-Index.db"));
          if (!fs.exists(indexPath)) {
            fuzzySplit = length;
          } else {
            FSDataInputStream fileIn = fs.open(indexPath);
            scanner = new OffsetScanner(new DataInputStream(new BufferedInputStream(fileIn)), indexPath.getName());
          }
        }
        long splitStart = 0;
        while (splitStart + fuzzySplit < length && scanner.hasNext()) {
          long splitSize = 0;
          // The scanner returns an offset from the start of the file.
          while (splitSize < maxSplitSize && scanner.hasNext()) {
                        Pair<Long, Long> pair = scanner.next();
                        splitSize = pair.left - splitStart;
          }
          int blkIndex = getBlockIndex(blkLocations, splitStart + (splitSize / 2));
          LOG.info("split path: " + path.getName() + ":" + splitStart + ":" + splitSize);
          splits
              .add(new AegSplitpath,
                        splitStart,
                        splitSize,
                        blkLocations[blkIndex].getHosts(),
                        convertors));
          bytesRemaining -= splitSize;
          splitStart += splitSize;
        }
        if (scanner != null ) {
          scanner.close();
        }
      }

      if (bytesRemaining != 0) {
        LOG.info("end path: " + path.getName() + ":" + (length - bytesRemaining) + ":" + bytesRemaining);
View Full Code Here

        }
        System.out.flush();
    }

    public static void exportIndex(String ssTableFile) throws IOException {
        export(new OffsetScanner(ssTableFile), true);
    }
View Full Code Here

        export(new OffsetScanner(ssTableFile), true);
    }

    public static void exportIndexSplit(String ssTableFile, DataInput input, Descriptor.Version version)
            throws IOException {
        Iterator<Pair<Long, Long>> scanner = new OffsetScanner(input, version);

        long maxSplitSize = Long.getLong("aegisthus.block.size", 67108864);
        long splitStart = 0;
        while (scanner.hasNext()) {
            long splitSize = 0;
            // The scanner returns an offset from the start of the file.
            while (splitSize < maxSplitSize && scanner.hasNext()) {
                splitSize = scanner.next().left - splitStart;
            }
            if (scanner.hasNext()) {
                System.out.println(ssTableFile + "\t" + splitStart + "\t" + splitSize);
            } else {
                System.out.println(ssTableFile + "\t" + splitStart + "\t" + -1);
            }
            splitStart += splitSize;
View Full Code Here

TOP

Related Classes of com.netflix.aegisthus.io.sstable.OffsetScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.