thomasmueller commented on code in PR #1247: URL: https://github.com/apache/jackrabbit-oak/pull/1247#discussion_r1435014768
########## oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/analysis/modules/BinarySize.java: ########## @@ -0,0 +1,111 @@ +/* + * 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.index.indexer.document.flatfile.analysis.modules; + +import java.util.Map.Entry; +import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.apache.jackrabbit.oak.index.indexer.document.flatfile.analysis.stream.NodeData; +import org.apache.jackrabbit.oak.index.indexer.document.flatfile.analysis.stream.NodeProperty; +import org.apache.jackrabbit.oak.index.indexer.document.flatfile.analysis.stream.NodeProperty.ValueType; + +/** + * Collects the total binary size (references to the datastore) per path. + */ +public class BinarySize implements StatsCollector { + + private final Storage storage = new Storage(); + private final int resolution; + private final Random random; + + public BinarySize(int resolution, long seed) { + this.resolution = resolution; + this.random = new Random(seed); //NOSONAR + } + + public void add(NodeData node) { + long size = 0; + for(NodeProperty p : node.getProperties()) { + if (p.getType() == ValueType.BINARY) { + for (String v : p.getValues()) { + if (!v.startsWith(":blobId:")) { + continue; + } + v = v.substring(":blobId:".length()); + if (v.startsWith("0x")) { + // embedded Review Comment: You are right! I didn't know. (It seems unnecessary, because the length of such binaries can be easily calculated, and so adding the length at the end wastes space.) -- 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: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org