Repository: incubator-usergrid Updated Branches: refs/heads/USERGRID-528 [created] cee76da72
Initial commit. WIP overwrite Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fe1fa85c Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fe1fa85c Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fe1fa85c Branch: refs/heads/USERGRID-528 Commit: fe1fa85c36b5eb772c5ff03be816d71e1522793d Parents: 61c5f9c Author: Todd Nine <[email protected]> Authored: Thu Mar 19 09:47:43 2015 -0600 Committer: Todd Nine <[email protected]> Committed: Thu Mar 19 09:47:43 2015 -0600 ---------------------------------------------------------------------- .../io/execution/CommandExecution.java | 37 +++++++++++ .../corepersistence/io/read/Command.java | 38 ++++++++++++ .../corepersistence/io/read/CommandBuilder.java | 65 ++++++++++++++++++++ .../io/reduce/StreamReducer.java | 38 ++++++++++++ 4 files changed, 178 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe1fa85c/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/execution/CommandExecution.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/execution/CommandExecution.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/execution/CommandExecution.java new file mode 100644 index 0000000..0aaa764 --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/execution/CommandExecution.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.usergrid.corepersistence.io.execution; + + +import org.apache.usergrid.corepersistence.io.read.CommandBuilder; +import org.apache.usergrid.corepersistence.io.reduce.StreamReducer; + + +public interface CommandExecution { + + /** + * Invoke the commands, then feed them to the reducer to return a final output + * @param builder + * @param reducer + * @param <T> + * @return + */ + public <T> T invoke(CommandBuilder builder, StreamReducer<T> reducer); +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe1fa85c/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/Command.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/Command.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/Command.java new file mode 100644 index 0000000..4e3b0fc --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/Command.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.usergrid.corepersistence.io.read; + + +import org.apache.usergrid.persistence.model.entity.Id; + +import rx.Observable; + + +public interface Command<T> { + + + /** + * Process our input stream + * @param input + * @return + */ + public Observable<T> process( Observable<T> input ); + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe1fa85c/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/CommandBuilder.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/CommandBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/CommandBuilder.java new file mode 100644 index 0000000..119fc0e --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/read/CommandBuilder.java @@ -0,0 +1,65 @@ +/* + * 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.usergrid.corepersistence.io.read; + + +import java.util.ArrayList; +import java.util.List; + +import org.apache.usergrid.corepersistence.io.reduce.StreamReducer; +import org.apache.usergrid.persistence.model.entity.Id; + +import rx.Observable; +import rx.functions.Func1; + + +/** + * The builder to hold the list of traversal commands + */ +public class CommandBuilder { + + private final Id root; + private final List<Command<Id>> commandList; + + + public CommandBuilder( final Id root ) {this.root = root; + commandList = new ArrayList<>( ); + } + + public void addIntermediateCommand(final Command<Id> command){ + commandList.add( command ); + } + + + public <T> void addFinalCommand( final Command<T> command, final StreamReducer<T> reducer ) { + + Observable.just("foo").flatMap( new Func1<String, Observable<?>>() { + @Override + public Observable<?> call( final String s ) { + return null; + } + }; + } + + + public List<Command<Id>> getCommands(){ + return commandList; + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe1fa85c/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/reduce/StreamReducer.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/reduce/StreamReducer.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/reduce/StreamReducer.java new file mode 100644 index 0000000..ae84bd8 --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/io/reduce/StreamReducer.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.usergrid.corepersistence.io.reduce; + + +import org.apache.usergrid.corepersistence.io.read.Command; +import org.apache.usergrid.persistence.model.entity.Id; + +import rx.Observable; + + +public interface StreamReducer<T> { + + /** + * Reduce the result of our stream into a list of nodes + * + * @param candidates The candidate ids for loading + * @return + */ + public T reduce( Observable<Id> candidates ); +}
