Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.google.common.base.Throwables;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.util.concurrent.ListenableFuture;
Expand Down Expand Up @@ -59,7 +61,6 @@
import org.skife.jdbi.v2.util.ByteArrayMapper;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
Expand All @@ -76,6 +77,7 @@
@ManageLifecycle
public class SQLMetadataSegmentManager implements MetadataSegmentManager
{
private static final Interner<DataSegment> DATA_SEGMENT_INTERNER = Interners.newWeakInterner();
private static final EmittingLogger log = new EmittingLogger(SQLMetadataSegmentManager.class);


Expand Down Expand Up @@ -194,10 +196,10 @@ public VersionedIntervalTimeline<String, DataSegment> fold(
) throws SQLException
{
try {
DataSegment segment = jsonMapper.readValue(
final DataSegment segment = DATA_SEGMENT_INTERNER.intern(jsonMapper.readValue(
payload,
DataSegment.class
);
));

timeline.add(
segment.getInterval(),
Expand Down Expand Up @@ -464,7 +466,10 @@ public DataSegment map(int index, ResultSet r, StatementContext ctx)
throws SQLException
{
try {
return jsonMapper.readValue(r.getBytes("payload"), DataSegment.class);
return DATA_SEGMENT_INTERNER.intern(jsonMapper.readValue(
r.getBytes("payload"),
DataSegment.class
));
}
catch (IOException e) {
log.makeAlert(e, "Failed to read segment from db.");
Expand Down