Index the entire Wig file content in a SQLite database managed by the ChunkFrequencyManager.

@param wigPath   Wig file
@return          Path to the database
@throws Exception
487055
public static Path index(Path wigPath) throws Exception {
        Path dbPath = wigPath.getParent().resolve(WIG_DB);

        ChunkFrequencyManager chunkFrequencyManager = new ChunkFrequencyManager(dbPath);

        // get the chunk size
        int chunkSize = chunkFrequencyManager.getChunkSize();

        String chromosome = null;
        int step, span = 1, start = 1, end;
        int startChunk, endChunk, partial;

        boolean empty = true;
        List<Integer> values = new ArrayList<>();

        // reader
        BufferedReader bufferedReader = FileUtils.newBufferedReader(wigPath);
        // main loop
        String line = bufferedReader.readLine();
        while (line != null) {
            // check for header lines
            if (WigUtils.isHeaderLine(line)) {
                if (!empty) {
                    // save values for the current chromosome into the database
                    System.out.println("\tStoring " + values.size() + " values for " + chromosome);
//                    if (chromosome.equals("chr1")) {
                        computeAndSaveMeanValues(values, wigPath, chromosome, chunkSize, chunkFrequencyManager);
//                    }
                }

                System.out.println("Loading wig data:" + line);
                if (WigUtils.isVariableStep(line)) {
                    throw new UnsupportedOperationException("Wig coverage file with 'variableStep'"
                            + " is not supported yet.");
                }

                // update some values
                step = WigUtils.getStep(line);
                span = WigUtils.getSpan(line);
                start = WigUtils.getStart(line);
                chromosome = WigUtils.getChromosome(line);
                empty = true;
                values = new ArrayList<>();
                // sanity check
                if (start <= 0) {
                    throw new UnsupportedOperationException("Wig coverage file with"
                            + " 'start' <= 0, it must be greater than 0.");
                }
                if (start != 1) {
                    // we have to put zeros until the start position
                    for (int i = 0; i < start; i++) {
                        values.add(0);
                    }
                }
                if (step != 1) {
                    throw new UnsupportedOperationException("Wig coverage file with"
                            + " 'step' != 1 is not supported yet.");
                }
                // next line...
                line = bufferedReader.readLine();
            } else {
                if (values != null) {
                    end = start + span - 1;
                    startChunk = start / chunkSize;
                    endChunk = end / chunkSize;
                    for (int chunk = startChunk, pos = startChunk * chunkSize;
                         chunk <= endChunk;
                         chunk++, pos += chunkSize) {
                        // compute how many values are within the current chunk
                        // and update the chunk
                        partial = Math.min(end, pos + chunkSize) - Math.max(start, pos);
                        values.add(partial * Integer.parseInt(line));
                        empty = false;
                    }
                    start += span;
                }
                // next line...
                line = bufferedReader.readLine();
            }
        }

        if (!empty) {
            // save values for the current chromosome into the database
            System.out.println("\tStoring " + values.size() + " values for " + chromosome);
//            if (chromosome.equals("chr1")) {
                computeAndSaveMeanValues(values, wigPath, chromosome, chunkSize, chunkFrequencyManager);
//            }
        }

        return dbPath;
    }
658163
public static String get(String subPath) {
        String dataStr = null;
        try {
            dataStr = loadingCache.get(subPath).snd;
        } catch (ExecutionException e) {
            LOG.error(e);
        }
        return dataStr;
    }
300838
public XMLResource xml(JSONPathQuery path) throws Exception {
		Object jsonValue = path.eval(this);
		return xml(jsonValue.toString());
	}
1130032
public static Map<String, List<Object>> readDbf( String path ) throws IOException {

        OmsDbfTableReader reader = new OmsDbfTableReader();
        reader.file = path;
        reader.readTable();

        return reader.outTabledata;
    }
930352
public static String getCategoryPath(String rootPath, String baseFolder) throws CmsException {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new CmsDataAccessException(
                    Messages.get().container(Messages.ERR_CATEGORY_INVALID_LOCATION_1, rootPath));
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
110081
public ManagedEntity findByInventoryPath(String inventoryPath) throws RuntimeFault, RemoteException {
        ManagedObjectReference mor = getVimService().findByInventoryPath(getMOR(), inventoryPath);
        return MorUtil.createExactManagedEntity(getServerConnection(), mor);
    }
685168
@Override
  public final List<String> retrieveList() throws Exception {
    List<String> result = new ArrayList<String>();
    File dbDir = new File(this.databaseDir);
    if (dbDir.exists() && dbDir.isDirectory()) {
      String[] files = dbDir.list();
      if (files != null) {
        for (String flNm : files) {
          if (flNm.endsWith(".sqlite")) {
            result.add(flNm.replace(".sqlite", ""));
          }
        }
      }
    } else {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "DB directory not found: " + this.databaseDir);
    }
    return result;
  }
