aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research/MainLogBuffer.java
diff options
context:
space:
mode:
authorKurt Partridge <kep@google.com>2013-05-15 10:46:51 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-05-15 10:46:51 -0700
commit1efcbd67cd445d8c9218ed50d5ef8d5b9e3a273a (patch)
tree12d1a0782bd0c7ea90cfaf172da830c0d7836b7e /java/src/com/android/inputmethod/research/MainLogBuffer.java
parentbec53aa09f89b4aecb276e98e8c1efe0d6857fd0 (diff)
parent8acab80a8680956038b45912d3e00a1d6a5e3cdb (diff)
downloadlatinime-1efcbd67cd445d8c9218ed50d5ef8d5b9e3a273a.tar.gz
latinime-1efcbd67cd445d8c9218ed50d5ef8d5b9e3a273a.tar.xz
latinime-1efcbd67cd445d8c9218ed50d5ef8d5b9e3a273a.zip
am 8acab80a: am 56f35a10: Merge "Fix bug in counting words between samples"
* commit '8acab80a8680956038b45912d3e00a1d6a5e3cdb': Fix bug in counting words between samples
Diffstat (limited to 'java/src/com/android/inputmethod/research/MainLogBuffer.java')
-rw-r--r--java/src/com/android/inputmethod/research/MainLogBuffer.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java
index 3303d2bdb..cd4c1db6e 100644
--- a/java/src/com/android/inputmethod/research/MainLogBuffer.java
+++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java
@@ -25,7 +25,6 @@ import com.android.inputmethod.latin.define.ProductionFlag;
import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.Random;
/**
* MainLogBuffer is a FixedLogBuffer that tracks the state of LogUnits to make privacy guarantees.
@@ -100,10 +99,6 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
return mSuggest.getMainDictionary();
}
- public void resetWordCounter() {
- mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams;
- }
-
public void setIsStopping() {
mIsStopping = true;
}
@@ -201,7 +196,7 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
// Good n-gram at the front of the buffer. Publish it, disclosing details.
publish(logUnits, true /* canIncludePrivateData */);
shiftOutWords(N_GRAM_SIZE);
- resetWordCounter();
+ mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams;
} else {
// No good n-gram at front, and buffer is full. Shift out the first word (or if there
// is none, the existing logUnits).
@@ -224,13 +219,13 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
final boolean canIncludePrivateData);
@Override
- protected void shiftOutWords(final int numWords) {
- final int oldNumActualWords = getNumActualWords();
- super.shiftOutWords(numWords);
- final int numWordsShifted = oldNumActualWords - getNumActualWords();
- mNumWordsUntilSafeToSample -= numWordsShifted;
+ protected int shiftOutWords(final int numWords) {
+ final int numWordContainingLogUnitsShiftedOut = super.shiftOutWords(numWords);
+ mNumWordsUntilSafeToSample = Math.max(0, mNumWordsUntilSafeToSample
+ - numWordContainingLogUnitsShiftedOut);
if (DEBUG) {
Log.d(TAG, "wordsUntilSafeToSample now at " + mNumWordsUntilSafeToSample);
}
+ return numWordContainingLogUnitsShiftedOut;
}
}