Initial commit for the new platform work. This commit only contains working shard server logic and two primitive command implementations. DocumentCount and DocumentCountAggregator.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/94d579dd Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/94d579dd Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/94d579dd Branch: refs/heads/master Commit: 94d579ddef3a9e9c4e0a69d53f7f3167e1883595 Parents: f9d8e40 Author: Aaron McCurry <[email protected]> Authored: Wed Aug 27 09:00:31 2014 -0400 Committer: Aaron McCurry <[email protected]> Committed: Wed Aug 27 09:00:31 2014 -0400 ---------------------------------------------------------------------- .../org/apache/blur/manager/command/Args.java | 42 + .../blur/manager/command/CommandManager.java | 140 + .../apache/blur/manager/command/Response.java | 52 + .../command/primitive/DocumentCount.java | 37 + .../primitive/DocumentCountAggregator.java | 40 + .../command/primitive/PrimitiveCommand.java | 35 + .../primitive/PrimitiveCommandAggregator.java | 27 + .../manager/command/primitive/ReadCommand.java | 37 + .../command/primitive/ReadWriteCommand.java | 38 + .../apache/blur/server/FilteredBlurServer.java | 7 + .../blur/thrift/BlurControllerServer.java | 9 +- .../org/apache/blur/thrift/BlurShardServer.java | 82 + .../blur/thrift/ThriftBlurShardServer.java | 10 +- .../apache/blur/thrift/generated/Arguments.java | 470 +++ .../org/apache/blur/thrift/generated/Blur.java | 3040 ++++++++++++------ .../apache/blur/thrift/generated/Response.java | 418 +++ .../blur/thrift/generated/SafeClientGen.java | 927 +----- .../org/apache/blur/thrift/generated/Value.java | 794 +++++ .../apache/blur/thrift/util/CommandExample.java | 33 + .../src/main/scripts/interface/Blur.thrift | 24 + .../main/scripts/interface/gen-html/Blur.html | 33 +- .../main/scripts/interface/gen-html/index.html | 6 +- .../apache/blur/thrift/generated/Arguments.java | 470 +++ .../org/apache/blur/thrift/generated/Blur.java | 3040 ++++++++++++------ .../apache/blur/thrift/generated/Response.java | 418 +++ .../org/apache/blur/thrift/generated/Value.java | 794 +++++ .../src/main/scripts/interface/gen-js/Blur.js | 864 +++-- .../main/scripts/interface/gen-js/Blur_types.js | 364 +++ .../scripts/interface/gen-perl/Blur/Blur.pm | 699 ++-- .../scripts/interface/gen-perl/Blur/Types.pm | 380 +++ .../src/main/scripts/interface/gen-rb/blur.rb | 65 + .../main/scripts/interface/gen-rb/blur_types.rb | 116 + docs/Blur.html | 34 +- 33 files changed, 10134 insertions(+), 3411 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/Args.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/Args.java b/blur-core/src/main/java/org/apache/blur/manager/command/Args.java new file mode 100644 index 0000000..96dfee6 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/Args.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command; + +import java.util.HashMap; +import java.util.Map; + +public class Args { + + private Map<String, Object> _values = new HashMap<String, Object>(); + + @SuppressWarnings("unchecked") + public <T> T get(String name) { + return (T) _values.get(name); + } + + public <T> T get(String name, T defaultValue) { + T t = get(name); + if (t == null) { + return defaultValue; + } + return t; + } + + public <T> void set(String name, T value) { + _values.put(name, value); + } +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/CommandManager.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/CommandManager.java b/blur-core/src/main/java/org/apache/blur/manager/command/CommandManager.java new file mode 100644 index 0000000..2247599 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/CommandManager.java @@ -0,0 +1,140 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command; + +import java.io.Closeable; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import org.apache.blur.concurrent.Executors; +import org.apache.blur.manager.IndexServer; +import org.apache.blur.manager.command.primitive.DocumentCount; +import org.apache.blur.manager.command.primitive.DocumentCountAggregator; +import org.apache.blur.manager.command.primitive.PrimitiveCommand; +import org.apache.blur.manager.command.primitive.PrimitiveCommandAggregator; +import org.apache.blur.manager.command.primitive.ReadCommand; +import org.apache.blur.manager.command.primitive.ReadWriteCommand; +import org.apache.blur.manager.writer.BlurIndex; +import org.apache.blur.server.IndexSearcherClosable; + +public class CommandManager implements Closeable { + + private final IndexServer _indexServer; + private final ExecutorService _executorService; + private final Map<String, PrimitiveCommand> _command = new ConcurrentHashMap<String, PrimitiveCommand>(); + + public CommandManager(IndexServer indexServer, int threadCount) throws IOException { + register(DocumentCount.class); + register(DocumentCountAggregator.class); + _indexServer = indexServer; + _executorService = Executors.newThreadPool("command-", threadCount); + } + + private void register(Class<? extends PrimitiveCommand> commandClass) throws IOException { + try { + PrimitiveCommand command = commandClass.newInstance(); + _command.put(command.getName(), command); + } catch (InstantiationException e) { + throw new IOException(e); + } catch (IllegalAccessException e) { + throw new IOException(e); + } + } + + public Response execute(String table, String commandName, Args args) throws IOException { + PrimitiveCommand command = getCommandObject(commandName); + if (command == null) { + throw new IOException("Command with name [" + commandName + "] not found."); + } + if (command instanceof ReadCommand) { + return toResponse(executeReadCommand((ReadCommand<?>) command, table, args), command); + } else if (command instanceof ReadWriteCommand) { + return toResponse(executeReadWriteCommand((ReadWriteCommand<?>) command, table, args), command); + } + throw new IOException("Command type of [" + command.getClass() + "] not supported."); + } + + @SuppressWarnings("unchecked") + private Response toResponse(Map<String, Object> results, PrimitiveCommand command) throws IOException { + if (command instanceof PrimitiveCommandAggregator) { + PrimitiveCommandAggregator<Object, Object> primitiveCommandAggregator = (PrimitiveCommandAggregator<Object, Object>) command; + Iterator<Entry<String, Object>> iterator = results.entrySet().iterator(); + Object object = primitiveCommandAggregator.aggregate(iterator); + return Response.createNewAggregateResponse(object); + } + return Response.createNewResponse(results); + } + + private Map<String, Object> executeReadWriteCommand(ReadWriteCommand<?> command, String table, Args args) { + return null; + } + + private Map<String, Object> executeReadCommand(ReadCommand<?> command, String table, final Args args) + throws IOException { + Map<String, BlurIndex> indexes = _indexServer.getIndexes(table); + Map<String, Future<?>> futureMap = new HashMap<String, Future<?>>(); + for (Entry<String, BlurIndex> e : indexes.entrySet()) { + String shardId = e.getKey(); + final BlurIndex blurIndex = e.getValue(); + final ReadCommand<?> readCommand = command.clone(); + Future<Object> future = _executorService.submit(new Callable<Object>() { + @Override + public Object call() throws Exception { + IndexSearcherClosable searcher = blurIndex.getIndexSearcher(); + try { + return readCommand.execute(args, searcher); + } finally { + searcher.close(); + } + } + }); + futureMap.put(shardId, future); + } + Map<String, Object> resultMap = new HashMap<String, Object>(); + for (Entry<String, Future<?>> e : futureMap.entrySet()) { + Future<?> future = e.getValue(); + Object object; + try { + object = future.get(); + } catch (InterruptedException ex) { + throw new IOException(ex); + } catch (ExecutionException ex) { + throw new IOException(ex.getCause()); + } + resultMap.put(e.getKey(), object); + } + return resultMap; + } + + private PrimitiveCommand getCommandObject(String commandName) { + return _command.get(commandName); + } + + @Override + public void close() throws IOException { + _executorService.shutdownNow(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/Response.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/Response.java b/blur-core/src/main/java/org/apache/blur/manager/command/Response.java new file mode 100644 index 0000000..f5bce02 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/Response.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command; + +import java.util.Map; + +public class Response { + + private final Map<String, Object> _shardResults; + private final Object _serverResult; + private final boolean _aggregatedResults; + + private Response(Map<String, Object> shardResults, Object serverResult, boolean aggregatedResults) { + _shardResults = shardResults; + _serverResult = serverResult; + _aggregatedResults = aggregatedResults; + } + + public boolean isAggregatedResults() { + return _aggregatedResults; + } + + public Map<String, Object> getShardResults() { + return _shardResults; + } + + public Object getServerResult() { + return _serverResult; + } + + public static Response createNewAggregateResponse(Object object) { + return new Response(null, object, true); + } + + public static Response createNewResponse(Map<String, Object> map) { + return new Response(map, null, false); + } +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCount.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCount.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCount.java new file mode 100644 index 0000000..4a6de04 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCount.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.IOException; + +import org.apache.blur.manager.command.Args; +import org.apache.lucene.search.IndexSearcher; + +@SuppressWarnings("serial") +public class DocumentCount extends ReadCommand<Integer> { + + @Override + public String getName() { + return "docCount"; + } + + @Override + public Integer execute(Args args, IndexSearcher searcher) throws IOException { + return (int) searcher.getIndexReader().numDocs(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCountAggregator.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCountAggregator.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCountAggregator.java new file mode 100644 index 0000000..9187421 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/DocumentCountAggregator.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; + +@SuppressWarnings("serial") +public class DocumentCountAggregator extends DocumentCount implements PrimitiveCommandAggregator<Integer, Long> { + + @Override + public String getName() { + return "docCountAggregate"; + } + + @Override + public Long aggregate(Iterator<Entry<String, Integer>> it) throws IOException { + long total = 0; + while (it.hasNext()) { + total += it.next().getValue(); + } + return total; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommand.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommand.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommand.java new file mode 100644 index 0000000..b9c5757 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommand.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public abstract class PrimitiveCommand implements Serializable, Cloneable { + + public abstract String getName(); + + @Override + public PrimitiveCommand clone() { + try { + return (PrimitiveCommand) super.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommandAggregator.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommandAggregator.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommandAggregator.java new file mode 100644 index 0000000..3182cc8 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/PrimitiveCommandAggregator.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; + +public interface PrimitiveCommandAggregator<IN, OUT> { + + OUT aggregate(Iterator<Entry<String, IN>> it) throws IOException; + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadCommand.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadCommand.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadCommand.java new file mode 100644 index 0000000..6f436e5 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadCommand.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.IOException; + +import org.apache.blur.manager.command.Args; +import org.apache.lucene.search.IndexSearcher; + +@SuppressWarnings("serial") +public abstract class ReadCommand<T> extends PrimitiveCommand { + + @SuppressWarnings("unchecked") + @Override + public ReadCommand<T> clone() { + return (ReadCommand<T>) super.clone(); + } + + public abstract String getName(); + + public abstract T execute(Args args, IndexSearcher searcher) throws IOException; + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadWriteCommand.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadWriteCommand.java b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadWriteCommand.java new file mode 100644 index 0000000..129fc94 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/manager/command/primitive/ReadWriteCommand.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.manager.command.primitive; + +import java.io.IOException; + +import org.apache.blur.manager.command.Args; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.search.IndexSearcher; + +@SuppressWarnings("serial") +public abstract class ReadWriteCommand<T> extends PrimitiveCommand { + + @SuppressWarnings("unchecked") + @Override + public ReadWriteCommand<T> clone() { + return (ReadWriteCommand<T>) super.clone(); + } + + public abstract String getName(); + + public abstract T execute(Args args, IndexSearcher searcher, IndexWriter writer) throws IOException; + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java index 53e59fe..f1ee57c 100644 --- a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java +++ b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java @@ -22,6 +22,7 @@ import java.util.Set; import org.apache.blur.BlurConfiguration; import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.generated.Arguments; import org.apache.blur.thrift.generated.Blur.Iface; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.BlurQuery; @@ -32,6 +33,7 @@ import org.apache.blur.thrift.generated.FetchResult; import org.apache.blur.thrift.generated.Level; import org.apache.blur.thrift.generated.Metric; import org.apache.blur.thrift.generated.Query; +import org.apache.blur.thrift.generated.Response; import org.apache.blur.thrift.generated.RowMutation; import org.apache.blur.thrift.generated.Schema; import org.apache.blur.thrift.generated.Selector; @@ -244,4 +246,9 @@ public class FilteredBlurServer implements Iface { _iface.enqueueMutateBatch(mutations); } + @Override + public Response execute(String table, String commandName, Arguments arguments) throws BlurException, TException { + return _iface.execute(table, commandName, arguments); + } + } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java index e378c44..5fda94a 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java @@ -70,6 +70,7 @@ import org.apache.blur.thirdparty.thrift_0_9_0.transport.TFramedTransport; import org.apache.blur.thirdparty.thrift_0_9_0.transport.TSocket; import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport; import org.apache.blur.thrift.commands.BlurCommand; +import org.apache.blur.thrift.generated.Arguments; import org.apache.blur.thrift.generated.Blur.Client; import org.apache.blur.thrift.generated.Blur.Iface; import org.apache.blur.thrift.generated.BlurException; @@ -82,6 +83,7 @@ import org.apache.blur.thrift.generated.ErrorType; import org.apache.blur.thrift.generated.FetchResult; import org.apache.blur.thrift.generated.HighlightOptions; import org.apache.blur.thrift.generated.Query; +import org.apache.blur.thrift.generated.Response; import org.apache.blur.thrift.generated.RowMutation; import org.apache.blur.thrift.generated.Schema; import org.apache.blur.thrift.generated.Selector; @@ -99,9 +101,9 @@ import org.apache.blur.utils.ForkJoin; import org.apache.blur.utils.ForkJoin.Merger; import org.apache.blur.utils.ForkJoin.ParallelCall; import org.apache.blur.zookeeper.WatchChildren; -import org.apache.blur.zookeeper.ZookeeperPathConstants; import org.apache.blur.zookeeper.WatchChildren.OnChange; import org.apache.blur.zookeeper.WatchNodeExistance; +import org.apache.blur.zookeeper.ZookeeperPathConstants; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.ZooDefs.Ids; @@ -1492,4 +1494,9 @@ public class BlurControllerServer extends TableAdmin implements Iface { context.setTraceRequestId(requestId); } + @Override + public Response execute(String table, String commandName, Arguments arguments) throws BlurException, TException { + throw new BlurException("not implemented", null, ErrorType.UNKNOWN); + } + } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java index 3ccd577..afe50bd 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; @@ -36,10 +37,14 @@ import org.apache.blur.log.LogFactory; import org.apache.blur.manager.BlurQueryChecker; import org.apache.blur.manager.IndexManager; import org.apache.blur.manager.IndexServer; +import org.apache.blur.manager.command.Args; +import org.apache.blur.manager.command.CommandManager; +import org.apache.blur.manager.command.Response; import org.apache.blur.manager.results.BlurResultIterable; import org.apache.blur.manager.writer.BlurIndex; import org.apache.blur.server.ShardServerContext; import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.generated.Arguments; import org.apache.blur.thrift.generated.Blur.Iface; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.BlurQuery; @@ -55,6 +60,7 @@ import org.apache.blur.thrift.generated.ShardState; import org.apache.blur.thrift.generated.Status; import org.apache.blur.thrift.generated.TableStats; import org.apache.blur.thrift.generated.User; +import org.apache.blur.thrift.generated.Value; import org.apache.blur.utils.BlurConstants; import org.apache.blur.utils.BlurUtil; import org.apache.blur.utils.QueryCache; @@ -75,6 +81,7 @@ public class BlurShardServer extends TableAdmin implements Iface { private ExecutorService _dataFetch; private String _cluster = BlurConstants.BLUR_CLUSTER; private int _dataFetchThreadCount = 32; + private CommandManager _commandManager; public void init() throws BlurException { _queryCache = new QueryCache("shard-cache", _maxQueryCacheElements, _maxTimeToLive); @@ -583,4 +590,79 @@ public class BlurShardServer extends TableAdmin implements Iface { return false; } + @Override + public org.apache.blur.thrift.generated.Response execute(String table, String commandName, Arguments arguments) + throws BlurException, TException { + try { + Response response = _commandManager.execute(table, commandName, convert(arguments)); + return convert(response); + } catch (Exception e) { + LOG.error("Unknown error while trying to execute command [{0}] for table [{1}]", e, commandName, table); + if (e instanceof BlurException) { + throw (BlurException) e; + } + throw new BException(e.getMessage(), e); + } + } + + private org.apache.blur.thrift.generated.Response convert(Response response) throws BlurException { + org.apache.blur.thrift.generated.Response converted = new org.apache.blur.thrift.generated.Response(); + if (response.isAggregatedResults()) { + converted.setValue(toValue(response.getServerResult())); + } else { + converted.setShardToValue(convert(response.getShardResults())); + } + return converted; + } + + private Map<String, Value> convert(Map<String, Object> map) throws BlurException { + Map<String, Value> result = new HashMap<String, Value>(); + for (Entry<String, Object> e : map.entrySet()) { + result.put(e.getKey(), toValue(e.getValue())); + } + return result; + } + + private Value toValue(Object o) throws BlurException { + Value value = new Value(); + if (o == null) { + value.setNullValue(true); + return value; + } + if (o instanceof Long) { + value.setLongValue((Long) o); + return value; + } else if (o instanceof String) { + value.setStringValue((String) o); + return value; + } else if (o instanceof Integer) { + value.setIntValue((Integer) o); + return value; + } + throw new BException("Object [{0}] not supported.", o); + } + + private Args convert(Arguments arguments) { + if (arguments == null) { + return null; + } + Args args = new Args(); + Map<String, Value> values = arguments.getValues(); + Set<Entry<String, Value>> entrySet = values.entrySet(); + for (Entry<String, Value> e : entrySet) { + args.set(e.getKey(), toObject(e.getValue())); + } + return args; + } + + private Object toObject(Value value) { + if (value.getNullValue()) { + return null; + } + return value.getFieldValue(); + } + + public void setCommandManager(CommandManager commandManager) { + _commandManager = commandManager; + } } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java index 195eb5e..754a70e 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java @@ -45,8 +45,8 @@ import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_THRIFT_MAX_READ_BUF import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_THRIFT_SELECTOR_THREADS; import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_WARMUP_DISABLED; import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_WARMUP_THREAD_COUNT; -import static org.apache.blur.utils.BlurConstants.BLUR_THRIFT_MAX_FRAME_SIZE; import static org.apache.blur.utils.BlurConstants.BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE; +import static org.apache.blur.utils.BlurConstants.BLUR_THRIFT_MAX_FRAME_SIZE; import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_CONNECTION; import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_TIMEOUT; import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_TIMEOUT_DEFAULT; @@ -70,6 +70,7 @@ import org.apache.blur.manager.BlurQueryChecker; import org.apache.blur.manager.DefaultBlurFilterCache; import org.apache.blur.manager.IndexManager; import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus; +import org.apache.blur.manager.command.CommandManager; import org.apache.blur.manager.indexserver.BlurIndexWarmup; import org.apache.blur.manager.indexserver.BlurServerShutDown; import org.apache.blur.manager.indexserver.BlurServerShutDown.BlurShutdown; @@ -228,7 +229,10 @@ public class ThriftBlurShardServer extends ThriftServer { fetchCount, indexManagerThreadCount, mutateThreadCount, statusCleanupTimerDelay, facetThreadCount, deepPagingCache); + final CommandManager commandManager = new CommandManager(indexServer, 16); + final BlurShardServer shardServer = new BlurShardServer(); + shardServer.setCommandManager(commandManager); shardServer.setIndexServer(indexServer); shardServer.setIndexManager(indexManager); shardServer.setZookeeper(zooKeeper); @@ -293,8 +297,8 @@ public class ThriftBlurShardServer extends ThriftServer { @Override public void shutdown() { ThreadWatcher threadWatcher = ThreadWatcher.instance(); - quietClose(traceStorage, refresher, server, shardServer, indexManager, indexServer, threadWatcher, - clusterStatus, zooKeeper, httpServer); + quietClose(commandManager, traceStorage, refresher, server, shardServer, indexManager, indexServer, + threadWatcher, clusterStatus, zooKeeper, httpServer); } }; server.setShutdown(shutdown); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/94d579dd/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Arguments.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Arguments.java b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Arguments.java new file mode 100644 index 0000000..68d6916 --- /dev/null +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Arguments.java @@ -0,0 +1,470 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.blur.thrift.generated; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.IScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.SchemeFactory; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.StandardScheme; + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.TupleScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TTupleProtocol; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolException; +import org.apache.blur.thirdparty.thrift_0_9_0.EncodingUtils; +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +public class Arguments implements org.apache.blur.thirdparty.thrift_0_9_0.TBase<Arguments, Arguments._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct STRUCT_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct("Arguments"); + + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField VALUES_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("values", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, (short)1); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ArgumentsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ArgumentsTupleSchemeFactory()); + } + + public Map<String,Value> values; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.blur.thirdparty.thrift_0_9_0.TFieldIdEnum { + VALUES((short)1, "values"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // VALUES + return VALUES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.VALUES, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("values", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.MapMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING), + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Value.class)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData.addStructMetaDataMap(Arguments.class, metaDataMap); + } + + public Arguments() { + } + + public Arguments( + Map<String,Value> values) + { + this(); + this.values = values; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public Arguments(Arguments other) { + if (other.isSetValues()) { + Map<String,Value> __this__values = new HashMap<String,Value>(); + for (Map.Entry<String, Value> other_element : other.values.entrySet()) { + + String other_element_key = other_element.getKey(); + Value other_element_value = other_element.getValue(); + + String __this__values_copy_key = other_element_key; + + Value __this__values_copy_value = new Value(other_element_value); + + __this__values.put(__this__values_copy_key, __this__values_copy_value); + } + this.values = __this__values; + } + } + + public Arguments deepCopy() { + return new Arguments(this); + } + + @Override + public void clear() { + this.values = null; + } + + public int getValuesSize() { + return (this.values == null) ? 0 : this.values.size(); + } + + public void putToValues(String key, Value val) { + if (this.values == null) { + this.values = new HashMap<String,Value>(); + } + this.values.put(key, val); + } + + public Map<String,Value> getValues() { + return this.values; + } + + public Arguments setValues(Map<String,Value> values) { + this.values = values; + return this; + } + + public void unsetValues() { + this.values = null; + } + + /** Returns true if field values is set (has been assigned a value) and false otherwise */ + public boolean isSetValues() { + return this.values != null; + } + + public void setValuesIsSet(boolean value) { + if (!value) { + this.values = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case VALUES: + if (value == null) { + unsetValues(); + } else { + setValues((Map<String,Value>)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case VALUES: + return getValues(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case VALUES: + return isSetValues(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Arguments) + return this.equals((Arguments)that); + return false; + } + + public boolean equals(Arguments that) { + if (that == null) + return false; + + boolean this_present_values = true && this.isSetValues(); + boolean that_present_values = true && that.isSetValues(); + if (this_present_values || that_present_values) { + if (!(this_present_values && that_present_values)) + return false; + if (!this.values.equals(that.values)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(Arguments other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + Arguments typedOther = (Arguments)other; + + lastComparison = Boolean.valueOf(isSetValues()).compareTo(typedOther.isSetValues()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValues()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.values, typedOther.values); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Arguments("); + boolean first = true; + + sb.append("values:"); + if (this.values == null) { + sb.append("null"); + } else { + sb.append(this.values); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(out))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(in))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ArgumentsStandardSchemeFactory implements SchemeFactory { + public ArgumentsStandardScheme getScheme() { + return new ArgumentsStandardScheme(); + } + } + + private static class ArgumentsStandardScheme extends StandardScheme<Arguments> { + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot, Arguments struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // VALUES + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map242 = iprot.readMapBegin(); + struct.values = new HashMap<String,Value>(2*_map242.size); + for (int _i243 = 0; _i243 < _map242.size; ++_i243) + { + String _key244; // optional + Value _val245; // required + _key244 = iprot.readString(); + _val245 = new Value(); + _val245.read(iprot); + struct.values.put(_key244, _val245); + } + iprot.readMapEnd(); + } + struct.setValuesIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot, Arguments struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.values != null) { + oprot.writeFieldBegin(VALUES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, struct.values.size())); + for (Map.Entry<String, Value> _iter246 : struct.values.entrySet()) + { + oprot.writeString(_iter246.getKey()); + _iter246.getValue().write(oprot); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ArgumentsTupleSchemeFactory implements SchemeFactory { + public ArgumentsTupleScheme getScheme() { + return new ArgumentsTupleScheme(); + } + } + + private static class ArgumentsTupleScheme extends TupleScheme<Arguments> { + + @Override + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, Arguments struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetValues()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetValues()) { + { + oprot.writeI32(struct.values.size()); + for (Map.Entry<String, Value> _iter247 : struct.values.entrySet()) + { + oprot.writeString(_iter247.getKey()); + _iter247.getValue().write(oprot); + } + } + } + } + + @Override + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, Arguments struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map248 = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, iprot.readI32()); + struct.values = new HashMap<String,Value>(2*_map248.size); + for (int _i249 = 0; _i249 < _map248.size; ++_i249) + { + String _key250; // optional + Value _val251; // required + _key250 = iprot.readString(); + _val251 = new Value(); + _val251.read(iprot); + struct.values.put(_key250, _val251); + } + } + struct.setValuesIsSet(true); + } + } + } + +} +