491633
@Override
    public T addAsDirectory(String path) throws IllegalArgumentException {
        this.getArchive().addAsDirectory(path);
        return covarientReturn();
    }
1123298
private static final HadoopPath toHadoopPath(Path path) {
    if (path == null) {
      throw new NullPointerException();
    }
    if (!(path instanceof HadoopPath)) {
      throw new ProviderMismatchException();
    }
    return (HadoopPath) path;
  }
485051
public static RocksDbWrapper openReadOnly(String dirPath) throws RocksDbException, IOException {
        RocksDbWrapper rocksDbWrapper = new RocksDbWrapper(dirPath, true);
        rocksDbWrapper.init();
        return rocksDbWrapper;
    }
56710
private Path getYarnFilesDir(final ApplicationId appId) throws IOException {
		final FileSystem fileSystem = FileSystem.get(yarnConfiguration);
		final Path homeDir = fileSystem.getHomeDirectory();
		return new Path(homeDir, ".flink/" + appId + '/');
	}
1038392
public static void loadSeg(String path) throws LoadModelException {
		if(seg==null)
		{
			String file = path+segModel;
			seg = new CWSTagger(file);
			seg.setEnFilter(isEnFilter);
		} 
	}
1255427
public static String readStringFromFile(String path, SparkContext sc) throws IOException {
        return readStringFromFile(path, sc.hadoopConfiguration());
    }
1371424
public File[] listFiles(String directoryPath) {
        File[] result = null;
        File directory = null;
        directory = new File(directoryPath);
        if (directory.isDirectory()) {
            result = directory.listFiles();
        }
        return result;
    }
1292440
public static ArrayList<File> getFilesInDirectoryTree(String path, FileFilterRuleSet includeRuleSet) {
		File file = new File(path);
		return getContentsInDirectoryTree(file, includeRuleSet, true, false);
	}
1320158
public void insert(Path filePath, String chromosome, List<Integer> values) {

        Connection conn = null;

        try {
            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:" + databasePath);

            // get the file ID from the database, (if it does not exits, the file will be inserted)
            int fileId = getFileId(filePath, conn);
            if (fileId == -1) {
                throw new InternalError("Impossible to insert file '" + filePath
                        + "' into the database '" + databasePath + "'");
            }

            // update chromosome chunks, inserting them to the database and update the map, if necessary
            if (!chunkIdMap.containsKey(buildChunkMapKey(chromosome, 1))) {
                updateChromosomeChunks(chromosome, values.size(), conn);
            }

            // reset counters
            resetCounters();
            int chunk64k = 0;

            // prepare statement to iterate over the values
            PreparedStatement insertCoverage = conn.prepareStatement("insert into mean_coverage (chunk_id, "
                    + " file_id, v1, v2, v3, v4, v5, v6, v7, v8) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            conn.setAutoCommit(false);

            // main loop
            for (int v: values) {
                chunkValues[counter1] = (byte) Math.min(v, 255);
                if (++counter1 == 8) {
                    // packed mean coverages and save into the packed coverages array
                    packedChunkValues[counter2] = bytesToLong(chunkValues);
                    if (++counter2 == 8) {
                        // write packed coverages array to DB
                        insertPackedChunkValues(insertCoverage, getChunkId(chromosome, chunk64k),
                                fileId, packedChunkValues);

                        // update counters and reset packed coverages array and counter2
                        chunk64k++;
                        Arrays.fill(packedChunkValues, 0);
                        counter2 = 0;
                    }
                    // reset mean coverages array and counter1
                    counter1 = 0;
                    Arrays.fill(chunkValues, (byte) 0);
                }
            }

            // write to DB, if pending mean values
            if (counter1 > 0 || counter2 > 0) {
                packedChunkValues[counter2] = bytesToLong(chunkValues);
                insertPackedChunkValues(insertCoverage, getChunkId(chromosome, chunk64k), fileId, packedChunkValues);
            }
            // execute batch
            insertCoverage.executeBatch();
            conn.commit();
            conn.setAutoCommit(true);

            // close resources
            conn.close();
        } catch (SQLException e) {
            logger.error(e.getClass().getName() + ": " + e.getMessage());
            cleanConnectionClose(conn, null);
        } catch (ClassNotFoundException e) {
            logger.error(e.getClass().getName() + ": " + e.getMessage());
            e.printStackTrace();
        }
    }
662803
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
        try {
            checkIndex();

            DirectoryEntry de = directories.get(path);
            com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles();

            if (ret == null) {
                return com.sun.tools.javac.util.List.<String>nil();
            }
            return ret;
        }
        catch (IOException e) {
            return com.sun.tools.javac.util.List.<String>nil();
        }
    }