test_class.declarator: INDEX_FILE = "/data/Keyspace1-Standard1-ic-0-Index.db"
test_class.modifier: private static final
test_class.original_string: private static final String INDEX_FILE = "/data/Keyspace1-Standard1-ic-0-Index.db";
test_class.type: String
test_class.var_name: INDEX_FILE
test_class.declarator: fileSystem
test_class.modifier: private
test_class.original_string: private LocalFileSystem fileSystem;
test_class.type: LocalFileSystem
test_class.var_name: fileSystem
test_class.file: db/cassandra-intro/src/test/java/com/fullcontact/sstable/index/SSTableIndexIndexerTest.java
test_class.identifier: SSTableIndexIndexerTest
test_case.body: @Test
      public void testIndex() throws Exception {
  
          // Create a temp dir...
          final File tmpDir = Files.createTempDir();
          tmpDir.deleteOnExit();
  
          // Copy the .Index.db file to the temp dir...
          File sampleFile = new File(getClass().getResource(INDEX_FILE).getFile());
          File tmpSampleFile = new File(tmpDir, sampleFile.getName());
          Files.copy(sampleFile, tmpSampleFile);
  
          fileSystem.getConf().set("hadoop.sstable.split.mb", "1");
  
          SSTableIndexIndexer indexer = new SSTableIndexIndexer(fileSystem.getConf());
  
          indexer.index(new Path(tmpDir.getAbsolutePath(), sampleFile.getName()));
  
          indexer.complete();
  
          SSTableIndexIndex index =
                  SSTableIndexIndex.readIndex(fileSystem, new Path(tmpDir.getAbsolutePath(), sampleFile.getName()));
          assertNotNull(index);
          assertEquals(1, index.getOffsets().size());
          assertEquals(0, index.getOffsets().get(0).getStart());
          assertEquals(18, index.getOffsets().get(0).getEnd());
      }
