jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1440373 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: JcrImporter.java SegmentReader.java SegmentWriter.java
Date Wed, 30 Jan 2013 12:40:01 GMT
Author: jukka
Date: Wed Jan 30 12:40:01 2013
New Revision: 1440373

URL: http://svn.apache.org/viewvc?rev=1440373&view=rev
Log:
OAK-593: Segment-based MK

Start working on a JCR-to-segments importer to better benchmark with existing content

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java?rev=1440373&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
Wed Jan 30 12:40:01 2013
@@ -0,0 +1,61 @@
+/*
+ * 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.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class JcrImporter {
+
+    private final SegmentWriter writer;
+
+    public JcrImporter(SegmentWriter writer) {
+        this.writer = writer;
+    }
+
+    public RecordId writeValue(Value value) throws RepositoryException {
+        if (value.getType() == PropertyType.BINARY) {
+            Binary binary = value.getBinary();
+            try {
+                return writer.writeStream(binary.getStream());
+            } catch (IOException e) {
+                throw new RepositoryException(
+                        "Can not read a binary stream from the repository", e);
+            } finally {
+                binary.dispose();
+            }
+        } else {
+            return writer.writeString(value.getString());
+        }
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java?rev=1440373&r1=1440372&r2=1440373&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
Wed Jan 30 12:40:01 2013
@@ -16,8 +16,14 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import java.io.InputStream;
+
 public interface SegmentReader {
 
     String readString(RecordId recordId);
 
+    InputStream readStream(RecordId recordId);
+
+    void readBytes(RecordId recordId, byte[] bytes, int offset, int length);
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java?rev=1440373&r1=1440372&r2=1440373&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
Wed Jan 30 12:40:01 2013
@@ -16,8 +16,15 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import java.io.IOException;
+import java.io.InputStream;
+
 public interface SegmentWriter {
 
     RecordId writeString(String string);
 
+    RecordId writeStream(InputStream stream) throws IOException;
+
+    RecordId writeBytes(byte[] bytes, int offset, int length);
+
 }



Mime
View raw message