From notifications-return-3915-apmail-ignite-notifications-archive=ignite.apache.org@ignite.apache.org Fri Jun 21 13:57:31 2019 Return-Path: X-Original-To: apmail-ignite-notifications-archive@minotaur.apache.org Delivered-To: apmail-ignite-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id A373A19034 for ; Fri, 21 Jun 2019 13:57:31 +0000 (UTC) Received: (qmail 56150 invoked by uid 500); 21 Jun 2019 13:57:29 -0000 Delivered-To: apmail-ignite-notifications-archive@ignite.apache.org Received: (qmail 56091 invoked by uid 500); 21 Jun 2019 13:57:29 -0000 Mailing-List: contact notifications-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list notifications@ignite.apache.org Received: (qmail 55635 invoked by uid 99); 21 Jun 2019 13:57:28 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jun 2019 13:57:28 +0000 From: GitBox To: notifications@ignite.apache.org Subject: [GitHub] [ignite] ibessonov commented on a change in pull request #6536: IGNITE-6957 Boxing / Unboxing optimization - added IntSet. Message-ID: <156112544807.19922.12313373979562712839.gitbox@gitbox.apache.org> Date: Fri, 21 Jun 2019 13:57:28 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit ibessonov commented on a change in pull request #6536: IGNITE-6957 Boxing / Unboxing optimization - added IntSet. URL: https://github.com/apache/ignite/pull/6536#discussion_r296126858 ########## File path: modules/core/src/main/java/org/apache/ignite/internal/util/collection/IntHashMap.java ########## @@ -0,0 +1,337 @@ +/* + * 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.util.collection; + +import java.util.Arrays; +import java.util.Objects; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.stream.Collectors; + +/** + * The simple map for primitive types base on Robin-hood hashing with backward shift. + */ +public class IntHashMap implements IntMap { + /** Array load percentage before resize. */ + private static final float SCALE_LOAD_FACTOR = 0.9F; + + /** Array load percentage before decrise size. */ + private static final float COMPACT_LOAD_FACTOR = 0.5F; + + /** Initial capacity. */ + private static final int INITIAL_CAPACITY = 8; + + /** Maximum capacity. */ + private static final int MAXIMUM_CAPACITY = 1 << 30; + + /** RW Lock. */ + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + /** Entries. */ + private Entry[] entries; + + /** Count of elements into Map. */ + private int size; + + /** Inner entry structure. */ + private static class Entry { + /** Key. */ + private final int key; + + /** Value. */ + private final V val; + + /** Default constructor. */ + Entry(int key, V val) { + this.key = key; + this.val = val; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "{key=" + key + ", val=" + val + '}'; + } + } + + /** Default constructor. */ + public IntHashMap() { Review comment: See no constructor with the capacity. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services