test_case.class_method_signature: SSTableIndexIndexerTest.testIndex()
test_case.full_signature: @Test public void testIndex()
test_case.identifier: testIndex
test_case.invocations: createTempDir deleteOnExit getFile getResource getClass getName copy set getConf getConf index getAbsolutePath getName complete readIndex getAbsolutePath getName assertNotNull assertEquals size getOffsets assertEquals getStart get getOffsets assertEquals getEnd get getOffsets
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIndex()
focal_class.declarator: LOG = LoggerFactory.getLogger(SSTableIndexIndexer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(SSTableIndexIndexer.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: configuration
focal_class.modifier: private final
focal_class.original_string: private final Configuration configuration;
focal_class.type: Configuration
focal_class.var_name: configuration
focal_class.declarator: decimalFormat
focal_class.modifier: private final
focal_class.original_string: private final DecimalFormat decimalFormat;
focal_class.type: DecimalFormat
focal_class.var_name: decimalFormat
focal_class.declarator: service
focal_class.modifier: private final
focal_class.original_string: private final ListeningExecutorService service;
focal_class.type: ListeningExecutorService
focal_class.var_name: service
focal_class.declarator: SST_EXTENSION = "-Index.db"
focal_class.modifier: private static final
focal_class.original_string: private static final String SST_EXTENSION = "-Index.db";
focal_class.type: String
focal_class.var_name: SST_EXTENSION
focal_class.file: db/cassandra-intro/src/main/java/com/fullcontact/sstable/index/SSTableIndexIndexer.java
focal_class.identifier: SSTableIndexIndexer
focal_class.class_method_signature: SSTableIndexIndexer.SSTableIndexIndexer(final Configuration configuration)
focal_class.full_signature: public  SSTableIndexIndexer(final Configuration configuration)
focal_class.identifier: SSTableIndexIndexer
focal_class.modifiers: public
focal_class.parameters: (final Configuration configuration)
focal_class.signature:  SSTableIndexIndexer(final Configuration configuration)
focal_class.class_method_signature: SSTableIndexIndexer.index(final Path sstablePath)
focal_class.full_signature: public void index(final Path sstablePath)
focal_class.identifier: index
focal_class.modifiers: public
focal_class.parameters: (final Path sstablePath)
focal_class.return: void
focal_class.signature: void index(final Path sstablePath)
focal_class.class_method_signature: SSTableIndexIndexer.indexSingleFile(final FileSystem fileSystem, final Path sstablePath)
focal_class.full_signature: private void indexSingleFile(final FileSystem fileSystem, final Path sstablePath)
focal_class.identifier: indexSingleFile
focal_class.modifiers: private
focal_class.parameters: (final FileSystem fileSystem, final Path sstablePath)
focal_class.return: void
focal_class.signature: void indexSingleFile(final FileSystem fileSystem, final Path sstablePath)
focal_class.class_method_signature: SSTableIndexIndexer.main(String[] args)
focal_class.full_signature: public static void main(String[] args)
focal_class.identifier: main
focal_class.modifiers: public static
focal_class.parameters: (String[] args)
focal_class.return: void
focal_class.signature: void main(String[] args)
focal_class.class_method_signature: SSTableIndexIndexer.complete()
focal_class.full_signature: public void complete()
focal_class.identifier: complete
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void complete()
focal_class.class_method_signature: SSTableIndexIndexer.printUsage()
focal_class.full_signature: private static void printUsage()
focal_class.identifier: printUsage
focal_class.modifiers: private static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void printUsage()
focal_method.body: public void index(final Path sstablePath) throws IOException {
  
          final FileSystem fileSystem = FileSystem.get(URI.create(sstablePath.toString()), configuration);
          final FileStatus fileStatus = fileSystem.getFileStatus(sstablePath);
  
          if (fileStatus.isDir()) {
              LOG.info("SSTable Indexing directory {}", sstablePath);
              final FileStatus[] statuses = fileSystem.listStatus(sstablePath);
              for (final FileStatus childStatus : statuses) {
                  index(childStatus.getPath());
              }
          } else if (sstablePath.toString().endsWith(SST_EXTENSION)) {
              final Path sstableIndexPath = new Path(sstablePath.toString() + SSTableIndexIndex.SSTABLE_INDEX_SUFFIX);
              if (fileSystem.exists(sstableIndexPath)) {
                  LOG.info("Skipping as SSTable index file already exists for {}", sstablePath);
              } else {
                  // Kick a thread for the index.
                  final ListenableFuture<IndexRequest> indexFuture = service.submit(new Callable<IndexRequest>() {
                      @Override
                      public IndexRequest call() throws Exception {
                          final long startTime = System.currentTimeMillis();
                          final long fileSize = fileStatus.getLen();
  
                          LOG.info("Indexing SSTABLE Indexing file {}, size {} GB...", sstablePath,
                                  decimalFormat.format(fileSize / (1024.0 * 1024.0 * 1024.0)));
  
                          indexSingleFile(fileSystem, sstablePath);
  
                          return new IndexRequest(sstableIndexPath, startTime, fileSize);
                      }
                  });
  
                  Futures.addCallback(indexFuture, new FutureCallback<IndexRequest>() {
                      public void onSuccess(final IndexRequest indexRequest) {
                          long indexSize = 0;
  
                          try {
                              indexSize = fileSystem.getFileStatus(indexRequest.getIndexPath()).getLen();
                          } catch (IOException e) {
                              LOG.error("Error getting file status for index path: {}", indexRequest.getIndexPath());
                          }
  
                          final double elapsed = (System.currentTimeMillis() - indexRequest.getStartTime()) / 1000.0;
  
                          LOG.info("Completed SSTABLE Indexing in {} seconds ({} MB/s).  Index size is {} KB.",
                                  decimalFormat.format(elapsed),
                                  decimalFormat.format(indexRequest.getFileSize() / (1024.0 * 1024.0 * elapsed)),
                                  decimalFormat.format(indexSize / 1024.0));
                      }
  
                      public void onFailure(Throwable e) {
                          LOG.error("Failed to index.", e);
                      }
                  });
  
              }
          }
      }
focal_method.class_method_signature: SSTableIndexIndexer.index(final Path sstablePath)
focal_method.full_signature: public void index(final Path sstablePath)
focal_method.identifier: index
focal_method.invocations: get create toString getFileStatus isDir info listStatus index getPath endsWith toString toString exists info submit currentTimeMillis getLen info format indexSingleFile addCallback getLen getFileStatus getIndexPath error getIndexPath currentTimeMillis getStartTime info format format getFileSize format error
focal_method.modifiers: public
focal_method.parameters: (final Path sstablePath)
focal_method.return: void
focal_method.signature: void index(final Path sstablePath)