ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [19/50] [abbrv] ignite git commit: IGNITE-1917: Binary protocol performance optimizations.
Date Sat, 21 Nov 2015 02:01:57 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
index e5fd71b..2f6ad5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
@@ -163,4 +163,34 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
 
         shift(cnt);
     }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteShort(short val) {
+        super.unsafeWriteShort(Short.reverseBytes(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteShort(int pos, short val) {
+        super.unsafeWriteShort(pos, Short.reverseBytes(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteChar(char val) {
+        super.unsafeWriteChar(Character.reverseBytes(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteInt(int val) {
+        super.unsafeWriteInt(Integer.reverseBytes(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteInt(int pos, int val) {
+        super.unsafeWriteInt(pos, Integer.reverseBytes(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteLong(long val) {
+        super.unsafeWriteLong(Long.reverseBytes(val));
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
index 16b1567..670dd28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -223,6 +223,69 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream
{
     }
 
     /** {@inheritDoc} */
+    @Override public void unsafeEnsure(int cap) {
+        ensureCapacity(pos + cap);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteByte(byte val) {
+        UNSAFE.putByte(data + pos++, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteBoolean(boolean val) {
+        unsafeWriteByte(val ? (byte) 1 : (byte) 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteShort(short val) {
+        UNSAFE.putShort(data + pos, val);
+
+        shift(2);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteShort(int pos, short val) {
+        UNSAFE.putShort(data + pos, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteChar(char val) {
+        UNSAFE.putChar(data + pos, val);
+
+        shift(2);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteInt(int val) {
+        UNSAFE.putInt(data + pos, val);
+
+        shift(4);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteInt(int pos, int val) {
+        UNSAFE.putInt(data + pos, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteLong(long val) {
+        UNSAFE.putLong(data + pos, val);
+
+        shift(8);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteFloat(float val) {
+        unsafeWriteInt(Float.floatToIntBits(val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unsafeWriteDouble(double val) {
+        unsafeWriteLong(Double.doubleToLongBits(val));
+    }
+
+    /** {@inheritDoc} */
     @Override public void synchronize() {
         PlatformMemoryUtils.length(mem.pointer(), pos);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
deleted file mode 100644
index f84c1e5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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;
-
-import java.util.concurrent.ConcurrentMap;
-import org.jsr166.ConcurrentHashMap8;
-
-/**
- * Cache for enum constants.
- */
-public class GridEnumCache {
-    /** Cache for enum constants. */
-    private static final ConcurrentMap<Class<?>, Object[]> ENUM_CACHE = new ConcurrentHashMap8<>();
-
-    /**
-     * Gets enum constants for provided class.
-     *
-     * @param cls Class.
-     * @return Enum constants.
-     */
-    public static Object[] get(Class<?> cls) {
-        assert cls != null;
-
-        Object[] vals = ENUM_CACHE.get(cls);
-
-        if (vals == null) {
-            vals = cls.getEnumConstants();
-
-            ENUM_CACHE.putIfAbsent(cls, vals);
-        }
-
-        return vals;
-    }
-
-    /**
-     * Clears cache.
-     */
-    public static void clear() {
-        ENUM_CACHE.clear();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index 9809a7e..17ec7d6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -68,7 +68,7 @@ import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 
-import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
+import static org.apache.ignite.internal.portable.streams.PortableMemoryAllocator.INSTANCE;
 import static org.junit.Assert.assertArrayEquals;
 
 /**
@@ -93,7 +93,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testByte() throws Exception {
-        assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue());
+        assertEquals((byte) 100, marshalUnmarshal((byte) 100).byteValue());
     }
 
     /**
@@ -1492,11 +1492,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1,
2, 3}));
 
-        assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[]{1, 2, 3}, copy.<byte[]>field("bArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
+        assertArrayEquals(new byte[]{1, 2, 3}, obj0.bArr);
     }
 
     /**
@@ -1741,7 +1741,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
-        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
     }
 
     /**
@@ -1769,7 +1769,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         map.put("inner", newObj);
         map.put("s", (short)2323);
         map.put("bArr", new byte[]{6, 7, 9});
-        map.put("b", (byte)111);
+        map.put("b", (byte) 111);
 
         BinaryObject copy = copy(po, map);
 
@@ -1786,8 +1786,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
         assertEquals((short)2323, obj0.s);
-        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
-        assertEquals((byte)111, obj0.b);
+        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+        assertEquals((byte) 111, obj0.b);
     }
 
     /**
@@ -2069,28 +2069,28 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
      */
     public void testThreadLocalArrayReleased() throws Exception {
         // Checking the writer directly.
-        assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+        assertEquals(false, INSTANCE.isAcquired());
 
         PortableMarshaller marsh0 = createMarshaller();
-
+        
         try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh0)))
{
-            assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+            assertEquals(true, INSTANCE.isAcquired());
 
             writer.writeString("Thread local test");
 
             writer.array();
 
-            assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+            assertEquals(true, INSTANCE.isAcquired());
         }
 
         // Checking the portable marshaller.
-        assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+        assertEquals(false, INSTANCE.isAcquired());
 
         PortableMarshaller marsh = createMarshaller();
 
         marsh.marshal(new SimpleObject());
 
-        assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+        assertEquals(false, INSTANCE.isAcquired());
 
         // Checking the builder.
         PortableMarshaller marsh2 = createMarshaller();
@@ -2102,7 +2102,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject portableObj = builder.build();
 
-        assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+        assertEquals(false, INSTANCE.isAcquired());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 3e41979..bee9990 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -61,7 +61,7 @@ import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.IgnitionEx;
 import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
 import org.apache.ignite.internal.util.GridClassLoaderCache;
-import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.portable.BinaryEnumCache;
 import org.apache.ignite.internal.util.GridTestClockTimer;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.F;
@@ -1365,7 +1365,7 @@ public abstract class GridAbstractTest extends TestCase {
                 GridClassLoaderCache.clear();
                 U.clearClassCache();
                 MarshallerExclusions.clearCache();
-                GridEnumCache.clear();
+                BinaryEnumCache.clear();
             }
 
             Thread.currentThread().setContextClassLoader(clsLdr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 411ef05..08a98f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -565,7 +565,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// Check scan query with partitions.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-1012")]
         public void TestScanQueryPartitions([Values(true, false)]  bool loc)
         {
             CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
@@ -575,7 +574,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// Check scan query with partitions in binary mode.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-1012")]
         public void TestScanQueryPartitionsBinary([Values(true, false)]  bool loc)
         {
             CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);


Mime
View raw message