DocumentNodeState extends AbstractDocumentNodeState implements CacheValue { @Override public int getMemory() { long size = memory; if (size == 0) { size = 40 + (lastRevision != null ? lastRevision.getMemory() : 0) + rootRevision.getMemory() + path.getMemory(); for (Map.Entry<String, PropertyState> entry : bundlingContext.getAllProperties().entrySet()) { size += estimateMemoryUsage(entry.getKey()); PropertyState propState = entry.getValue(); if (propState.getType() != Type.BINARY && propState.getType() != Type.BINARIES) { for (int i = 0; i < propState.count(); i++) { size += (56 + propState.size(i) * 2) * 2; } } else { size += (long)estimateMemoryUsage(asString(entry.getValue())) * 2; } } if (size > Integer.MAX_VALUE) { log.debug("Estimated memory footprint larger than Integer.MAX_VALUE: {}.", size); size = Integer.MAX_VALUE; } memory = (int) size; } return (int) size; } DocumentNodeState(@NotNull DocumentNodeStore store,
                      @NotNull Path path,
                      @NotNull RevisionVector rootRevision);   DocumentNodeState(@NotNull DocumentNodeStore store, @NotNull Path path,
                      @NotNull RevisionVector rootRevision,
                      Iterable<? extends PropertyState> properties,
                      boolean hasChildren,
                      @Nullable RevisionVector lastRevision);  DocumentNodeState(@NotNull DocumentNodeStore store,
                             @NotNull Path path,
                             @NotNull RevisionVector rootRevision,
                             @NotNull Map<String, PropertyState> properties,
                             boolean hasChildren,
                             int memory,
                             @Nullable RevisionVector lastRevision,
                             boolean fromExternalChange); protected  DocumentNodeState(@NotNull DocumentNodeStore store,
                                @NotNull Path path,
                                @Nullable RevisionVector lastRevision,
                                @NotNull RevisionVector rootRevision,
                                boolean fromExternalChange,
                                BundlingContext bundlingContext,
                                int memory); @Override DocumentNodeState withRootRevision(@NotNull RevisionVector root,
                                               boolean externalChange); @NotNull DocumentNodeState fromExternalChange(); @Override boolean isFromExternalChange(); @NotNull RevisionVector getRootRevision(); @Override Path getPath(); @Override RevisionVector getLastRevision(); @Override boolean exists(); @Override PropertyState getProperty(@NotNull String name); @Override boolean hasProperty(@NotNull String name); @NotNull @Override Iterable<? extends PropertyState> getProperties(); @Override boolean hasChildNode(@NotNull String name); @NotNull @Override NodeState getChildNode(@NotNull String name); @Override long getChildNodeCount(long max); @Override long getPropertyCount(); @NotNull @Override Iterable<? extends ChildNodeEntry> getChildNodeEntries(); @NotNull @Override NodeBuilder builder(); Set<String> getBundledChildNodeNames(); boolean hasOnlyBundledChildren(); @Override boolean hasNoChildren(); @Override String toString(); @Override int getMemory(); Iterable<DocumentNodeState> getAllBundledNodesStates(); Map<String, String> getAllBundledProperties(); static final Children NO_CHILDREN; }
@Test public void getMemory() { DocumentNodeStore store = builderProvider.newBuilder().getNodeStore(); RevisionVector rv = new RevisionVector(Revision.newRevision(1)); DocumentNodeState state = new DocumentNodeState(store, Path.fromString("/foo"), rv); assertEquals(198, state.getMemory()); }