Skip to content

Commit

Permalink
Fix missing wildcard from LIKE when querying source segments for allo…
Browse files Browse the repository at this point in the history
…cation.
  • Loading branch information
agoallikmaa committed Aug 1, 2018
1 parent 9b2a4f6 commit 7e4c709
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -334,6 +334,8 @@ private List<DataSegment> collectSourceSegments(
sourceVersion.lhs.getEnd(), sourceVersion.rhs, NoneShardSpec.instance());
}

String identifierPrefix = org.apache.commons.lang.StringUtils.getCommonPrefix(identifiers) + "%";

Query<Map<String, Object>> sql = handle
.createQuery(
String.format(
Expand All @@ -343,7 +345,7 @@ private List<DataSegment> collectSourceSegments(
)
)
.bind(0, dataSource)
.bind(1, org.apache.commons.lang.StringUtils.getCommonPrefix(identifiers));
.bind(1, identifierPrefix);

index = 0;

Expand All @@ -352,6 +354,7 @@ private List<DataSegment> collectSourceSegments(
}

final List<DataSegment> results = new ArrayList<>();
int falsePositiveCount = 0;

try (final ResultIterator<byte[]> dbSegments = sql
.map(ByteArrayMapper.FIRST)
Expand All @@ -367,10 +370,16 @@ private List<DataSegment> collectSourceSegments(

if (sourceVersions.contains(new Pair<>(segment.getInterval(), segment.getVersion()))) {
results.add(segment);
} else {
falsePositiveCount++;
}
}
}

log.debug("Collecting corresponding source segments for segment allocation for [%s], result is [%d] segments and " +
"[%d] false positives (identifier prefix [%s]).", sourceVersions, results.size(), falsePositiveCount,
identifierPrefix);

return results;
}

Expand Down

0 comments on commit 7e4c709

Please sign in to comment.