You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2013/08/08 16:33:33 UTC
svn commit: r1511807 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate:
./ AggregateIndex.java AggregateIndexProvider.java
Author: thomasm
Date: Thu Aug 8 14:33:32 2013
New Revision: 1511807
URL: http://svn.apache.org/r1511807
Log:
OAK-828 Lucene support for index aggregates (dummy implementation)
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndex.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndexProvider.java
Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndex.java?rev=1511807&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndex.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndex.java Thu Aug 8 14:33:32 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.jackrabbit.oak.plugins.index.aggregate;
+
+import org.apache.jackrabbit.oak.spi.query.Cursor;
+import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * A virtual full-text that can aggregate nodes based on aggregate definitions.
+ * Internally, it uses another full-text index.
+ */
+public class AggregateIndex implements FulltextQueryIndex {
+
+ private final FulltextQueryIndex baseIndex;
+
+ public AggregateIndex(FulltextQueryIndex baseIndex) {
+ this.baseIndex = baseIndex;
+ }
+
+ @Override
+ public double getCost(Filter filter, NodeState rootState) {
+ // TODO dummy implementation
+ if (baseIndex == null) {
+ return Double.POSITIVE_INFINITY;
+ }
+ return baseIndex.getCost(filter, rootState);
+ }
+
+ @Override
+ public Cursor query(Filter filter, NodeState rootState) {
+ // TODO dummy implementation
+ return baseIndex.query(filter, rootState);
+ }
+
+ @Override
+ public String getPlan(Filter filter, NodeState rootState) {
+ // TODO dummy implementation
+ if (baseIndex == null) {
+ return "no plan";
+ }
+ return "aggregate " + baseIndex.getPlan(filter, rootState);
+ }
+
+ @Override
+ public String getIndexName() {
+ // TODO dummy implementation
+ if (baseIndex == null) {
+ return "aggregat";
+ }
+ return "aggregate." + baseIndex.getIndexName();
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndexProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndexProvider.java?rev=1511807&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndexProvider.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/AggregateIndexProvider.java Thu Aug 8 14:33:32 2013
@@ -0,0 +1,60 @@
+/*
+ * 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.jackrabbit.oak.plugins.index.aggregate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.spi.query.QueryIndex;
+import org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * A provider for aggregate indexes. It wraps all full-text query indexes.
+ */
+public class AggregateIndexProvider implements QueryIndexProvider {
+
+ private final QueryIndexProvider baseProvider;
+
+ AggregateIndexProvider(QueryIndexProvider baseProvider) {
+ this.baseProvider = baseProvider;
+ }
+
+ @Nonnull
+ public static QueryIndexProvider wrap(
+ @Nonnull QueryIndexProvider baseProvider) {
+ return new AggregateIndexProvider(baseProvider);
+ }
+
+ @Override @Nonnull
+ public List<? extends QueryIndex> getQueryIndexes(NodeState state) {
+ List<? extends QueryIndex> list = baseProvider.getQueryIndexes(state);
+ ArrayList<AggregateIndex> aggregateList = new ArrayList<AggregateIndex>();
+ for (int i = 0; i < list.size(); i++) {
+ QueryIndex index = list.get(i);
+ if (index instanceof FulltextQueryIndex) {
+ aggregateList
+ .add(new AggregateIndex((FulltextQueryIndex) index));
+ }
+ }
+ return aggregateList;
+ }
+
+}