AMashenkov commented on code in PR #3146: URL: https://github.com/apache/ignite-3/pull/3146#discussion_r1481366018
########## modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/ReflectionMarshallersProvider.java: ########## @@ -0,0 +1,180 @@ +/* + * 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.ignite.internal.marshaller; + +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.Caffeine; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.Function; +import org.apache.ignite.table.mapper.Mapper; + +/** Implementation of {@link MarshallersProvider}. */ +public class ReflectionMarshallersProvider implements MarshallersProvider { + /** Marshaller cache size for schema based marshallers (schema version, mapper, flags). */ + private static final int KV_CACHE_SIZE = 32; + + /** Marshaller cache size for column based marshallers (columns, mapper, flags). */ + private static final int PROJECTION_CACHE_SIZE = 64; + + /** Marshaller for key columns of a particular schema. Cached by schema version. */ + private final MarshallerCache keysMarshallerCache; + + /** Marshaller for value columns of a particular schema. Cached by schema version. */ + private final MarshallerCache valuesMarshallerCache; + + /** Marshaller for all columns of a particular schema. Cached by schema version. */ + private final MarshallerCache rowMarshallerCache; + + /** Marshaller for an arbitrary columns. Cached by columns. */ + private final MarshallerCache projectionMarshallerCache; + + /** Constructor. */ + public ReflectionMarshallersProvider() { + this.keysMarshallerCache = new MarshallerCache(KV_CACHE_SIZE); + this.valuesMarshallerCache = new MarshallerCache(KV_CACHE_SIZE); + this.rowMarshallerCache = new MarshallerCache(KV_CACHE_SIZE); Review Comment: Can we have a single cache for these marshallers? As I understand, we need 3 marshallers for different column sets: key_only, value_only, full_row. Can we use a enum for these 3 types instead of boolean flags? -- 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]
