From 3bfbcbe95c2ec64b9a5a2bdbe3f04fc63a8d907d Mon Sep 17 00:00:00 2001 From: Eric Tschetter Date: Fri, 28 Dec 2012 10:50:40 -0600 Subject: [PATCH] 1) Create DirectClientQuerySegmentWalker to make it a bit easier to embed and use DirectDruidClient as a client. --- .../http/DirectClientQuerySegmentWalker.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 client/src/main/java/com/metamx/druid/http/DirectClientQuerySegmentWalker.java diff --git a/client/src/main/java/com/metamx/druid/http/DirectClientQuerySegmentWalker.java b/client/src/main/java/com/metamx/druid/http/DirectClientQuerySegmentWalker.java new file mode 100644 index 00000000000..e1cac8a90c3 --- /dev/null +++ b/client/src/main/java/com/metamx/druid/http/DirectClientQuerySegmentWalker.java @@ -0,0 +1,63 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012 Metamarkets Group Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package com.metamx.druid.http; + +import com.metamx.druid.Query; +import com.metamx.druid.client.DirectDruidClient; +import com.metamx.druid.query.FinalizeResultsQueryRunner; +import com.metamx.druid.query.QueryRunner; +import com.metamx.druid.query.QueryToolChestWarehouse; +import com.metamx.druid.query.segment.QuerySegmentWalker; +import com.metamx.druid.query.segment.SegmentDescriptor; +import org.joda.time.Interval; + +/** + */ +public class DirectClientQuerySegmentWalker implements QuerySegmentWalker +{ + private final QueryToolChestWarehouse warehouse; + private final DirectDruidClient baseClient; + + public DirectClientQuerySegmentWalker( + QueryToolChestWarehouse warehouse, + DirectDruidClient baseClient + ) + { + this.warehouse = warehouse; + this.baseClient = baseClient; + } + + @Override + public QueryRunner getQueryRunnerForIntervals(Query query, Iterable intervals) + { + return makeRunner(query); + } + + @Override + public QueryRunner getQueryRunnerForSegments(Query query, Iterable specs) + { + return makeRunner(query); + } + + private FinalizeResultsQueryRunner makeRunner(final Query query) + { + return new FinalizeResultsQueryRunner(baseClient, warehouse.getToolChest(query)); + } +}