Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions buildSrc/src/main/resources/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<module name="OuterTypeFilename" />
<!-- No line wraps inside of import and package statements. -->
<module name="NoLineWrap" />
<!-- only one statement per line should be allowed -->
<module name="OneStatementPerLine"/>
<!-- Each java file has only one outer class -->
<module name="OneTopLevelClass" />
<!-- The suffix L is preferred, because the letter l (ell) is often
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,39 @@ public void writeBinaryInstruction(Location location, Class<?> clazz, Operation
}

switch (operation) {
case MUL: math(GeneratorAdapter.MUL, getType(clazz)); break;
case DIV: math(GeneratorAdapter.DIV, getType(clazz)); break;
case REM: math(GeneratorAdapter.REM, getType(clazz)); break;
case ADD: math(GeneratorAdapter.ADD, getType(clazz)); break;
case SUB: math(GeneratorAdapter.SUB, getType(clazz)); break;
case LSH: math(GeneratorAdapter.SHL, getType(clazz)); break;
case USH: math(GeneratorAdapter.USHR, getType(clazz)); break;
case RSH: math(GeneratorAdapter.SHR, getType(clazz)); break;
case BWAND: math(GeneratorAdapter.AND, getType(clazz)); break;
case XOR: math(GeneratorAdapter.XOR, getType(clazz)); break;
case BWOR: math(GeneratorAdapter.OR, getType(clazz)); break;
case MUL:
math(GeneratorAdapter.MUL, getType(clazz));
break;
case DIV:
math(GeneratorAdapter.DIV, getType(clazz));
break;
case REM:
math(GeneratorAdapter.REM, getType(clazz));
break;
case ADD:
math(GeneratorAdapter.ADD, getType(clazz));
break;
case SUB:
math(GeneratorAdapter.SUB, getType(clazz));
break;
case LSH:
math(GeneratorAdapter.SHL, getType(clazz));
break;
case USH:
math(GeneratorAdapter.USHR, getType(clazz));
break;
case RSH:
math(GeneratorAdapter.SHR, getType(clazz));
break;
case BWAND:
math(GeneratorAdapter.AND, getType(clazz));
break;
case XOR:
math(GeneratorAdapter.XOR, getType(clazz));
break;
case BWOR:
math(GeneratorAdapter.OR, getType(clazz));
break;
default:
throw location.createError(new IllegalStateException("Illegal tree structure."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,33 @@ void write(MethodWriter writer, Globals globals) {
for (AStatement statement : statements) {
statement.write(writer, globals);
}

if (!methodEscape) {
switch (scriptClassInfo.getExecuteMethod().getReturnType().getSort()) {
case org.objectweb.asm.Type.VOID: break;
case org.objectweb.asm.Type.BOOLEAN: writer.push(false); break;
case org.objectweb.asm.Type.BYTE: writer.push(0); break;
case org.objectweb.asm.Type.SHORT: writer.push(0); break;
case org.objectweb.asm.Type.INT: writer.push(0); break;
case org.objectweb.asm.Type.LONG: writer.push(0L); break;
case org.objectweb.asm.Type.FLOAT: writer.push(0f); break;
case org.objectweb.asm.Type.DOUBLE: writer.push(0d); break;
default: writer.visitInsn(Opcodes.ACONST_NULL);
case org.objectweb.asm.Type.VOID:
break;
case org.objectweb.asm.Type.BOOLEAN:
writer.push(false);
break;
case org.objectweb.asm.Type.BYTE:
writer.push(0);
break;
case org.objectweb.asm.Type.SHORT:
writer.push(0);
break;
case org.objectweb.asm.Type.INT:
writer.push(0);
break;
case org.objectweb.asm.Type.LONG:
writer.push(0L);
break;
case org.objectweb.asm.Type.FLOAT:
writer.push(0f);
break;
case org.objectweb.asm.Type.DOUBLE:
writer.push(0d);
break;
default:
writer.visitInsn(Opcodes.ACONST_NULL);
}
writer.returnValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.lucene.queries.BlendedTermQuery;
import org.apache.lucene.queries.CommonTermsQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.ConstantScoreQuery;
Expand All @@ -38,7 +39,6 @@
import org.apache.lucene.search.SynonymQuery;
import org.apache.lucene.search.TermInSetQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.spans.SpanFirstQuery;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanNotQuery;
Expand Down Expand Up @@ -489,43 +489,51 @@ private static Result handleConjunction(List<Result> conjunctions, Version versi
return subResult;
}
}
int msm = 0;
boolean verified = true;
boolean matchAllDocs = true;
boolean hasDuplicateTerms = false;Set<QueryExtraction> extractions = new HashSet<>();
Set<String> seenRangeFields = new HashSet<>();
for (Result result : conjunctions) {
// In case that there are duplicate query extractions we need to be careful with incrementing msm,
// because that could lead to valid matches not becoming candidate matches:
// query: (field:val1 AND field:val2) AND (field:val2 AND field:val3)
// doc: field: val1 val2 val3
// So lets be protective and decrease the msm:
int resultMsm = result.minimumShouldMatch;
for (QueryExtraction queryExtraction : result.extractions) {
if (queryExtraction.range != null) {
// In case of range queries each extraction does not simply increment the minimum_should_match
// for that percolator query like for a term based extraction, so that can lead to more false
// positives for percolator queries with range queries than term based queries.
// The is because the way number fields are extracted from the document to be percolated.
// Per field a single range is extracted and if a percolator query has two or more range queries
// on the same field, then the minimum should match can be higher than clauses in the CoveringQuery.
// Therefore right now the minimum should match is incremented once per number field when processing
// the percolator query at index time.
if (seenRangeFields.add(queryExtraction.range.fieldName)) {
resultMsm = 1;
} else {
resultMsm = 0;
}
}

if (extractions.contains(queryExtraction)) {

resultMsm = 0;
verified = false;
break;
}
}
msm += resultMsm;
int msm = 0;
boolean verified = true;
boolean matchAllDocs = true;
boolean hasDuplicateTerms = false;
Set<QueryExtraction> extractions = new HashSet<>();
Set<String> seenRangeFields = new HashSet<>();
for (Result result : conjunctions) {
// In case that there are duplicate query extractions we need to be careful with
// incrementing msm,
// because that could lead to valid matches not becoming candidate matches:
// query: (field:val1 AND field:val2) AND (field:val2 AND field:val3)
// doc: field: val1 val2 val3
// So lets be protective and decrease the msm:
int resultMsm = result.minimumShouldMatch;
for (QueryExtraction queryExtraction : result.extractions) {
if (queryExtraction.range != null) {
// In case of range queries each extraction does not simply increment the
// minimum_should_match
// for that percolator query like for a term based extraction, so that can lead
// to more false
// positives for percolator queries with range queries than term based queries.
// The is because the way number fields are extracted from the document to be
// percolated.
// Per field a single range is extracted and if a percolator query has two or
// more range queries
// on the same field, then the minimum should match can be higher than clauses
// in the CoveringQuery.
// Therefore right now the minimum should match is incremented once per number
// field when processing
// the percolator query at index time.
if (seenRangeFields.add(queryExtraction.range.fieldName)) {
resultMsm = 1;
} else {
resultMsm = 0;
}
}

if (extractions.contains(queryExtraction)) {

resultMsm = 0;
verified = false;
break;
}
}
msm += resultMsm;

if (result.verified == false
// If some inner extractions are optional, the result can't be verified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(textMinusMarkup);
sb.append("\n");
annotations.forEach(a -> {sb.append(a); sb.append("\n");});
annotations.forEach(a -> {
sb.append(a);
sb.append("\n");
});
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ public static Rounding read(StreamInput in) throws IOException {
Rounding rounding;
byte id = in.readByte();
switch (id) {
case TimeUnitRounding.ID: rounding = new TimeUnitRounding(in); break;
case TimeIntervalRounding.ID: rounding = new TimeIntervalRounding(in); break;
default: throw new ElasticsearchException("unknown rounding id [" + id + "]");
case TimeUnitRounding.ID:
rounding = new TimeUnitRounding(in);
break;
case TimeIntervalRounding.ID:
rounding = new TimeIntervalRounding(in);
break;
default:
throw new ElasticsearchException("unknown rounding id [" + id + "]");
}
return rounding;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ private static Tuple<Integer, ObjectMapper> getDynamicParentMapper(ParseContext
builder = new ObjectMapper.Builder(paths[i]).enabled(true);
}
Mapper.BuilderContext builderContext = new Mapper.BuilderContext(context.indexSettings().getSettings(),
context.path()); mapper = (ObjectMapper) builder.build(builderContext);
context.path());
mapper = (ObjectMapper) builder.build(builderContext);
if (mapper.nested() != ObjectMapper.Nested.NO) {
throw new MapperParsingException("It is forbidden to create dynamic nested objects ([" + context.path().pathAsText(paths[i])
+ "]) through `copy_to` or dots in field names");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,18 @@ public static void writeHistogramOrder(BucketOrder order, StreamOutput out, bool
// convert the new order IDs to the old histogram order IDs.
byte id;
switch (order.id()) {
case COUNT_DESC_ID: id = 4; break;
case COUNT_ASC_ID: id = 3; break;
case KEY_DESC_ID: id = 2; break;
case KEY_ASC_ID: id = 1; break;
case COUNT_DESC_ID:
id = 4;
break;
case COUNT_ASC_ID:
id = 3;
break;
case KEY_DESC_ID:
id = 2;
break;
case KEY_ASC_ID:
id = 1;
break;
default: throw new RuntimeException("unknown order id [" + order.id() + "]");
}
out.writeByte(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ static boolean execute(SearchContext searchContext,

final Runnable checkCancelled;
if (timeoutRunnable != null && cancellationRunnable != null) {
checkCancelled = () -> { timeoutRunnable.run(); cancellationRunnable.run(); };
checkCancelled = () -> {
timeoutRunnable.run();
cancellationRunnable.run();
};
} else if (timeoutRunnable != null) {
checkCancelled = timeoutRunnable;
} else if (cancellationRunnable != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ public void testAddConsumer() {
}

try {
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {consumer.set(a); consumer2.set(b);});
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {
consumer.set(a);
consumer2.set(b);
});
fail("setting not registered");
} catch (IllegalArgumentException ex) {
assertEquals("Setting is not registered for key [foo.bar.baz]", ex.getMessage());
Expand Down Expand Up @@ -467,7 +470,10 @@ public void testApply() {

AtomicInteger aC = new AtomicInteger();
AtomicInteger bC = new AtomicInteger();
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {aC.set(a); bC.set(b);});
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {
aC.set(a);
bC.set(b);
});

assertEquals(0, consumer.get());
assertEquals(0, consumer2.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@ protected void write(List<Tuple<Object, Consumer<Exception>>> candidates) throws
received.addAndGet(candidates.size());
}
};
processor.put(new Object(), (e) -> {notified.incrementAndGet();throw new RuntimeException();});
processor.put(new Object(), (e) -> {notified.incrementAndGet();throw new RuntimeException();});
processor.put(new Object(), (e) -> {
notified.incrementAndGet();
throw new RuntimeException();
});
processor.put(new Object(), (e) -> {
notified.incrementAndGet();
throw new RuntimeException();
});
assertEquals(2, notified.get());
assertEquals(2, received.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,18 @@ public void testStatusEquals() throws IOException {
assertEquals(status.hashCode(), sameStatus.hashCode());

switch (randomInt(3)) {
case 0: task.setPhase("otherPhase"); break;
case 1: task.setResyncedOperations(task.getResyncedOperations() + 1); break;
case 2: task.setSkippedOperations(task.getSkippedOperations() + 1); break;
case 3: task.setTotalOperations(task.getTotalOperations() + 1); break;
case 0:
task.setPhase("otherPhase");
break;
case 1:
task.setResyncedOperations(task.getResyncedOperations() + 1);
break;
case 2:
task.setSkippedOperations(task.getSkippedOperations() + 1);
break;
case 3:
task.setTotalOperations(task.getTotalOperations() + 1);
break;
}

PrimaryReplicaSyncer.ResyncTask.Status differentStatus = task.getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
public void testEmptySettingsAreOkay() throws InterruptedException {
AtomicBoolean scheduled = new AtomicBoolean();
execute(Settings.EMPTY,
(command, interval, name) -> { scheduled.set(true); return new MockCancellable(); },
(command, interval, name) -> {
scheduled.set(true);
return new MockCancellable();
},
() -> assertTrue(scheduled.get()));
}

public void testDisabledSetting() throws InterruptedException {
Settings settings = Settings.builder().put("monitor.jvm.gc.enabled", "false").build();
AtomicBoolean scheduled = new AtomicBoolean();
execute(settings,
(command, interval, name) -> { scheduled.set(true); return new MockCancellable(); },
(command, interval, name) -> {
scheduled.set(true);
return new MockCancellable();
},
() -> assertFalse(scheduled.get()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public void setupSuiteScopeCluster() throws Exception {
multiValue = new boolean[] {true};
break;
case 3:
numMultiFalses++; numMultiTrues++;
numMultiFalses++;
numMultiTrues++;
multiValue = new boolean[] {false, true};
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,11 @@ private static HighlightBuilder mutate(HighlightBuilder original) throws IOExcep
switch (randomIntBetween(0, 2)) {
// change settings that only exists on top level
case 0:
mutation.useExplicitFieldOrder(!original.useExplicitFieldOrder()); break;
mutation.useExplicitFieldOrder(!original.useExplicitFieldOrder());
break;
case 1:
mutation.encoder(original.encoder() + randomAlphaOfLength(2)); break;
mutation.encoder(original.encoder() + randomAlphaOfLength(2));
break;
case 2:
if (randomBoolean()) {
// add another field
Expand Down
Loading