diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.search.engine')
24 files changed, 260 insertions, 218 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java index 483feafa53e..7d17bbb103e 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java @@ -22,7 +22,7 @@ public interface IAttributeTaggerProvider { /** * Creates tags for attribute content - * + * * @param attributeData attribute to content to tag * @param collector object collecting tags * @throws Exception @@ -31,7 +31,7 @@ public interface IAttributeTaggerProvider { /** * Searches attribute content for value match - * + * * @param attributeData attribute to search in * @param value to search in attribute content * @param options diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ISearchEngine.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ISearchEngine.java index f62f03f5dbc..190989c5cd7 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ISearchEngine.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ISearchEngine.java @@ -21,7 +21,7 @@ public interface ISearchEngine { /** * Searches tagged items for matches meeting criteria specified. If branchId is less than 0, search will include all * branches in the system. - * + * * @param searchString * @param branchId * @param options @@ -33,7 +33,7 @@ public interface ISearchEngine { /** * Get statistics - * + * * @return search statistics */ SearchStatistics getStatistics(); diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/MatchLocation.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/MatchLocation.java index 533b4592b00..b2e2cd37bd4 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/MatchLocation.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/MatchLocation.java @@ -31,6 +31,7 @@ public class MatchLocation { endPosition = 0; } + @Override public String toString() { return String.format("startAt: [%s] endAt: [%s] ", startPosition, endPosition); } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchOptions.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchOptions.java index 650d7d713a0..008806c58fc 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchOptions.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchOptions.java @@ -18,14 +18,18 @@ import java.util.Properties; public class SearchOptions { public enum SearchOptionsEnum { - include_deleted, match_word_order, as_xml, find_all_locations, case_sensitive; + include_deleted, + match_word_order, + as_xml, + find_all_locations, + case_sensitive; public String asStringOption() { return name().replaceAll("_", " "); } } - private Properties properties; + private final Properties properties; public SearchOptions() { this.properties = new Properties(); diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java index ded23cc7685..42bcc3e8063 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java @@ -23,7 +23,7 @@ import org.eclipse.osee.framework.jdk.core.type.HashCollection; */ public class SearchResult { - private Map<Integer, Map<Integer, ArtifactMatch>> entries; + private final Map<Integer, Map<Integer, ArtifactMatch>> entries; private int size; public SearchResult() { @@ -83,10 +83,10 @@ public class SearchResult { } public class ArtifactMatch { - private int artId; - private int branchId; + private final int artId; + private final int branchId; private boolean hasMatchLocations; - private HashCollection<Long, MatchLocation> attributes; + private final HashCollection<Long, MatchLocation> attributes; public ArtifactMatch(int branchId, int artId) { this.artId = artId; diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeData.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeData.java index b2a737ef4f5..a51184a6dbc 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeData.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeData.java @@ -48,6 +48,7 @@ public class AttributeData implements IAttributeLocator { return branchId; } + @Override public long getGammaId() { return gammaId; } @@ -83,7 +84,7 @@ public class AttributeData implements IAttributeLocator { @Override public String toString() { return String.format("artId:[%s] branchId:[%d] gammaId:[%s] uri:[%s] attrTypeId:[%s]", getArtId(), getId(), - getGammaId(), getUri(), getAttrTypeId()); + getGammaId(), getUri(), getAttrTypeId()); } @Override diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java index 13629a02a8b..2233b5c217e 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java @@ -16,15 +16,14 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; - import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeDataStoreException; import org.eclipse.osee.framework.core.model.type.AttributeType; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.JoinUtility; -import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.database.core.JoinUtility.IdJoinQuery; +import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.search.engine.SearchOptions; import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum; @@ -34,16 +33,21 @@ import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum; */ public class AttributeDataStore { - private static final String LOAD_ATTRIBUTE = "SELECT attr1.gamma_id, attr1.VALUE, attr1.uri, attr1.attr_type_id FROM osee_attribute attr1, osee_tag_gamma_queue tgq1 WHERE attr1.gamma_id = tgq1.gamma_id AND tgq1.query_id = ?"; + private static final String LOAD_ATTRIBUTE = + "SELECT attr1.gamma_id, attr1.VALUE, attr1.uri, attr1.attr_type_id FROM osee_attribute attr1, osee_tag_gamma_queue tgq1 WHERE attr1.gamma_id = tgq1.gamma_id AND tgq1.query_id = ?"; - private static final String GET_TAGGABLE_SQL_BODY = " FROM osee_attribute attr1, osee_attribute_type type1, osee_txs txs1 WHERE txs1.gamma_id = attr1.gamma_id AND attr1.attr_type_id = type1.attr_type_id AND type1.tagger_id IS NOT NULL"; + private static final String GET_TAGGABLE_SQL_BODY = + " FROM osee_attribute attr1, osee_attribute_type type1, osee_txs txs1 WHERE txs1.gamma_id = attr1.gamma_id AND attr1.attr_type_id = type1.attr_type_id AND type1.tagger_id IS NOT NULL"; - private static final String FIND_ALL_TAGGABLE_ATTRIBUTES = "SELECT DISTINCT attr1.gamma_id, type1.tagger_id" + GET_TAGGABLE_SQL_BODY; - private static final String COUNT_TAGGABLE_ATTRIBUTES = "SELECT count(DISTINCT attr1.gamma_id)" + GET_TAGGABLE_SQL_BODY; + private static final String FIND_ALL_TAGGABLE_ATTRIBUTES = + "SELECT DISTINCT attr1.gamma_id, type1.tagger_id" + GET_TAGGABLE_SQL_BODY; + private static final String COUNT_TAGGABLE_ATTRIBUTES = + "SELECT count(DISTINCT attr1.gamma_id)" + GET_TAGGABLE_SQL_BODY; private static final String RESTRICT_BY_BRANCH = " AND txs1.branch_id = ?"; - private static final CompositeKeyHashMap<Integer, Boolean, String> queryCache = new CompositeKeyHashMap<Integer, Boolean, String>(); + private static final CompositeKeyHashMap<Integer, Boolean, String> queryCache = + new CompositeKeyHashMap<Integer, Boolean, String>(); private AttributeDataStore() { } @@ -55,11 +59,10 @@ public class AttributeDataStore { try { chStmt.runPreparedQuery(LOAD_ATTRIBUTE, tagQueueQueryId); while (chStmt.next()) { - attributeData.add(new AttributeData(chStmt.getLong("gamma_id"), chStmt.getString("value"), chStmt.getString("uri"), - chStmt.getInt("attr_type_id"))); + attributeData.add(new AttributeData(chStmt.getLong("gamma_id"), chStmt.getString("value"), + chStmt.getString("uri"), chStmt.getInt("attr_type_id"))); } - } - finally { + } finally { chStmt.close(); } @@ -86,7 +89,8 @@ public class AttributeDataStore { for (int index = 1; index < numberOfTags; index++) { codedTag.append(String.format("ost%d.gamma_id = ost%d.gamma_id and \n", index - 1, index)); } - codedTag.append(String.format("ost%d.gamma_id = attr1.gamma_id and\n attr1.gamma_id = txs1.gamma_id \n", numberOfTags - 1)); + codedTag.append(String.format("ost%d.gamma_id = attr1.gamma_id and\n attr1.gamma_id = txs1.gamma_id \n", + numberOfTags - 1)); if (useAttrTypeJoin) { codedTag.append(" and attr1.attr_type_id = idj.id and idj.query_id = ? "); @@ -105,8 +109,7 @@ public class AttributeDataStore { // txs1 is for attributes, txs2 is for artifact if (options.getBoolean(SearchOptionsEnum.include_deleted.asStringOption())) { toReturn.append(" AND txs1.tx_current IN (1,3)"); - } - else { + } else { toReturn.append(" AND txs1.tx_current = 1"); } return toReturn.toString(); @@ -128,8 +131,7 @@ public class AttributeDataStore { } } - public static Set<AttributeData> getAttributesByTags(final int branchId, final SearchOptions options, final Collection<Long> tagData, - final AttributeType... attributeTypes) throws OseeCoreException { + public static Set<AttributeData> getAttributesByTags(final int branchId, final SearchOptions options, final Collection<Long> tagData, final AttributeType... attributeTypes) throws OseeCoreException { final Set<AttributeData> toReturn = new HashSet<AttributeData>(); IdJoinQuery oseeIdJoin = null; IOseeStatement chStmt = ConnectionHandler.getStatement(); @@ -142,8 +144,7 @@ public class AttributeDataStore { if (attributeTypes.length == 1) { sqlQuery += " and attr1.attr_type_id = ?"; - } - else if (useAttrTypeJoin) { + } else if (useAttrTypeJoin) { oseeIdJoin = JoinUtility.createIdJoinQuery(); for (AttributeType attributeType : attributeTypes) { oseeIdJoin.add(attributeType.getId()); @@ -161,11 +162,11 @@ public class AttributeDataStore { chStmt.runPreparedQuery(sqlQuery, params.toArray(new Object[params.size()])); while (chStmt.next()) { - toReturn.add(new AttributeData(chStmt.getInt("art_id"), chStmt.getLong("gamma_id"), chStmt.getInt("branch_id"), - chStmt.getString("value"), chStmt.getString("uri"), chStmt.getInt("attr_type_id"))); + toReturn.add(new AttributeData(chStmt.getInt("art_id"), chStmt.getLong("gamma_id"), + chStmt.getInt("branch_id"), chStmt.getString("value"), chStmt.getString("uri"), + chStmt.getInt("attr_type_id"))); } - } - finally { + } finally { chStmt.close(); if (useAttrTypeJoin) { oseeIdJoin.delete(); @@ -193,6 +194,6 @@ public class AttributeDataStore { public static int getTotalTaggableItems(OseeConnection connection, final int branchId) throws OseeDataStoreException { return ConnectionHandler.runPreparedQueryFetchInt(connection, -1, getBranchTaggingQueries(branchId, true), - getAllTaggableGammasByBranchQueryData(branchId)); + getAllTaggableGammasByBranchQueryData(branchId)); } } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeSearch.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeSearch.java index 9930c5f8da5..3a5dc9f9b9c 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeSearch.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeSearch.java @@ -50,7 +50,7 @@ public final class AttributeSearch implements ITagCollector { } OseeLog.log(AttributeSearch.class, Level.INFO, String.format("Attribute Search Query found [%d] in [%d] ms", - toReturn.size(), System.currentTimeMillis() - start)); + toReturn.size(), System.currentTimeMillis() - start)); return toReturn; } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeVersion.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeVersion.java index fbf1e2284cc..36111b19433 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeVersion.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/AttributeVersion.java @@ -14,21 +14,26 @@ package org.eclipse.osee.framework.search.engine.data; * @author Roberto E. Escobar */ public class AttributeVersion implements IAttributeLocator { - private long gammaId; + private final long gammaId; public AttributeVersion(long gammaId) { super(); this.gammaId = gammaId; } + @Override public long getGammaId() { return gammaId; } @Override public boolean equals(Object object) { - if (this == object) return true; - if (!(object instanceof IAttributeLocator)) return false; + if (this == object) { + return true; + } + if (!(object instanceof IAttributeLocator)) { + return false; + } IAttributeLocator other = (IAttributeLocator) object; return other.getGammaId() == this.getGammaId(); } @@ -38,6 +43,7 @@ public class AttributeVersion implements IAttributeLocator { return (int) (37 * getGammaId()); } + @Override public String toString() { return String.format("gammaId: [%d]", getGammaId()); } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/SearchTag.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/SearchTag.java index 2f98285541b..3c5f5176dc3 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/SearchTag.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/data/SearchTag.java @@ -18,8 +18,8 @@ import java.util.Set; */ public class SearchTag implements IAttributeLocator { - private AttributeVersion attributeVersion; - private Set<Long> codedTags; + private final AttributeVersion attributeVersion; + private final Set<Long> codedTags; private int runningTotal; public SearchTag(long gammaId) { @@ -46,14 +46,19 @@ public class SearchTag implements IAttributeLocator { this.codedTags.clear(); } + @Override public long getGammaId() { return attributeVersion.getGammaId(); } @Override public boolean equals(Object object) { - if (this == object) return true; - if (!(object instanceof SearchTag)) return false; + if (this == object) { + return true; + } + if (!(object instanceof SearchTag)) { + return false; + } SearchTag other = (SearchTag) object; return other.getGammaId() == this.getGammaId(); } @@ -67,8 +72,9 @@ public class SearchTag implements IAttributeLocator { return this.codedTags; } + @Override public String toString() { return String.format("%s with %d tags cached - total [%d]", attributeVersion.toString(), cacheSize(), - getTotalTags()); + getTotalTags()); } } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/Activator.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/Activator.java index 480a569f2f4..e701e01e8d3 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/Activator.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/Activator.java @@ -33,6 +33,7 @@ public class Activator implements BundleActivator, IOseeCachingServiceProvider { private BundleContext context; + @Override public void start(BundleContext context) throws Exception { instance = this; this.context = context; @@ -44,13 +45,14 @@ public class Activator implements BundleActivator, IOseeCachingServiceProvider { resourceManagementTracker.open(); attributeTaggerProviderTracker = - new ServiceTracker(context, IAttributeTaggerProviderManager.class.getName(), null); + new ServiceTracker(context, IAttributeTaggerProviderManager.class.getName(), null); attributeTaggerProviderTracker.open(); cacheTracker = new ServiceTracker(context, IOseeCachingService.class.getName(), null); cacheTracker.open(); } + @Override public void stop(BundleContext context) throws Exception { attributeTaggerProviderTracker.close(); attributeTaggerProviderTracker = null; diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/InputToTagQueueTx.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/InputToTagQueueTx.java index f15dfb32ff6..7de93784a98 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/InputToTagQueueTx.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/InputToTagQueueTx.java @@ -18,8 +18,8 @@ import org.eclipse.osee.framework.core.exception.OseeDataStoreException; import org.eclipse.osee.framework.core.exception.OseeExceptions; import org.eclipse.osee.framework.database.core.DbTransaction; import org.eclipse.osee.framework.database.core.JoinUtility; -import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.database.core.JoinUtility.TagQueueJoinQuery; +import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.search.engine.ISearchEngineTagger; import org.eclipse.osee.framework.search.engine.ITagListener; diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngine.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngine.java index ac261c5a77b..b2ba731a4e9 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngine.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngine.java @@ -19,8 +19,8 @@ import org.eclipse.osee.framework.search.engine.IAttributeTaggerProviderManager; import org.eclipse.osee.framework.search.engine.ISearchEngine; import org.eclipse.osee.framework.search.engine.MatchLocation; import org.eclipse.osee.framework.search.engine.SearchOptions; -import org.eclipse.osee.framework.search.engine.SearchResult; import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum; +import org.eclipse.osee.framework.search.engine.SearchResult; import org.eclipse.osee.framework.search.engine.attribute.AttributeData; import org.eclipse.osee.framework.search.engine.data.AttributeSearch; @@ -57,8 +57,7 @@ public class SearchEngine implements ISearchEngine { try { List<MatchLocation> locations = manager.find(attributeData, searchString, options); if (!locations.isEmpty()) { - results.add(attributeData.getId(), attributeData.getArtId(), attributeData.getGammaId(), - locations); + results.add(attributeData.getId(), attributeData.getArtId(), attributeData.getGammaId(), locations); } } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, String.format("Error processing: [%s]", attributeData)); @@ -68,12 +67,12 @@ public class SearchEngine implements ISearchEngine { secondPass = System.currentTimeMillis() - secondPass; String firstPassMsg = - String.format("Pass 1: [%d items in %d ms]);", bypassSecondPass ? results.size() : tagMatches.size(), - timeAfterPass1); + String.format("Pass 1: [%d items in %d ms]);", bypassSecondPass ? results.size() : tagMatches.size(), + timeAfterPass1); String secondPassMsg = String.format(" Pass 2: [%d items in %d ms]", results.size(), secondPass); System.out.println(String.format("Search for [%s] - %s%s", searchString, firstPassMsg, - bypassSecondPass ? "" : secondPassMsg)); + bypassSecondPass ? "" : secondPassMsg)); statistics.addEntry(searchString, branchId, options, results.size(), System.currentTimeMillis() - startTime); return results; } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java index e13d3214158..5a0233d6cdf 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java @@ -32,148 +32,148 @@ import org.eclipse.osee.framework.search.engine.utility.SearchTagDataStore; * @author Roberto E. Escobar */ public final class SearchEngineTagger implements ISearchEngineTagger { - private static final int CACHE_LIMIT = 1000; - private final ExecutorService executor; - private final Map<Integer, FutureTask<?>> futureTasks; - private final TaggerStatistics statistics; - - public SearchEngineTagger() { - this.statistics = new TaggerStatistics(); - this.futureTasks = Collections.synchronizedMap(new HashMap<Integer, FutureTask<?>>()); - this.executor = Executors.newFixedThreadPool(3, ServerThreads.createNewThreadFactory("tagger.worker")); - - Timer timer = new Timer("Start-Up Tagger"); - timer.schedule(new StartUpRunnable(this), 3000); - } - - @Override - public int deleteTags(int joinQueryId) throws Exception { - DeleteTagsTx deleteTransaction = new DeleteTagsTx(joinQueryId); - deleteTransaction.execute(); - return deleteTransaction.rowsDeleted(); - } - - @Override - public void tagByQueueQueryId(int queryId) { - tagByQueueQueryId(null, queryId); - } - - @Override - public void tagByQueueQueryId(ITagListener listener, int queryId) { - TaggerRunnable runnable = new TaggerRunnable(queryId, false, CACHE_LIMIT); - runnable.addListener(statistics); - if (listener != null) { - runnable.addListener(listener); - listener.onTagQueryIdSubmit(queryId); - } - FutureTask<Object> futureTask = new FutureTaggingTask(runnable); - this.futureTasks.put(queryId, futureTask); - this.executor.submit(futureTask); - } - - @Override - public void tagByBranchId(ITagListener listener, int branchId) throws OseeCoreException { - this.executor.submit(new BranchTaggerRunnable(this, listener, branchId, false, CACHE_LIMIT)); - } - - @Override - public void tagByBranchId(int branchId) throws OseeCoreException { - tagByBranchId(null, branchId); - } - - @Override - public void tagFromXmlStream(ITagListener listener, InputStream inputStream) throws Exception { - InputStreamTagProcessor inputStreamTagProcessor = - new InputStreamTagProcessor(this, listener, inputStream, false, CACHE_LIMIT); - inputStreamTagProcessor.execute(); - } - - @Override - public void tagFromXmlStream(InputStream inputStream) throws Exception { - tagFromXmlStream(null, inputStream); - } - - @Override - public int getWorkersInQueue() { - return futureTasks.size(); - } - - @Override - public void clearStatistics() { - this.statistics.clear(); - } - - @Override - public ITaggerStatistics getStatistics() { - try { - return this.statistics.clone(); - } catch (CloneNotSupportedException ex) { - return TaggerStatistics.EMPTY_STATS; - } - } - - @Override - public int stopTaggingByQueueQueryId(int... queryId) { - int toReturn = 0; - for (int item : queryId) { - FutureTask<?> task = futureTasks.get(item); - if (task != null) { - if (task.isDone()) { - toReturn++; - } else { - if (task.cancel(true)) { - toReturn++; - } - } - } - } - return toReturn; - } - - @Override - public int stopAllTagging() { - int index = 0; - Set<Integer> list = futureTasks.keySet(); - int[] toProcess = new int[list.size()]; - for (Integer item : list) { - toProcess[index] = item; - index++; - } - return stopTaggingByQueueQueryId(toProcess); - } - - private final class FutureTaggingTask extends FutureTask<Object> { - private final TaggerRunnable runnable; - - public FutureTaggingTask(TaggerRunnable runnable) { - super(runnable, null); - this.runnable = runnable; - } - - @Override - protected void done() { - futureTasks.remove(runnable.getTagQueueQueryId()); - } - } - - private final class DeleteTagsTx extends DbTransaction { - - private final int queryId; - private int updated; - - public DeleteTagsTx(int queryId) throws OseeCoreException { - super(); - this.queryId = queryId; - this.updated = -1; - } - - public int rowsDeleted() { - return updated; - } - - @Override - protected void handleTxWork(OseeConnection connection) throws OseeCoreException { - this.updated = SearchTagDataStore.deleteTags(connection, queryId); - } - } + private static final int CACHE_LIMIT = 1000; + private final ExecutorService executor; + private final Map<Integer, FutureTask<?>> futureTasks; + private final TaggerStatistics statistics; + + public SearchEngineTagger() { + this.statistics = new TaggerStatistics(); + this.futureTasks = Collections.synchronizedMap(new HashMap<Integer, FutureTask<?>>()); + this.executor = Executors.newFixedThreadPool(3, ServerThreads.createNewThreadFactory("tagger.worker")); + + Timer timer = new Timer("Start-Up Tagger"); + timer.schedule(new StartUpRunnable(this), 3000); + } + + @Override + public int deleteTags(int joinQueryId) throws Exception { + DeleteTagsTx deleteTransaction = new DeleteTagsTx(joinQueryId); + deleteTransaction.execute(); + return deleteTransaction.rowsDeleted(); + } + + @Override + public void tagByQueueQueryId(int queryId) { + tagByQueueQueryId(null, queryId); + } + + @Override + public void tagByQueueQueryId(ITagListener listener, int queryId) { + TaggerRunnable runnable = new TaggerRunnable(queryId, false, CACHE_LIMIT); + runnable.addListener(statistics); + if (listener != null) { + runnable.addListener(listener); + listener.onTagQueryIdSubmit(queryId); + } + FutureTask<Object> futureTask = new FutureTaggingTask(runnable); + this.futureTasks.put(queryId, futureTask); + this.executor.submit(futureTask); + } + + @Override + public void tagByBranchId(ITagListener listener, int branchId) throws OseeCoreException { + this.executor.submit(new BranchTaggerRunnable(this, listener, branchId, false, CACHE_LIMIT)); + } + + @Override + public void tagByBranchId(int branchId) throws OseeCoreException { + tagByBranchId(null, branchId); + } + + @Override + public void tagFromXmlStream(ITagListener listener, InputStream inputStream) throws Exception { + InputStreamTagProcessor inputStreamTagProcessor = + new InputStreamTagProcessor(this, listener, inputStream, false, CACHE_LIMIT); + inputStreamTagProcessor.execute(); + } + + @Override + public void tagFromXmlStream(InputStream inputStream) throws Exception { + tagFromXmlStream(null, inputStream); + } + + @Override + public int getWorkersInQueue() { + return futureTasks.size(); + } + + @Override + public void clearStatistics() { + this.statistics.clear(); + } + + @Override + public ITaggerStatistics getStatistics() { + try { + return this.statistics.clone(); + } catch (CloneNotSupportedException ex) { + return TaggerStatistics.EMPTY_STATS; + } + } + + @Override + public int stopTaggingByQueueQueryId(int... queryId) { + int toReturn = 0; + for (int item : queryId) { + FutureTask<?> task = futureTasks.get(item); + if (task != null) { + if (task.isDone()) { + toReturn++; + } else { + if (task.cancel(true)) { + toReturn++; + } + } + } + } + return toReturn; + } + + @Override + public int stopAllTagging() { + int index = 0; + Set<Integer> list = futureTasks.keySet(); + int[] toProcess = new int[list.size()]; + for (Integer item : list) { + toProcess[index] = item; + index++; + } + return stopTaggingByQueueQueryId(toProcess); + } + + private final class FutureTaggingTask extends FutureTask<Object> { + private final TaggerRunnable runnable; + + public FutureTaggingTask(TaggerRunnable runnable) { + super(runnable, null); + this.runnable = runnable; + } + + @Override + protected void done() { + futureTasks.remove(runnable.getTagQueueQueryId()); + } + } + + private final class DeleteTagsTx extends DbTransaction { + + private final int queryId; + private int updated; + + public DeleteTagsTx(int queryId) throws OseeCoreException { + super(); + this.queryId = queryId; + this.updated = -1; + } + + public int rowsDeleted() { + return updated; + } + + @Override + protected void handleTxWork(OseeConnection connection) throws OseeCoreException { + this.updated = SearchTagDataStore.deleteTags(connection, queryId); + } + } } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchStatistics.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchStatistics.java index c22ab73272b..d99f5d05d2b 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchStatistics.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchStatistics.java @@ -37,18 +37,22 @@ public class SearchStatistics implements Cloneable, ISearchStatistics { this.longestQuery = EMPTY_STRING; } + @Override public long getAverageSearchTime() { return averageProcessingTime; } + @Override public int getTotalSearches() { return totalProcessed; } + @Override public long getLongestSearchTime() { return longestProcessingTime; } + @Override public String getLongestSearch() { return longestQuery; } @@ -60,8 +64,8 @@ public class SearchStatistics implements Cloneable, ISearchStatistics { if (processingTime > this.longestProcessingTime) { this.longestQuery = - String.format("Query:[%s] BranchId:[%d] Options:[%s] Found:[%d in %d ms]", queryString, branchId, - options.toString(), found, processingTime); + String.format("Query:[%s] BranchId:[%d] Options:[%s] Found:[%d in %d ms]", queryString, branchId, + options.toString(), found, processingTime); } } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/StartUpRunnable.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/StartUpRunnable.java index 02fef2b05b7..a0ac9905a23 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/StartUpRunnable.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/StartUpRunnable.java @@ -33,8 +33,8 @@ final class StartUpRunnable extends TimerTask { try { if (OseeServerProperties.isCheckTagQueueOnStartupAllowed()) { List<Integer> queries = JoinUtility.getAllTagQueueQueryIds(); - OseeLog.log(SearchEngineTagger.class, Level.INFO, String.format( - "On Start-Up Tagging - [%d] tag queue items.", queries.size())); + OseeLog.log(SearchEngineTagger.class, Level.INFO, + String.format("On Start-Up Tagging - [%d] tag queue items.", queries.size())); for (Integer queryId : queries) { tagger.tagByQueueQueryId(queryId); } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerRunnable.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerRunnable.java index 9413f0f9525..1f2a98b3255 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerRunnable.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerRunnable.java @@ -20,8 +20,8 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeDataStoreException; import org.eclipse.osee.framework.database.core.DbTransaction; import org.eclipse.osee.framework.database.core.JoinUtility; -import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.database.core.JoinUtility.JoinItem; +import org.eclipse.osee.framework.database.core.OseeConnection; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.search.engine.ITagListener; import org.eclipse.osee.framework.search.engine.attribute.AttributeData; @@ -71,8 +71,8 @@ class TaggerRunnable implements Runnable { AttributeToTagTx attributeToTagTx = new AttributeToTagTx(); attributeToTagTx.execute(); } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, String.format("Unable to tag - tagQueueQueryId [%d]", - getTagQueueQueryId()), ex); + OseeLog.log(Activator.class, Level.SEVERE, + String.format("Unable to tag - tagQueueQueryId [%d]", getTagQueueQueryId()), ex); } finally { this.processingTime = System.currentTimeMillis() - processStart; notifyOnTagQueryIdTagComplete(); @@ -85,8 +85,8 @@ class TaggerRunnable implements Runnable { try { listener.onAttributeTagComplete(tagQueueQueryId, gammaId, totalTags, processingTime); } catch (Exception ex) { - OseeLog.log(TaggerRunnable.class, Level.SEVERE, String.format("Error notifying listener: [%s] ", - listener.getClass().getName()), ex); + OseeLog.log(TaggerRunnable.class, Level.SEVERE, + String.format("Error notifying listener: [%s] ", listener.getClass().getName()), ex); } } } @@ -96,8 +96,8 @@ class TaggerRunnable implements Runnable { try { listener.onTagQueryIdTagComplete(tagQueueQueryId, waitTime, processingTime); } catch (Exception ex) { - OseeLog.log(TaggerRunnable.class, Level.SEVERE, String.format("Error notifying listener: [%s] ", - listener.getClass().getName()), ex); + OseeLog.log(TaggerRunnable.class, Level.SEVERE, + String.format("Error notifying listener: [%s] ", listener.getClass().getName()), ex); } } } @@ -107,8 +107,8 @@ class TaggerRunnable implements Runnable { try { listener.onAttributeAddTagEvent(tagQueueQueryId, gammaId, word, codedTag); } catch (Exception ex) { - OseeLog.log(TaggerRunnable.class, Level.SEVERE, String.format("Error notifying listener: [%s] ", - listener.getClass().getName()), ex); + OseeLog.log(TaggerRunnable.class, Level.SEVERE, + String.format("Error notifying listener: [%s] ", listener.getClass().getName()), ex); } } } @@ -146,7 +146,7 @@ class TaggerRunnable implements Runnable { if (!attributeDatas.isEmpty()) { try { SearchTagDataStore.deleteTags(connection, - attributeDatas.toArray(new IAttributeLocator[attributeDatas.size()])); + attributeDatas.toArray(new IAttributeLocator[attributeDatas.size()])); for (AttributeData attributeData : attributeDatas) { long startItemTime = System.currentTimeMillis(); this.currentTag = new SearchTag(attributeData.getGammaId()); @@ -158,15 +158,15 @@ class TaggerRunnable implements Runnable { OseeLog.log(Activator.class, Level.SEVERE, String.format("Unable to tag - [%s]", this.currentTag)); } finally { notifyOnAttributeTagComplete(this.currentTag.getGammaId(), this.currentTag.getTotalTags(), - (System.currentTimeMillis() - startItemTime)); + (System.currentTimeMillis() - startItemTime)); this.currentTag = null; } } store(connection, this.searchTags); JoinUtility.deleteQuery(connection, JoinItem.TAG_GAMMA_QUEUE, getTagQueueQueryId()); } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, String.format("Unable to store tags - tagQueueQueryId [%d]", - getTagQueueQueryId()), ex); + OseeLog.log(Activator.class, Level.SEVERE, + String.format("Unable to store tags - tagQueueQueryId [%d]", getTagQueueQueryId()), ex); } } else { System.out.println(String.format("Empty gamma query id: %s", getTagQueueQueryId())); diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerStatistics.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerStatistics.java index 43153f64fb5..224cc512296 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerStatistics.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaggerStatistics.java @@ -57,54 +57,67 @@ public class TaggerStatistics extends TagListenerAdapter implements Cloneable, I this.mostTags = DEFAULT_TASK_STATS; } + @Override public long getLongestQueryIdWaitTime() { return longestQueryIdWaitTime; } + @Override public long getLongestQueryIdProcessingTime() { return longestQueryIdProcessingTime; } + @Override public long getAverageQueryIdWaitTime() { return averageQueryIdWaitTime; } + @Override public int getTotalQueryIdsProcessed() { return this.totalQueryIdsProcessed; } + @Override public long getAverageQueryIdProcessingTime() { return averageQueryIdProcessingTime; } + @Override public long getAverageAttributeProcessingTime() { return averageAttributeProcessingTime; } + @Override public long getTotalTags() { return totalTags; } + @Override public int getTotalAttributesProcessed() { return totalAttributesProcessed; } + @Override public long getLongestAttributeProcessingTime() { return longestTask.getProcessingTime(); } + @Override public ITagItemStatistics getLongestTask() { return longestTask; } + @Override public ITagItemStatistics getMostTagsTask() { return mostTags; } + @Override public long getTagsInSystem() throws OseeDataStoreException { return SearchTagDataStore.getTotalTags(); } + @Override public long getTotalQueryIdsInQueue() throws OseeDataStoreException { return SearchTagDataStore.getTotalQueryIdsInQueue(); } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaskStatistics.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaskStatistics.java index 6900f300825..5ccb4c10899 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaskStatistics.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/TaskStatistics.java @@ -27,14 +27,17 @@ public class TaskStatistics implements Cloneable, ITagItemStatistics { this.processingTime = processingTime; } + @Override public long getGammaId() { return gammaId; } + @Override public int getTotalTags() { return totalTags; } + @Override public long getProcessingTime() { return processingTime; } diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java index 78ae46c0877..bb22909a242 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java @@ -28,10 +28,12 @@ import org.eclipse.osee.framework.search.engine.utility.WordOrderMatcher; */ public class DefaultAttributeTaggerProvider extends BaseAttributeTaggerProvider { + @Override public void tagIt(AttributeData attributeData, ITagCollector tagCollector) throws OseeCoreException { TagProcessor.collectFromString(getValue(attributeData), tagCollector); } + @Override public List<MatchLocation> find(AttributeData attributeData, String toSearch, SearchOptions options) throws OseeCoreException { if (Strings.isValid(toSearch)) { InputStream inputStream = null; diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java index 1f1693303df..cfe27f6a812 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java @@ -43,6 +43,7 @@ public class XmlAttributeTaggerProvider extends BaseAttributeTaggerProvider { return Collections.emptyList(); } + @Override public void tagIt(AttributeData attributeData, ITagCollector collector) throws OseeCoreException { InputStream inputStream = null; try { diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java index c8f53f4ff66..5af803900f8 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java @@ -35,10 +35,10 @@ public class SearchTagDataStore { private static final String SELECT_TOTAL_TAGS = "select count(1) from osee_search_tags"; private static final String SELECT_TOTAL_QUERY_IDS_IN_QUEUE = - "select count(DISTINCT query_id) from osee_tag_gamma_queue"; + "select count(DISTINCT query_id) from osee_tag_gamma_queue"; private static final String SELECT_SEARCH_TAGS = - "select ost1.gamma_id from osee_search_tags ost1 where ost1.coded_tag_id = ?"; + "select ost1.gamma_id from osee_search_tags ost1 where ost1.coded_tag_id = ?"; public static long getTotalQueryIdsInQueue() throws OseeDataStoreException { return ConnectionHandler.runPreparedQueryFetchLong(-1L, SELECT_TOTAL_QUERY_IDS_IN_QUEUE); diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/TagEncoder.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/TagEncoder.java index c6430751135..a088812464b 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/TagEncoder.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/TagEncoder.java @@ -17,9 +17,8 @@ import java.util.Arrays; */ public class TagEncoder { - private static final char[] tagChars = - new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', - 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'y'}; + private static final char[] tagChars = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', + 'd', 'e', 'f', 'g', 'h', 'i', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'y'}; /** * Create a bit-packed tag that will fit in a 64-bit integer that can provide an extremely quick search mechanism for diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordsUtil.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordsUtil.java index a34a2acdd88..b72b6673fcb 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordsUtil.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordsUtil.java @@ -89,7 +89,7 @@ public class WordsUtil { public static String stripPossesive(String original) { String toReturn = original; if (original != null && original.length() > 0) { - if (original.lastIndexOf('\'') == (original.length() - 1)) { + if (original.lastIndexOf('\'') == original.length() - 1) { toReturn = replaceEndingWith(original, "'", ""); } else if (original.endsWith("'s")) { toReturn = replaceEndingWith(original, "'s", ""); |