Skip to content

Commit

Permalink
Virtual apps bad performance #10015
Browse files Browse the repository at this point in the history
  • Loading branch information
rymsha committed Mar 14, 2023
1 parent 3cf7fb3 commit 8c67eb7
Show file tree
Hide file tree
Showing 89 changed files with 885 additions and 1,188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected WebResponse doHandle( final WebRequest webRequest, final WebResponse w
}

trace.put( "path", webRequest.getPath() );
trace.put( "method", webRequest.getMethod().toString() );
trace.put( "method", webRequest.getMethod() );
trace.put( "host", webRequest.getHost() );
trace.put( "httpRequest", webRequest );
trace.put( "httpResponse", webResponse );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.enonic.xp.internal.blobstore.file;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
Expand Down Expand Up @@ -39,7 +40,7 @@ public long getLength()
}
catch ( IOException e )
{
return 0;
throw new UncheckedIOException( e );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.google.common.base.Preconditions;

public class NodeVersionKey
public final class NodeVersionKey
{
private final BlobKey nodeBlobKey;

Expand Down Expand Up @@ -41,7 +41,7 @@ public boolean equals( final Object o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
if ( !( o instanceof NodeVersionKey ) )
{
return false;
}
Expand All @@ -58,11 +58,10 @@ public int hashCode()

public static NodeVersionKey from( final BlobKey nodeBlobKey, final BlobKey indexConfigBlobKey, final BlobKey accessControlBlobKey )
{
return create().
nodeBlobKey( nodeBlobKey ).
indexConfigBlobKey( indexConfigBlobKey ).
accessControlBlobKey( accessControlBlobKey ).
build();
return create().nodeBlobKey( nodeBlobKey )
.indexConfigBlobKey( indexConfigBlobKey )
.accessControlBlobKey( accessControlBlobKey )
.build();
}

public static NodeVersionKey from( final String nodeBlobKey, final String indexConfigBlobKey, final String accessControlBlobKey )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public boolean isPageTemplate()
return this instanceof PageTemplate;
}

@Deprecated
public boolean hasPage()
{
return page != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public EditableContent( final Content source )
this.displayName = source.getDisplayName();
this.data = source.getData().copy();
this.extraDatas = source.getAllExtraData().copy();
this.page = source.hasPage() ? source.getPage().copy() : null;
this.page = source.getPage() != null ? source.getPage().copy() : null;
this.valid = source.isValid();
this.thumbnail = source.getThumbnail();
this.inheritPermissions = source.inheritsPermissions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.enonic.xp.index;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.google.common.collect.ImmutableList;

public final class AllTextIndexConfig
{
private final List<String> languages;
private final ImmutableList<String> languages;

private AllTextIndexConfig( final Builder builder )
private AllTextIndexConfig( final ImmutableList<String> languages )
{
this.languages = ImmutableList.copyOf( builder.languages );
this.languages = languages;
}

public static Builder create()
Expand All @@ -30,38 +28,19 @@ public List<String> getLanguages()
return languages;
}

@Override
public boolean equals( final Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
final AllTextIndexConfig that = (AllTextIndexConfig) o;
return Objects.equals( languages, that.languages );
}

@Override
public int hashCode()
{
return Objects.hash( languages );
}

public static class Builder
{
private List<String> languages = new ArrayList<>();
private final ImmutableList.Builder<String> languages;

Builder()
{
languages = ImmutableList.builder();
}

Builder( final AllTextIndexConfig source )
{
this.languages = new ArrayList<>( source.languages );
this.languages = ImmutableList.<String>builder().addAll( source.languages );
}

public Builder addLanguage( final String language )
Expand All @@ -72,7 +51,7 @@ public Builder addLanguage( final String language )

public AllTextIndexConfig build()
{
return new AllTextIndexConfig( this );
return new AllTextIndexConfig( languages.build() );
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.enonic.xp.node;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static Builder create()

public static class Builder
{
private final Set<AttachedBinary> nodeAttachedBinaries = new HashSet<>();
private final ImmutableSet.Builder<AttachedBinary> nodeAttachedBinaries = ImmutableSet.builder();

public Builder add( final AttachedBinary attachedBinary )
{
Expand All @@ -67,12 +66,12 @@ public Builder add( final AttachedBinary attachedBinary )
@Deprecated
public Set<AttachedBinary> getNodeAttachedBinaries()
{
return nodeAttachedBinaries;
return nodeAttachedBinaries.build();
}

public AttachedBinaries build()
{
return fromInternal( ImmutableSet.copyOf( nodeAttachedBinaries ) );
return fromInternal( nodeAttachedBinaries.build() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,35 @@ public static final class Builder
{
private NodeId id;

private NodeType nodeType = NodeType.DEFAULT_NODE_COLLECTION;
private NodeType nodeType;

private PropertyTree data = new PropertyTree();
private PropertyTree data;

private IndexConfigDocument indexConfigDocument;

private ChildOrder childOrder;

private Long manualOrderValue;

private AccessControlList permissions = AccessControlList.empty();
private AccessControlList permissions;

private boolean inheritPermissions;

private AttachedBinaries attachedBinaries = AttachedBinaries.empty();
private AttachedBinaries attachedBinaries;

private Builder()
{
this.nodeType = NodeType.DEFAULT_NODE_COLLECTION;
this.data = new PropertyTree();
permissions = AccessControlList.empty();
attachedBinaries = AttachedBinaries.empty();
}

private Builder( NodeVersion nodeVersion )
{
this.id = nodeVersion.id;
this.nodeType = nodeVersion.nodeType;
this.data = nodeVersion.data;
this.data = nodeVersion.data.copy();
this.indexConfigDocument = nodeVersion.indexConfigDocument;
this.childOrder = nodeVersion.childOrder;
this.manualOrderValue = nodeVersion.manualOrderValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public boolean hasRegions()
return regions != null;
}

@SuppressWarnings("UnusedDeclaration")
public Region getRegion( final String name )
{
return hasRegions() ? this.regions.getRegion( name ) : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.enonic.xp.query.expr;

import java.util.Objects;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.index.IndexPath;

Expand All @@ -11,7 +13,7 @@ public final class FieldExpr

private FieldExpr( final IndexPath indexPath )
{
this.indexPath = indexPath;
this.indexPath = Objects.requireNonNull( indexPath );
}

public String getFieldPath()
Expand Down Expand Up @@ -39,23 +41,12 @@ public String toString()
@Override
public boolean equals( final Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}

final FieldExpr fieldExpr = (FieldExpr) o;

return indexPath != null ? indexPath.equals( fieldExpr.indexPath ) : fieldExpr.indexPath == null;
return this == o || o instanceof FieldExpr && indexPath.equals( ( (FieldExpr) o ).indexPath );
}

@Override
public int hashCode()
{
return indexPath != null ? indexPath.hashCode() : 0;
return indexPath.hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.enonic.xp.query.expr;

import java.util.Objects;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.index.IndexPath;

Expand All @@ -12,7 +14,7 @@ public final class FieldOrderExpr
public FieldOrderExpr( final FieldExpr field, final Direction direction )
{
super( direction );
this.field = field;
this.field = Objects.requireNonNull( field );
}

public FieldExpr getField()
Expand Down Expand Up @@ -43,25 +45,21 @@ public boolean equals( final Object o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
if ( !( o instanceof FieldOrderExpr ) )
{
return false;
}
if ( !super.equals( o ) )
{
return false;
}

final FieldOrderExpr that = (FieldOrderExpr) o;

return field != null ? field.equals( that.field ) : that.field == null;
return field.equals( that.field );
}

@Override
public int hashCode()
{
int result = super.hashCode();
result = 31 * result + ( field != null ? field.hashCode() : 0 );
return result;
return Objects.hash( super.hashCode(), field );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,36 @@

import java.util.Iterator;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public final class RegionDescriptors
implements Iterable<RegionDescriptor>
{
private final ImmutableMap<String, RegionDescriptor> regionByName;
private final ImmutableSet<RegionDescriptor> regionDescriptors;

public RegionDescriptors( final Builder builder )
public RegionDescriptors( final ImmutableSet<RegionDescriptor> regionDescriptors )
{
this.regionByName = builder.regionsByName.build();
this.regionDescriptors = regionDescriptors;
}

@Deprecated
public RegionDescriptor getRegionDescriptor( final String name )
{
return regionByName.get( name );
return regionDescriptors.stream().filter( regionDescriptor -> regionDescriptor.getName().equals( name ) ).findAny().orElse( null );
}

public int numberOfRegions()
{
return this.regionByName.size();
return this.regionDescriptors.size();
}

@Override
public Iterator<RegionDescriptor> iterator()
{
return regionByName.values().iterator();
return regionDescriptors.iterator();
}

public static Builder create()
Expand All @@ -41,17 +42,17 @@ public static Builder create()

public static class Builder
{
private final ImmutableMap.Builder<String, RegionDescriptor> regionsByName = new ImmutableMap.Builder<>();
private final ImmutableSet.Builder<RegionDescriptor> regionsDescriptors = new ImmutableSet.Builder<>();

public Builder add( final RegionDescriptor value )
{
regionsByName.put( value.getName(), value );
regionsDescriptors.add( value );
return this;
}

public RegionDescriptors build()
{
return new RegionDescriptors( this );
return new RegionDescriptors( regionsDescriptors.build() );
}
}
}
Loading

0 comments on commit 8c67eb7

Please sign in to comment.