715N/A * The contents of this file are subject to the terms of the 715N/A * Common Development and Distribution License (the "License"). 715N/A * You may not use this file except in compliance with the License. 715N/A * language governing permissions and limitations under the License. 715N/A * When distributing Covered Code, include this CDDL HEADER in each 715N/A * If applicable, add the following below this CDDL HEADER, with the 715N/A * fields enclosed by brackets "[]" replaced with your own identifying 715N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1338N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 899N/A /** The schema in which the tables live. */ 747N/A /** The names of all the tables created by this class. */ 1421N/A "REPOSITORIES",
"FILES",
"AUTHORS",
"TAGS",
"CHANGESETS",
"FILECHANGES",
844N/A "DIRECTORIES",
"DIRCHANGES" 788N/A * The number of times to retry an operation that failed in a way that 788N/A * indicates that it may succeed if it's tried again. 856N/A * The maximum number of characters in commit messages. Longer messages 851N/A /** The id to be used for the next row inserted into FILES. */ 851N/A /** The id to be used for the next row inserted into DIRECTORIES. */ 851N/A /** The id to be used for the next row inserted into CHANGESETS. */ 898N/A /** The id to be used for the next row inserted into AUTHORS. */ 1421N/A /** The id to be used for the next row inserted into TAGS. */ 864N/A /** Info string to return from {@link #getInfo()}. */ 803N/A /** SQL queries used by this class. */ 760N/A * Create a new cache instance with the default JDBC driver and URL. 760N/A * Create a new cache instance with the specified JDBC driver and URL. 760N/A * @param jdbcDriverClass JDBC driver class to access the database backend 760N/A * @param url the JDBC url to the database 887N/A * Check whether this cache implementation can store history for the given 887N/A * repository. Only repositories that support retrieval of history for the 887N/A * whole directory at once are supported. 788N/A * Handle an {@code SQLException}. If the exception indicates that the 788N/A * operation may succeed if it's retried and the number of attempts hasn't 788N/A * exceeded the limit defined by {@link #MAX_RETRIES}, ignore it and let 788N/A * the caller retry the operation. Otherwise, re-throw the exception. 788N/A * @param sqle the exception to handle 788N/A * @param attemptNo the attempt number, first attempt is 0 788N/A * @throws SQLException if the operation shouldn't be retried 803N/A * Get the SQL text for a name query. 803N/A * @param key name of the query 803N/A * @return SQL text for the query 715N/A // TODO Store a database version which is incremented on each 715N/A // format change. When a version change is detected, drop the database 1402N/A // or, if possible, upgrade the database to the new format. For now, 1402N/A // check if the tables exist, and create them if necessary. 1402N/A // Databases created with 0.11 or earlier versions don't have a 1402N/A // PARENT column in the DIRECTORIES table. If the column is missing, 1402N/A // create it and populate it. Bug #3174. 841N/A // Create a composite index on the repository in ascending order 841N/A // and the id in descending order. This index may allow faster 841N/A // retrieval of history in reverse chronological order. 898N/A // Derby has some performance problems with auto-generated identity 898N/A // columns when multiple threads insert into the same table 898N/A // concurrently. Therefore, we have our own light-weight id generators 898N/A // that we initialize on start-up. Details can be found in Derby's 1402N/A * Fill the PARENT column of the DIRECTORIES table with correct values. 1402N/A * Used when upgrading a database from an old format that doesn't have 851N/A * Initialize the {@code AtomicInteger} object that holds the value of 851N/A * the id to use for the next row in a certain table. If there are rows 851N/A * in the table, take the maximum value and increment it by one. Otherwise, 851N/A * the {@code AtomicInteger} will be left at its current value (presumably 851N/A * @param s a statement object on which the max query is executed 851N/A * @param stmtKey name of the query to execute in order to get max id 851N/A * @param generator the {@code AtomicInteger} object to initialize 788N/A for (
int i =
0;; i++) {
788N/A // Success! Break out of the loop. 717N/A // We do check the return value from ResultSet.next(), but PMD doesn't 717N/A // understand it, so suppress the warning. 788N/A for (
int i =
0;; i++) {
715N/A * Get path name with all file separators replaced with '/'. 715N/A * Get path name with all file separators replaced with '/'. 763N/A * Get the path of a file relative to the source root. 763N/A * @param file the file to get the path for 763N/A * @return relative path for {@code file} with unix file separators 763N/A * Get the path of a file relative to the specified root directory. 763N/A * @param filePath the canonical path of the file to get the relative 763N/A * @param rootPath the canonical path of the root directory 763N/A * @return relative path with unix file separators 844N/A * Get the base name of a path (with unix file separators). 844N/A * @param fullPath the full path of the file with unix file separators 844N/A * @return the base name of the file 844N/A * Get the path to the parent of the specified file. 844N/A * @param fullPath the full path of the file with unix file separators 844N/A * @return the full path of the file's parent 844N/A * Split a full (unix-style) path into an array of path elements. 844N/A * @param fullPath the full unix-style path name 844N/A * @return an array with each separate element of the path 844N/A * @throws IllegalArgumentException if fullPath doesn't start with '/' 844N/A * Reconstruct a path previously split by {@link #splitPath(String)}, or 844N/A * possibly just a part of it (only the {@code num} first elements will 844N/A * @param pathElts the elements of the path 844N/A * @param num the number of elements to use when reconstructing the path 856N/A * Truncate a string to the given length. 856N/A * @param str the string to truncate 856N/A * @param length the length of the string after truncation 856N/A * @return the truncated string 856N/A * @throws IllegalArgumentException if the string is not longer than the 761N/A * Statement that gets the history for the specified file and repository. 761N/A * The result is ordered in reverse chronological order to match the 761N/A * required ordering for {@link HistoryCache#get(File, Repository)}. 779N/A * Statement that gets the history for all files matching a pattern in the 779N/A * given repository. The result is ordered in reverse chronological order 779N/A * to match the required ordering for 779N/A * {@link HistoryCache#get(File, Repository)}. 826N/A /** Statement that retrieves all the files touched by a given changeset. */ 788N/A for (
int i =
0;; i++) {
788N/A * Helper for {@link #get(File, Repository)}. 844N/A // Fetch history for all files under this directory. 788N/A // Fetch history for a single file only. 826N/A // Get the information about a changeset 839N/A // Fill the list of files touched by the changeset, if 839N/A // We do check next(), but PMD doesn't understand it. 788N/A for (
int i =
0;; i++) {
788N/A // Success! Break out of the loop. 761N/A // getHistoryEntries() returns the entries in reverse chronological 761N/A // order, but we want to insert them in chronological order so that 761N/A // their auto-generated identity column can be used as a chronological 761N/A // ordering column. Otherwise, incremental updates will make the 761N/A // identity column unusable for chronological ordering. So therefore 761N/A // we walk the list backwards. 788N/A for (
int i =
0;; i++) {
856N/A // Truncate the message if it can't fit in a VARCHAR 844N/A // Add one row for each file in FILECHANGES, and one row 844N/A // for each path element of the directories in DIRCHANGES. 844N/A // Only add to DIRCHANGES if we haven't already 788N/A // Successfully added the entry. Break out of retry loop. 795N/A * Optimize how the cache is stored on disk. In particular, make sure 795N/A * index cardinality statistics are up to date, and perform a checkpoint 795N/A * to make sure all changes are forced to the tables on disk and that 795N/A * the unneeded transaction log is deleted. 795N/A * @throws HistoryException if an error happens when optimizing the cache 747N/A * Make sure Derby's index cardinality statistics are up to date. 747N/A * Otherwise, the optimizer may choose a bad execution strategy for 747N/A * some queries. This method should be called if the size of the tables 747N/A * has changed significantly. 747N/A * This is a workaround for the problems described in 747N/A * When automatic update of index cardinality statistics has been 747N/A * implemented in Derby, the workaround may be removed. 795N/A * Without this workaround, poor performance has been observed in 795N/A * {@code get()} due to bad choices made by the optimizer. 747N/A * Note that this method uses a system procedure introduced in Derby 10.5. 880N/A * If this procedure does not exist, this method is a no-op. 747N/A "CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS(?, ?, NULL)");
788N/A for (
int i =
0;; i++) {
788N/A // Successfully executed statement. Break out of 880N/A * If this is a Derby database, force a checkpoint so that the disk space 880N/A * occupied by the transaction log is freed as early as possible. 880N/A * Check if a stored database procedure exists. 880N/A * @param dmd the meta-data object used for checking 880N/A * @param schema the procedure's schema 880N/A * @param proc the name of the procedure 880N/A * @return {@code true} if the procedure exists, {@code false} otherwise 880N/A * @throws SQLException if an error happens when reading the meta-data 880N/A // If there's a row, there is such a procedure. 745N/A * Get the id of a repository in the database. If the repository is not 745N/A * stored in the database, add it and return its id. 745N/A * @param conn the connection to the database 745N/A * @param repository the repository whose id to get 745N/A * @return the id of the repository 745N/A // Repository is not in the database. Add it. 745N/A * Get a map from author names to their ids in the database. The authors 745N/A * that are not in the database are added to it. 715N/A * @param conn the connection to the database 715N/A * @param history the history to get the author names from 715N/A * @param reposId the id of the repository 715N/A * @return a map from author names to author ids 844N/A * Build maps from directory names and file names to their respective 844N/A * identifiers in the database. The directories and files that are not 844N/A * already in the database, are added to it. 745N/A * @param conn the connection to the database 844N/A * @param history the history to get the file and directory names from 715N/A * @param reposId the id of the repository 844N/A * @param dirMap a map which will be filled with directory names and ids 844N/A * @param fileMap a map which will be filled with file names and ids 844N/A // Add the file to the database and to the map if it isn't 844N/A // there already. Assumption: If the file is in the database, 844N/A // all its parent directories are also there. 844N/A // Get the dir id for this file, potentially adding the 844N/A // parent directories to the db and to dirMap. 852N/A // Commit every now and then to allow the database to free 852N/A // resources (like locks and transaction log), but not too 852N/A // frequently, since that may kill the performance. It is 852N/A // OK not to commit for every file added, since the worst 852N/A // thing that could happen is that we need to re-insert 852N/A // the files added since the last commit in case of a crash. 844N/A * Populate a map with all path/id combinations found in the FILES or 844N/A * DIRECTORIES tables associated with a specified repository id. 844N/A * @param ps the statement used to get path names and ids from the correct 844N/A * table. It should take one parameter: the repository id. 844N/A * @param reposId the id of the repository to scan 844N/A * @param map the map into which to insert the path/id combinations 844N/A * Add all the parent directories of a specified file to the database, if 844N/A * they haven't already been added, and also put their paths and ids into 844N/A * @param ps statement that inserts a directory into the DIRECTORY table. 851N/A * Takes three parameters: (1) the id of the repository, (2) the path of 851N/A * the directory, and (3) the id to use for the directory. 844N/A * @param reposId id of the repository to which the file belongs 844N/A * @param fullPath the file whose parents to add 844N/A * @param map a map from directory path to id for the directories already 844N/A * in the database. When a new directory is added, it's also added to this 844N/A * @return the id of the first parent of {@code fullPath} 719N/A * Return the integer key generated by the previous execution of a 719N/A * statement. The key should be a single INTEGER, and the statement 719N/A * should insert exactly one row, so there should be only one key. 719N/A * @param stmt a statement that has just inserted a row 719N/A * @return the integer key for the newly inserted row, or {@code null} 788N/A for (
int i =
0;; i++) {
788N/A * Helper for {@link #getLatestCachedRevision(Repository)}. 969N/A for (
int i =
0;; i++) {
969N/A * Helper for {@link #clear(Repository)}. 969N/A // This statement shouldn't be called very frequently, so don't 969N/A // care about caching it...