stefan-egli commented on code in PR #1619:
URL: https://github.com/apache/jackrabbit-oak/pull/1619#discussion_r1707169483


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CompressedDocumentPropertyState.java:
##########
@@ -0,0 +1,354 @@
+/*
+ * 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.document;
+
+import static java.util.Collections.emptyList;
+import static 
org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.guava.common.collect.Lists;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.Compression;
+import org.apache.jackrabbit.oak.commons.LongUtils;
+import org.apache.jackrabbit.oak.commons.json.JsopReader;
+import org.apache.jackrabbit.oak.commons.json.JsopTokenizer;
+import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier;
+import org.apache.jackrabbit.oak.json.TypeCodes;
+import org.apache.jackrabbit.oak.plugins.memory.AbstractPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.BooleanPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.DoublePropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.LongPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
+import org.apache.jackrabbit.oak.plugins.value.Conversions;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * PropertyState implementation with lazy parsing of the JSOP encoded value.
+ */
+public final class CompressedDocumentPropertyState implements PropertyState {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(CompressedDocumentPropertyState.class);
+
+    private final DocumentNodeStore store;
+
+    private final String name;
+
+    private final String value;
+
+    private PropertyState parsed;
+    private final byte[] compressedValue;
+    private final Compression compression;
+
+    private static int COMPRESSION_THRESHOLD = SystemPropertySupplier
+            .create("oak.documentMK.stringCompressionThreshold ", 
-1).loggingTo(LOG).get();
+
+    CompressedDocumentPropertyState(DocumentNodeStore store, String name, 
String value, Compression compression) {
+        this.store = store;
+        this.name = name;
+        this.compression = compression;
+        int size = value.length();
+        byte[] compressedValue = null;
+        if (size > COMPRESSION_THRESHOLD) {

Review Comment:
   I would suggest to move that out of the constructor and check the size in 
the factory. Would also simplify the code of this class



##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyStateFactory.java:
##########
@@ -0,0 +1,15 @@
+package org.apache.jackrabbit.oak.plugins.document;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.commons.Compression;
+
+public class DocumentPropertyStateFactory {
+
+    public static PropertyState createPropertyState(DocumentNodeStore store, 
String name, String value, Compression compression) {

Review Comment:
   what about adding a variant that doesn't ask for the `Compression`? in that 
case it would perhaps hard code to GZIP, or later that could be configured..



##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyStateFactory.java:
##########
@@ -0,0 +1,15 @@
+package org.apache.jackrabbit.oak.plugins.document;

Review Comment:
   license header is missing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to