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 al...@apache.org on 2013/05/16 20:55:46 UTC
svn commit: r1483508 - in
/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation:
AggregatedState.java NodeAggregator.java
Author: alexparvulescu
Date: Thu May 16 18:55:46 2013
New Revision: 1483508
URL: http://svn.apache.org/r1483508
Log:
OAK-828 Lucene support for index aggregates
- basic (hardcoded) file aggregation support
Added:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java (with props)
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java (with props)
Added: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java?rev=1483508&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java (added)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java Thu May 16 18:55:46 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.lucene.aggregation;
+
+import static org.apache.jackrabbit.JcrConstants.JCR_PATH;
+import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+import com.google.common.collect.ImmutableSet;
+
+public class AggregatedState {
+
+ private final String name;
+
+ private final NodeState state;
+
+ private final Set<String> included;
+
+ private static final Set<String> blacklist = ImmutableSet.of(JCR_PATH,
+ JCR_UUID);
+
+ public AggregatedState(String name, NodeState state, Set<String> included) {
+ this.name = name;
+ this.state = state;
+ if (included == null) {
+ this.included = ImmutableSet.of();
+ } else {
+ this.included = included;
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public NodeState getState() {
+ return state;
+ }
+
+ private boolean include(String name) {
+ if (included.contains(name)) {
+ return true;
+ }
+ if (blacklist.contains(name)) {
+ return false;
+ }
+ return included.isEmpty();
+ }
+
+ public Iterable<? extends PropertyState> getProperties() {
+ if (included == null || included.isEmpty()) {
+ return state.getProperties();
+ }
+
+ List<PropertyState> props = new ArrayList<PropertyState>();
+ for (PropertyState property : state.getProperties()) {
+ String pname = property.getName();
+ if (include(pname)) {
+ props.add(property);
+ }
+ }
+ return props;
+ }
+
+ public NodeState get() {
+ return state;
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/AggregatedState.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java?rev=1483508&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java (added)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java Thu May 16 18:55:46 2013
@@ -0,0 +1,51 @@
+/*
+ * 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.lucene.aggregation;
+
+import static org.apache.jackrabbit.JcrConstants.JCR_CONTENT;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FILE;
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getString;
+
+import java.util.List;
+
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+import com.google.common.collect.ImmutableList;
+
+public class NodeAggregator {
+
+ private final NodeBuilder index;
+
+ public NodeAggregator(NodeBuilder index) {
+ this.index = index;
+ }
+
+ public List<AggregatedState> getAggregates(NodeState state) {
+ // FIXME remove hardcoded aggregates
+ String type = getString(state, JCR_PRIMARYTYPE);
+
+ if (NT_FILE.equals(type)) {
+ // include jcr:content node
+ return ImmutableList.of(new AggregatedState(JCR_CONTENT, state
+ .getChildNode(JCR_CONTENT), null));
+ }
+
+ return ImmutableList.of();
+ }
+}
Propchange: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/aggregation/NodeAggregator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain