You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2016/02/04 11:09:50 UTC

[47/50] [abbrv] ignite git commit: Offheap cache object WIP

Offheap cache object WIP


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fb6b9f6c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fb6b9f6c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fb6b9f6c

Branch: refs/heads/sql-store
Commit: fb6b9f6c157a52884a9a77f9650a6ea592398e5a
Parents: fd9432e
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Feb 3 17:12:53 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Feb 3 17:13:44 2016 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryObjectImpl.java       |   2 +-
 .../processors/cache/CacheObjectAdapter.java    |   2 +-
 .../cache/CacheObjectByteArrayImpl.java         |   2 +-
 .../cache/CacheObjectOffheapImpl.java           | 122 +++++++++++++++++++
 .../IgniteCacheObjectProcessorImpl.java         |   4 +-
 5 files changed, 127 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fb6b9f6c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index c1b9953..1afbeb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -140,8 +140,8 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
         if (buf.remaining() < len + 5)
             return false;
 
-        buf.put(cacheObjectType());
         buf.putInt(len);
+        buf.put(cacheObjectType());
         buf.put(arr, start, len);
 
         return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb6b9f6c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
index d1577ee..126f3fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
@@ -77,8 +77,8 @@ public abstract class CacheObjectAdapter implements CacheObject, Externalizable
         if (buf.remaining() < valBytes.length + 5)
             return false;
 
-        buf.put(cacheObjectType());
         buf.putInt(valBytes.length);
+        buf.put(cacheObjectType());
         buf.put(valBytes);
 
         return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb6b9f6c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index 0e41b3e..28813ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -79,8 +79,8 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
         if (buf.remaining() < val.length + 5)
             return false;
 
-        buf.put(cacheObjectType());
         buf.putInt(val.length);
+        buf.put(cacheObjectType());
         buf.put(val);
 
         return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb6b9f6c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectOffheapImpl.java
new file mode 100644
index 0000000..d57b224
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectOffheapImpl.java
@@ -0,0 +1,122 @@
+/*
+ * 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.processors.cache;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.jetbrains.annotations.Nullable;
+import sun.nio.ch.DirectBuffer;
+
+import java.nio.ByteBuffer;
+
+/**
+ *
+ */
+public class CacheObjectOffheapImpl implements CacheObject {
+    /** */
+    private long ptr;
+
+    /** */
+    private int size;
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+        byte[] res = new byte[size];
+
+        return new byte[0];
+    }
+
+    /** {@inheritDoc} */
+    @Override public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException {
+        return size + 5;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean putValue(ByteBuffer buf, CacheObjectContext ctx) throws IgniteCheckedException {
+        int pos = buf.position();
+        int rem = buf.remaining();
+
+        if (size > rem)
+            return false;
+
+        if (buf.isDirect()) {
+            long ptr = ((DirectBuffer)buf).address();
+
+
+        }
+        else if (buf.hasArray()) {
+            byte[] backingArr = buf.array();
+            int off = buf.arrayOffset();
+
+
+        }
+
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte cacheObjectType() {
+        return TYPE_REGULAR;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte directType() {
+        return 0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte fieldsCount() {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb6b9f6c/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index f673983..9852c23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -184,10 +184,10 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
 
     /** {@inheritDoc} */
     @Override public CacheObject toCacheObject(CacheObjectContext ctx, ByteBuffer buf) {
-        byte type = buf.get();
-
         int len = buf.getInt();
 
+        byte type = buf.get();
+
         byte[] data = new byte[len];
 
         buf.get(data);