reuse version key in an actual operation
no need to compute the hash several times
This commit is contained in:
parent
1fb78c53b8
commit
4d357660ca
|
@ -384,8 +384,9 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
private void innerCreate(Create create, IndexWriter writer) throws IOException {
|
private void innerCreate(Create create, IndexWriter writer) throws IOException {
|
||||||
synchronized (dirtyLock(create.uid())) {
|
synchronized (dirtyLock(create.uid())) {
|
||||||
UidField uidField = create.uidField();
|
UidField uidField = create.uidField();
|
||||||
|
HashedBytesRef versionKey = versionKey(create.uid());
|
||||||
final long currentVersion;
|
final long currentVersion;
|
||||||
VersionValue versionValue = versionMap.get(versionKey(create.uid()));
|
VersionValue versionValue = versionMap.get(versionKey);
|
||||||
if (versionValue == null) {
|
if (versionValue == null) {
|
||||||
currentVersion = loadCurrentVersionFromIndex(create.uid());
|
currentVersion = loadCurrentVersionFromIndex(create.uid());
|
||||||
} else {
|
} else {
|
||||||
|
@ -471,7 +472,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
}
|
}
|
||||||
Translog.Location translogLocation = translog.add(new Translog.Create(create));
|
Translog.Location translogLocation = translog.add(new Translog.Create(create));
|
||||||
|
|
||||||
versionMap.put(versionKey(create.uid()), new VersionValue(updatedVersion, false, threadPool.estimatedTimeInMillis(), translogLocation));
|
versionMap.put(versionKey, new VersionValue(updatedVersion, false, threadPool.estimatedTimeInMillis(), translogLocation));
|
||||||
|
|
||||||
indexingService.postCreateUnderLock(create);
|
indexingService.postCreateUnderLock(create);
|
||||||
}
|
}
|
||||||
|
@ -508,8 +509,9 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
private void innerIndex(Index index, IndexWriter writer) throws IOException {
|
private void innerIndex(Index index, IndexWriter writer) throws IOException {
|
||||||
synchronized (dirtyLock(index.uid())) {
|
synchronized (dirtyLock(index.uid())) {
|
||||||
UidField uidField = index.uidField();
|
UidField uidField = index.uidField();
|
||||||
|
HashedBytesRef versionKey = versionKey(index.uid());
|
||||||
final long currentVersion;
|
final long currentVersion;
|
||||||
VersionValue versionValue = versionMap.get(versionKey(index.uid()));
|
VersionValue versionValue = versionMap.get(versionKey);
|
||||||
if (versionValue == null) {
|
if (versionValue == null) {
|
||||||
currentVersion = loadCurrentVersionFromIndex(index.uid());
|
currentVersion = loadCurrentVersionFromIndex(index.uid());
|
||||||
} else {
|
} else {
|
||||||
|
@ -585,7 +587,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
}
|
}
|
||||||
Translog.Location translogLocation = translog.add(new Translog.Index(index));
|
Translog.Location translogLocation = translog.add(new Translog.Index(index));
|
||||||
|
|
||||||
versionMap.put(versionKey(index.uid()), new VersionValue(updatedVersion, false, threadPool.estimatedTimeInMillis(), translogLocation));
|
versionMap.put(versionKey, new VersionValue(updatedVersion, false, threadPool.estimatedTimeInMillis(), translogLocation));
|
||||||
|
|
||||||
indexingService.postIndexUnderLock(index);
|
indexingService.postIndexUnderLock(index);
|
||||||
}
|
}
|
||||||
|
@ -621,7 +623,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
private void innerDelete(Delete delete, IndexWriter writer) throws IOException {
|
private void innerDelete(Delete delete, IndexWriter writer) throws IOException {
|
||||||
synchronized (dirtyLock(delete.uid())) {
|
synchronized (dirtyLock(delete.uid())) {
|
||||||
final long currentVersion;
|
final long currentVersion;
|
||||||
VersionValue versionValue = versionMap.get(versionKey(delete.uid()));
|
HashedBytesRef versionKey = versionKey(delete.uid());
|
||||||
|
VersionValue versionValue = versionMap.get(versionKey);
|
||||||
if (versionValue == null) {
|
if (versionValue == null) {
|
||||||
currentVersion = loadCurrentVersionFromIndex(delete.uid());
|
currentVersion = loadCurrentVersionFromIndex(delete.uid());
|
||||||
} else {
|
} else {
|
||||||
|
@ -678,17 +681,17 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
// doc does not exists and no prior deletes
|
// doc does not exists and no prior deletes
|
||||||
delete.version(updatedVersion).notFound(true);
|
delete.version(updatedVersion).notFound(true);
|
||||||
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
||||||
versionMap.put(versionKey(delete.uid()), new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
||||||
} else if (versionValue != null && versionValue.delete()) {
|
} else if (versionValue != null && versionValue.delete()) {
|
||||||
// a "delete on delete", in this case, we still increment the version, log it, and return that version
|
// a "delete on delete", in this case, we still increment the version, log it, and return that version
|
||||||
delete.version(updatedVersion).notFound(true);
|
delete.version(updatedVersion).notFound(true);
|
||||||
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
||||||
versionMap.put(versionKey(delete.uid()), new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
||||||
} else {
|
} else {
|
||||||
delete.version(updatedVersion);
|
delete.version(updatedVersion);
|
||||||
writer.deleteDocuments(delete.uid());
|
writer.deleteDocuments(delete.uid());
|
||||||
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
|
||||||
versionMap.put(versionKey(delete.uid()), new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
indexingService.postDeleteUnderLock(delete);
|
indexingService.postDeleteUnderLock(delete);
|
||||||
|
@ -865,7 +868,6 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
rwl.writeLock().unlock();
|
rwl.writeLock().unlock();
|
||||||
}
|
}
|
||||||
} else if (flush.type() == Flush.Type.COMMIT_TRANSLOG) {
|
} else if (flush.type() == Flush.Type.COMMIT_TRANSLOG) {
|
||||||
boolean makeTransientCurrent = false;
|
|
||||||
rwl.readLock().lock();
|
rwl.readLock().lock();
|
||||||
try {
|
try {
|
||||||
if (indexWriter == null) {
|
if (indexWriter == null) {
|
||||||
|
|
Loading…
Reference in New Issue