jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1152152 - in /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: RepositoryServiceImpl.java util/Values.java
Date Fri, 29 Jul 2011 09:42:27 GMT
Author: mduerig
Date: Fri Jul 29 09:42:27 2011
New Revision: 1152152

URL: http://svn.apache.org/viewvc?rev=1152152&view=rev
Log:
spi2microkernel (WIP)
- lower threshold for inlineing of binaries 

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1152152&r1=1152151&r2=1152152&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Fri Jul 29 09:42:27 2011
@@ -88,6 +88,8 @@ import static org.apache.jackrabbit.spi2
 import static org.apache.jackrabbit.spi2microkernel.util.Predicates.exists;
 
 public class RepositoryServiceImpl extends AbstractRepositoryService {
+    private static final long BINARY_VALUE_INLINE_THRESHOLD = 0x1000;
+
     static final Logger log = LoggerFactory.getLogger(RepositoryServiceImpl.class);
 
     private static final QNodeDefinition ROOT_NODE_DEFINITION = new QNodeDefinitionImpl(ROOT,
REP_ROOT, true, true,
@@ -508,6 +510,10 @@ public class RepositoryServiceImpl exten
 
     private final Function1<QValue, String> saveToDataStore = new Function1<QValue,
String>() {
         public String apply(QValue value) throws Exception {
+            if (value.getLength() < BINARY_VALUE_INLINE_THRESHOLD) {
+                return null;
+            }
+
             InputStream is = value.getStream();
             try {
                 return microKernel.write(is);

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java?rev=1152152&r1=1152151&r2=1152152&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
Fri Jul 29 09:42:27 2011
@@ -310,28 +310,23 @@ public final class Values {
                 return quoteAndEncode(type, JsonBuilder.escape(value.getString()));
 
             case BINARY:
-                if (value.getLength() > 0xffff) {
-                    try {
-                        String blobId = binaryHandler.apply(value);
-                        return quoteAndEncode(BLOB_REF_TYPE, blobId);
-                    }
-                    catch (RepositoryException e) {
-                        throw e;
-                    }
-                    catch (Exception e) {
-                        throw new RepositoryException(e.getMessage(), e);
-                    }
-                }
-                else {
-                    try {
+                try {
+                    String blobId = binaryHandler.apply(value);
+                    if (blobId == null) {
                         StringWriter sw = new StringWriter();
                         Base64.encode(value.getStream(), sw);
                         return quoteAndEncode(type, JsonBuilder.escape(sw.toString()));
                     }
-                    catch (IOException e) {
-                        throw new RepositoryException(e);
+                    else {
+                        return quoteAndEncode(BLOB_REF_TYPE, blobId);
                     }
                 }
+                catch (RepositoryException e) {
+                    throw e;
+                }
+                catch (Exception e) {
+                    throw new RepositoryException(e.getMessage(), e);
+                }
 
             case REFERENCE:
             case WEAKREFERENCE:



Mime
View raw message