Skip to content

Commit

Permalink
Add new performance settings
Browse files Browse the repository at this point in the history
  • Loading branch information
valentjn committed Nov 10, 2019
1 parent 06dfe31 commit 5630c73
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class Settings {
private String languageModelRulesDirectory = null;
private String neuralNetworkModelRulesDirectory = null;
private String word2VecModelRulesDirectory = null;
private Integer initialJavaHeapSize = null;
private Integer maximumJavaHeapSize = null;
private Integer sentenceCacheSize = null;

public Settings() {
}
Expand Down Expand Up @@ -156,11 +159,33 @@ public void setSettings(JsonElement jsonSettings) {
} catch (NullPointerException | UnsupportedOperationException e) {
word2VecModelRulesDirectory = null;
}

try {
initialJavaHeapSize = getSettingFromJSON(
jsonSettings, "performance.initialJavaHeapSize").getAsInt();
} catch (NullPointerException | UnsupportedOperationException e) {
initialJavaHeapSize = null;
}

try {
maximumJavaHeapSize = getSettingFromJSON(
jsonSettings, "performance.maximumJavaHeapSize").getAsInt();
} catch (NullPointerException | UnsupportedOperationException e) {
maximumJavaHeapSize = null;
}

try {
sentenceCacheSize = getSettingFromJSON(
jsonSettings, "performance.sentenceCacheSize").getAsInt();
} catch (NullPointerException | UnsupportedOperationException e) {
sentenceCacheSize = null;
}
}

@Override
public Object clone() {
Settings obj = new Settings();

obj.languageShortCode = languageShortCode;
obj.diagnosticSeverity = ((diagnosticSeverity == null) ? null : diagnosticSeverity);
obj.dictionary = ((dictionary == null) ? null : new ArrayList<>(dictionary));
Expand All @@ -187,6 +212,10 @@ public Object clone() {
obj.languageModelRulesDirectory = languageModelRulesDirectory;
obj.neuralNetworkModelRulesDirectory = neuralNetworkModelRulesDirectory;
obj.word2VecModelRulesDirectory = word2VecModelRulesDirectory;
obj.initialJavaHeapSize = initialJavaHeapSize;
obj.maximumJavaHeapSize = maximumJavaHeapSize;
obj.sentenceCacheSize = sentenceCacheSize;

return obj;
}

Expand Down Expand Up @@ -261,12 +290,28 @@ public boolean equals(Object obj) {
return false;
}

if ((initialJavaHeapSize == null) ? (other.initialJavaHeapSize != null) :
!initialJavaHeapSize.equals(other.initialJavaHeapSize)) {
return false;
}

if ((maximumJavaHeapSize == null) ? (other.maximumJavaHeapSize != null) :
!maximumJavaHeapSize.equals(other.maximumJavaHeapSize)) {
return false;
}

if ((sentenceCacheSize == null) ? (other.sentenceCacheSize != null) :
!sentenceCacheSize.equals(other.sentenceCacheSize)) {
return false;
}

return true;
}

@Override
public int hashCode() {
int hash = 3;

hash = 53 * hash + ((languageShortCode != null) ? languageShortCode.hashCode() : 0);
hash = 53 * hash + ((diagnosticSeverity != null) ? diagnosticSeverity.hashCode() : 0);
hash = 53 * hash + ((dictionary != null) ? dictionary.hashCode() : 0);
Expand All @@ -283,6 +328,13 @@ public int hashCode() {
neuralNetworkModelRulesDirectory.hashCode() : 0);
hash = 53 * hash + ((word2VecModelRulesDirectory != null) ?
word2VecModelRulesDirectory.hashCode() : 0);
hash = 53 * hash + ((initialJavaHeapSize != null) ?
initialJavaHeapSize.hashCode() : 0);
hash = 53 * hash + ((maximumJavaHeapSize != null) ?
maximumJavaHeapSize.hashCode() : 0);
hash = 53 * hash + ((sentenceCacheSize != null) ?
sentenceCacheSize.hashCode() : 0);

return hash;
}

Expand Down Expand Up @@ -341,4 +393,16 @@ public String getNeuralNetworkModelRulesDirectory() {
public String getWord2VecModelRulesDirectory() {
return getDefault(word2VecModelRulesDirectory, null);
}

public Integer getInitialJavaHeapSize() {
return getDefault(initialJavaHeapSize, null);
}

public Integer getMaximumJavaHeapSize() {
return getDefault(maximumJavaHeapSize, null);
}

public Integer getSentenceCacheSize() {
return getDefault(sentenceCacheSize, 2000);
}
}

0 comments on commit 5630c73

Please sign in to comment.