jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1445641 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: NodeTemplate.java PropertyTemplate.java
Date Wed, 13 Feb 2013 14:56:25 GMT
Author: jukka
Date: Wed Feb 13 14:56:25 2013
New Revision: 1445641

URL: http://svn.apache.org/r1445641
Log:
OAK-593: Segment-based MK

Start working the template feature

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/NodeTemplate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/NodeTemplate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/NodeTemplate.java?rev=1445641&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/NodeTemplate.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/NodeTemplate.java
Wed Feb 13 14:56:25 2013
@@ -0,0 +1,84 @@
+/*
+ * 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.segment;
+
+import java.util.Map;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+
+class NodeTemplate {
+
+    private final String ZERO_CHILD_NODES = null;
+
+    private final String MANY_CHILD_NODES = "";
+
+    private final Map<String, PropertyTemplate> properties;
+
+    private final String nodeName;
+
+    NodeTemplate(NodeState state) {
+        ImmutableMap.Builder<String, PropertyTemplate> builder =
+                ImmutableMap.builder();
+        for (PropertyState property : state.getProperties()) {
+            builder.put(property.getName(), new PropertyTemplate(property));
+        }
+        properties = builder.build();
+
+        long count = state.getChildNodeCount();
+        if (count == 0) {
+            nodeName = ZERO_CHILD_NODES;
+        } else if (count == 1) {
+            nodeName = state.getChildNodeNames().iterator().next();
+        } else {
+            nodeName = MANY_CHILD_NODES;
+        }
+    }
+
+    public int getPropertyCount() {
+        return properties.size();
+    }
+
+    //------------------------------------------------------------< Object >--
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        } else if (object instanceof NodeTemplate) {
+            NodeTemplate that = (NodeTemplate) object;
+            return properties.equals(that.properties)
+                    && Objects.equal(nodeName, that.nodeName);
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(properties, nodeName);
+    }
+
+    @Override
+    public String toString() {
+        return properties.values() + " : " + nodeName;
+    }
+
+}

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java?rev=1445641&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java
Wed Feb 13 14:56:25 2013
@@ -0,0 +1,75 @@
+/*
+ * 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.segment;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+
+class PropertyTemplate implements Comparable<PropertyTemplate> {
+
+    private final String name;
+
+    private final Type<?> type;
+
+    PropertyTemplate(PropertyState state) {
+        checkNotNull(state);
+        this.name = state.getName();
+        this.type = state.getType();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Type<?> getType() {
+        return type;
+    }
+
+    //--------------------------------------------------------< Comparable >--
+
+    @Override
+    public int compareTo(PropertyTemplate template) {
+        return name.compareTo(checkNotNull(template).name);
+    }
+
+    //------------------------------------------------------------< Object >--
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        } else if (object instanceof PropertyTemplate) {
+            PropertyTemplate that = (PropertyTemplate) object;
+            return name.equals(that.name) && type.equals(that.type); 
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode() * 37 + type.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return name + "(" + type + ")";
+    }
+
+}
\ No newline at end of file



Mime
View raw message