You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/12/11 16:56:14 UTC
[46/59] [abbrv] ignite git commit: ignite-2065: rename "portable"
classes to "binary"
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapInputStream.java
deleted file mode 100644
index d8717ce..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapInputStream.java
+++ /dev/null
@@ -1,166 +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.binary.streams;
-
-import java.util.Arrays;
-
-/**
- * Portable off-heap input stream.
- */
-public final class PortableHeapInputStream extends PortableAbstractInputStream {
- /**
- * Create stream with pointer set at the given position.
- *
- * @param data Data.
- * @param pos Position.
- * @return Stream.
- */
- public static PortableHeapInputStream create(byte[] data, int pos) {
- assert pos < data.length;
-
- PortableHeapInputStream stream = new PortableHeapInputStream(data);
-
- stream.pos = pos;
-
- return stream;
- }
-
- /** Data. */
- private byte[] data;
-
- /**
- * Constructor.
- *
- * @param data Data.
- */
- public PortableHeapInputStream(byte[] data) {
- this.data = data;
-
- len = data.length;
- }
-
- /**
- * @return Copy of this stream.
- */
- public PortableHeapInputStream copy() {
- PortableHeapInputStream in = new PortableHeapInputStream(Arrays.copyOf(data, data.length));
-
- in.position(pos);
-
- return in;
- }
-
- /**
- * Method called from JNI to resize stream.
- *
- * @param len Required length.
- * @return Underlying byte array.
- */
- public byte[] resize(int len) {
- if (data.length < len) {
- byte[] data0 = new byte[len];
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, data0, BYTE_ARR_OFF, data.length);
-
- data = data0;
- }
-
- return data;
- }
-
- /** {@inheritDoc} */
- @Override public int remaining() {
- return data.length - pos;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- return data;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- byte[] res = new byte[len];
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, res.length);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override protected byte readByteAndShift() {
- return data[pos++];
- }
-
- /** {@inheritDoc} */
- @Override protected void copyAndShift(Object target, long off, int len) {
- UNSAFE.copyMemory(data, BYTE_ARR_OFF + pos, target, off, len);
-
- shift(len);
- }
-
- /** {@inheritDoc} */
- @Override protected short readShortFast() {
- return UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected char readCharFast() {
- return UNSAFE.getChar(data, BYTE_ARR_OFF + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected int readIntFast() {
- return UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected long readLongFast() {
- return UNSAFE.getLong(data, BYTE_ARR_OFF + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected byte readBytePositioned0(int pos) {
- return UNSAFE.getByte(data, BYTE_ARR_OFF + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected short readShortPositioned0(int pos) {
- short res = UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
-
- if (!LITTLE_ENDIAN)
- res = Short.reverseBytes(res);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override protected int readIntPositioned0(int pos) {
- int res = UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
-
- if (!LITTLE_ENDIAN)
- res = Integer.reverseBytes(res);
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapOutputStream.java
deleted file mode 100644
index 8f9ca4a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableHeapOutputStream.java
+++ /dev/null
@@ -1,176 +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.binary.streams;
-
-/**
- * Portable heap output stream.
- */
-public final class PortableHeapOutputStream extends PortableAbstractOutputStream {
- /** Allocator. */
- private final PortableMemoryAllocatorChunk chunk;
-
- /** Data. */
- private byte[] data;
-
- /**
- * Constructor.
- *
- * @param cap Initial capacity.
- */
- public PortableHeapOutputStream(int cap) {
- this(cap, PortableMemoryAllocator.INSTANCE.chunk());
- }
-
- /**
- * Constructor.
- *
- * @param cap Capacity.
- * @param chunk Chunk.
- */
- public PortableHeapOutputStream(int cap, PortableMemoryAllocatorChunk chunk) {
- this.chunk = chunk;
-
- data = chunk.allocate(cap);
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- chunk.release(data, pos);
- }
-
- /** {@inheritDoc} */
- @Override public void ensureCapacity(int cnt) {
- if (cnt > data.length) {
- int newCap = capacity(data.length, cnt);
-
- data = chunk.reallocate(data, newCap);
- }
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- return data;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- byte[] res = new byte[pos];
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, pos);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override protected void writeByteAndShift(byte val) {
- data[pos++] = val;
- }
-
- /** {@inheritDoc} */
- @Override protected void copyAndShift(Object src, long off, int len) {
- UNSAFE.copyMemory(src, off, data, BYTE_ARR_OFF + pos, len);
-
- shift(len);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeShortFast(short val) {
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeCharFast(char val) {
- UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeIntFast(int val) {
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeLongFast(long val) {
- UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteByte(byte val) {
- UNSAFE.putByte(data, BYTE_ARR_OFF + pos++, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteShort(short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
-
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteShort(int pos, short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
-
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteChar(char val) {
- if (!LITTLE_ENDIAN)
- val = Character.reverseBytes(val);
-
- UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteInt(int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
-
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
-
- shift(4);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteInt(int pos, int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
-
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteLong(long val) {
- if (!LITTLE_ENDIAN)
- val = Long.reverseBytes(val);
-
- UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
-
- shift(8);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableInputStream.java
deleted file mode 100644
index cf71dc7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableInputStream.java
+++ /dev/null
@@ -1,163 +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.binary.streams;
-
-import org.apache.ignite.internal.binary.PortablePositionReadable;
-import org.apache.ignite.internal.binary.PortablePositionReadable;
-
-/**
- * Portable input stream.
- */
-public interface PortableInputStream extends PortableStream, PortablePositionReadable {
- /**
- * Read byte value.
- *
- * @return Byte value.
- */
- public byte readByte();
-
- /**
- * Read byte array.
- *
- * @param cnt Expected item count.
- * @return Byte array.
- */
- public byte[] readByteArray(int cnt);
-
- /**
- * Reads {@code cnt} of bytes into byte array.
- *
- * @param arr Expected item count.
- * @param off offset
- * @param cnt number of bytes to read.
- * @return actual length read.
- */
- public int read(byte[] arr, int off, int cnt);
-
- /**
- * Read boolean value.
- *
- * @return Boolean value.
- */
- public boolean readBoolean();
-
- /**
- * Read boolean array.
- *
- * @param cnt Expected item count.
- * @return Boolean array.
- */
- public boolean[] readBooleanArray(int cnt);
-
- /**
- * Read short value.
- *
- * @return Short value.
- */
- public short readShort();
-
- /**
- * Read short array.
- *
- * @param cnt Expected item count.
- * @return Short array.
- */
- public short[] readShortArray(int cnt);
-
- /**
- * Read char value.
- *
- * @return Char value.
- */
- public char readChar();
-
- /**
- * Read char array.
- *
- * @param cnt Expected item count.
- * @return Char array.
- */
- public char[] readCharArray(int cnt);
-
- /**
- * Read int value.
- *
- * @return Int value.
- */
- public int readInt();
-
- /**
- * Read int array.
- *
- * @param cnt Expected item count.
- * @return Int array.
- */
- public int[] readIntArray(int cnt);
-
- /**
- * Read float value.
- *
- * @return Float value.
- */
- public float readFloat();
-
- /**
- * Read float array.
- *
- * @param cnt Expected item count.
- * @return Float array.
- */
- public float[] readFloatArray(int cnt);
-
- /**
- * Read long value.
- *
- * @return Long value.
- */
- public long readLong();
-
- /**
- * Read long array.
- *
- * @param cnt Expected item count.
- * @return Long array.
- */
- public long[] readLongArray(int cnt);
-
- /**
- * Read double value.
- *
- * @return Double value.
- */
- public double readDouble();
-
- /**
- * Read double array.
- *
- * @param cnt Expected item count.
- * @return Double array.
- */
- public double[] readDoubleArray(int cnt);
-
- /**
- * Gets amount of remaining data in bytes.
- *
- * @return Remaining data.
- */
- public int remaining();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocator.java
deleted file mode 100644
index f20a7bc..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocator.java
+++ /dev/null
@@ -1,57 +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.binary.streams;
-
-/**
- * Thread-local memory allocator.
- */
-public final class PortableMemoryAllocator {
- /** Memory allocator instance. */
- public static final PortableMemoryAllocator INSTANCE = new PortableMemoryAllocator();
-
- /** Holders. */
- private static final ThreadLocal<PortableMemoryAllocatorChunk> holders = new ThreadLocal<>();
-
- /**
- * Ensures singleton.
- */
- private PortableMemoryAllocator() {
- // No-op.
- }
-
- public PortableMemoryAllocatorChunk chunk() {
- PortableMemoryAllocatorChunk holder = holders.get();
-
- if (holder == null)
- holders.set(holder = new PortableMemoryAllocatorChunk());
-
- return holder;
- }
-
- /**
- * Checks whether a thread-local array is acquired or not.
- * The function is used by Unit tests.
- *
- * @return {@code true} if acquired {@code false} otherwise.
- */
- public boolean isAcquired() {
- PortableMemoryAllocatorChunk holder = holders.get();
-
- return holder != null && holder.isAcquired();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocatorChunk.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocatorChunk.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocatorChunk.java
deleted file mode 100644
index 749a0b4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableMemoryAllocatorChunk.java
+++ /dev/null
@@ -1,117 +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.binary.streams;
-
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
-
-/**
- * Memory allocator chunk.
- */
-public class PortableMemoryAllocatorChunk {
- /** Unsafe instance. */
- protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: byte. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Buffer size re-check frequency. */
- private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
-
- /** Data array */
- private byte[] data;
-
- /** Max message size detected between checks. */
- private int maxMsgSize;
-
- /** Last time array size is checked. */
- private long lastCheck = U.currentTimeMillis();
-
- /** Whether the holder is acquired or not. */
- private boolean acquired;
-
- /**
- * Allocate.
- *
- * @param size Desired size.
- * @return Data.
- */
- public byte[] allocate(int size) {
- if (acquired)
- return new byte[size];
-
- acquired = true;
-
- if (data == null || size > data.length)
- data = new byte[size];
-
- return data;
- }
-
- /**
- * Reallocate.
- *
- * @param data Old data.
- * @param size Size.
- * @return New data.
- */
- public byte[] reallocate(byte[] data, int size) {
- byte[] newData = new byte[size];
-
- if (this.data == data)
- this.data = newData;
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
-
- return newData;
- }
-
- /**
- * Shrinks array size if needed.
- */
- public void release(byte[] data, int maxMsgSize) {
- if (this.data != data)
- return;
-
- if (maxMsgSize > this.maxMsgSize)
- this.maxMsgSize = maxMsgSize;
-
- this.acquired = false;
-
- long now = U.currentTimeMillis();
-
- if (now - this.lastCheck >= CHECK_FREQ) {
- int halfSize = data.length >> 1;
-
- if (this.maxMsgSize < halfSize)
- this.data = new byte[halfSize];
-
- this.lastCheck = now;
- }
- }
-
- /**
- * @return {@code True} if acquired.
- */
- public boolean isAcquired() {
- return acquired;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapInputStream.java
deleted file mode 100644
index 2a4d7d7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapInputStream.java
+++ /dev/null
@@ -1,144 +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.binary.streams;
-
-/**
- * Portable off-heap input stream.
- */
-public class PortableOffheapInputStream extends PortableAbstractInputStream {
- /** Pointer. */
- private final long ptr;
-
- /** Capacity. */
- private final int cap;
-
- /** */
- private boolean forceHeap;
-
- /**
- * Constructor.
- *
- * @param ptr Pointer.
- * @param cap Capacity.
- */
- public PortableOffheapInputStream(long ptr, int cap) {
- this(ptr, cap, false);
- }
-
- /**
- * Constructor.
- *
- * @param ptr Pointer.
- * @param cap Capacity.
- * @param forceHeap If {@code true} method {@link #offheapPointer} returns 0 and unmarshalling will
- * create heap-based objects.
- */
- public PortableOffheapInputStream(long ptr, int cap, boolean forceHeap) {
- this.ptr = ptr;
- this.cap = cap;
- this.forceHeap = forceHeap;
-
- len = cap;
- }
-
- /** {@inheritDoc} */
- @Override public int remaining() {
- return cap - pos;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- return arrayCopy();
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- byte[] res = new byte[len];
-
- UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, res.length);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected byte readByteAndShift() {
- return UNSAFE.getByte(ptr + pos++);
- }
-
- /** {@inheritDoc} */
- @Override protected void copyAndShift(Object target, long off, int len) {
- UNSAFE.copyMemory(null, ptr + pos, target, off, len);
-
- shift(len);
- }
-
- /** {@inheritDoc} */
- @Override protected short readShortFast() {
- return UNSAFE.getShort(ptr + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected char readCharFast() {
- return UNSAFE.getChar(ptr + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected int readIntFast() {
- return UNSAFE.getInt(ptr + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected long readLongFast() {
- return UNSAFE.getLong(ptr + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected byte readBytePositioned0(int pos) {
- return UNSAFE.getByte(ptr + pos);
- }
-
- /** {@inheritDoc} */
- @Override protected short readShortPositioned0(int pos) {
- short res = UNSAFE.getShort(ptr + pos);
-
- if (!LITTLE_ENDIAN)
- res = Short.reverseBytes(res);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override protected int readIntPositioned0(int pos) {
- int res = UNSAFE.getInt(ptr + pos);
-
- if (!LITTLE_ENDIAN)
- res = Integer.reverseBytes(res);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public long offheapPointer() {
- return forceHeap ? 0 : ptr;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapOutputStream.java
deleted file mode 100644
index 9bcb1f4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOffheapOutputStream.java
+++ /dev/null
@@ -1,222 +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.binary.streams;
-
-/**
- * Portable offheap output stream.
- */
-public class PortableOffheapOutputStream extends PortableAbstractOutputStream {
- /** Pointer. */
- private long ptr;
-
- /** Length of bytes that cen be used before resize is necessary. */
- private int cap;
-
- /**
- * Constructor.
- *
- * @param cap Capacity.
- */
- public PortableOffheapOutputStream(int cap) {
- this(0, cap);
- }
-
- /**
- * Constructor.
- *
- * @param ptr Pointer to existing address.
- * @param cap Capacity.
- */
- public PortableOffheapOutputStream(long ptr, int cap) {
- this.ptr = ptr == 0 ? allocate(cap) : ptr;
-
- this.cap = cap;
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- release(ptr);
- }
-
- /** {@inheritDoc} */
- @Override public void ensureCapacity(int cnt) {
- if (cnt > cap) {
- int newCap = capacity(cap, cnt);
-
- ptr = reallocate(ptr, newCap);
-
- cap = newCap;
- }
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- return arrayCopy();
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- byte[] res = new byte[pos];
-
- UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, pos);
-
- return res;
- }
-
- /**
- * @return Pointer.
- */
- public long pointer() {
- return ptr;
- }
-
- /**
- * @return Capacity.
- */
- public int capacity() {
- return cap;
- }
-
- /** {@inheritDoc} */
- @Override protected void writeByteAndShift(byte val) {
- UNSAFE.putByte(ptr + pos++, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void copyAndShift(Object src, long offset, int len) {
- UNSAFE.copyMemory(src, offset, null, ptr + pos, len);
-
- shift(len);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeShortFast(short val) {
- UNSAFE.putShort(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeCharFast(char val) {
- UNSAFE.putChar(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeIntFast(int val) {
- UNSAFE.putInt(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeLongFast(long val) {
- UNSAFE.putLong(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteByte(byte val) {
- UNSAFE.putByte(ptr + pos++, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteShort(short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
-
- UNSAFE.putShort(ptr + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteShort(int pos, short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
-
- UNSAFE.putShort(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteChar(char val) {
- if (!LITTLE_ENDIAN)
- val = Character.reverseBytes(val);
-
- UNSAFE.putChar(ptr + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteInt(int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
-
- UNSAFE.putInt(ptr + pos, val);
-
- shift(4);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteInt(int pos, int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
-
- UNSAFE.putInt(ptr + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void unsafeWriteLong(long val) {
- if (!LITTLE_ENDIAN)
- val = Long.reverseBytes(val);
-
- UNSAFE.putLong(ptr + pos, val);
-
- shift(8);
- }
-
- /**
- * Allocate memory.
- *
- * @param cap Capacity.
- * @return Pointer.
- */
- protected long allocate(int cap) {
- return UNSAFE.allocateMemory(cap);
- }
-
- /**
- * Reallocate memory.
- *
- * @param ptr Old pointer.
- * @param cap Capacity.
- * @return New pointer.
- */
- protected long reallocate(long ptr, int cap) {
- return UNSAFE.reallocateMemory(ptr, cap);
- }
-
- /**
- * Release memory.
- *
- * @param ptr Pointer.
- */
- protected void release(long ptr) {
- UNSAFE.freeMemory(ptr);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOutputStream.java
deleted file mode 100644
index a686e54..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableOutputStream.java
+++ /dev/null
@@ -1,259 +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.binary.streams;
-
-/**
- * Portable output stream.
- */
-public interface PortableOutputStream extends PortableStream, AutoCloseable {
- /**
- * Write byte value.
- *
- * @param val Byte value.
- */
- public void writeByte(byte val);
-
- /**
- * Write byte array.
- *
- * @param val Byte array.
- */
- public void writeByteArray(byte[] val);
-
- /**
- * Write boolean value.
- *
- * @param val Boolean value.
- */
- public void writeBoolean(boolean val);
-
- /**
- * Write boolean array.
- *
- * @param val Boolean array.
- */
- public void writeBooleanArray(boolean[] val);
-
- /**
- * Write short value.
- *
- * @param val Short value.
- */
- public void writeShort(short val);
-
- /**
- * Write short array.
- *
- * @param val Short array.
- */
- public void writeShortArray(short[] val);
-
- /**
- * Write char value.
- *
- * @param val Char value.
- */
- public void writeChar(char val);
-
- /**
- * Write char array.
- *
- * @param val Char array.
- */
- public void writeCharArray(char[] val);
-
- /**
- * Write int value.
- *
- * @param val Int value.
- */
- public void writeInt(int val);
-
- /**
- * Write short value at the given position.
- *
- * @param pos Position.
- * @param val Value.
- */
- public void writeShort(int pos, short val);
-
- /**
- * Write int value to the given position.
- *
- * @param pos Position.
- * @param val Value.
- */
- public void writeInt(int pos, int val);
-
- /**
- * Write int array.
- *
- * @param val Int array.
- */
- public void writeIntArray(int[] val);
-
- /**
- * Write float value.
- *
- * @param val Float value.
- */
- public void writeFloat(float val);
-
- /**
- * Write float array.
- *
- * @param val Float array.
- */
- public void writeFloatArray(float[] val);
-
- /**
- * Write long value.
- *
- * @param val Long value.
- */
- public void writeLong(long val);
-
- /**
- * Write long array.
- *
- * @param val Long array.
- */
- public void writeLongArray(long[] val);
-
- /**
- * Write double value.
- *
- * @param val Double value.
- */
- public void writeDouble(double val);
-
- /**
- * Write double array.
- *
- * @param val Double array.
- */
- public void writeDoubleArray(double[] val);
-
- /**
- * Write byte array.
- *
- * @param arr Array.
- * @param off Offset.
- * @param len Length.
- */
- public void write(byte[] arr, int off, int len);
-
- /**
- * Write data from unmanaged memory.
- *
- * @param addr Address.
- * @param cnt Count.
- */
- public void write(long addr, int cnt);
-
- /**
- * Close the stream releasing resources.
- */
- @Override public void close();
-
- /**
- * Set position in unsafe mode.
- *
- * @param pos Position.
- */
- public void unsafePosition(int pos);
-
- /**
- * Ensure capacity for unsafe writes.
- *
- * @param cap Capacity.
- */
- public void unsafeEnsure(int cap);
-
- /**
- * Write byte in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteByte(byte val);
-
- /**
- * Write boolean in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteBoolean(boolean val);
-
- /**
- * Write short in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteShort(short val);
-
- /**
- * Write short in unsafe mode.
- *
- * @param pos Position.
- * @param val Value.
- */
- public void unsafeWriteShort(int pos, short val);
-
- /**
- * Write char in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteChar(char val);
-
- /**
- * Write int in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteInt(int val);
-
- /**
- * Write int in unsafe mode.
- *
- * @param pos Position.
- * @param val Value.
- */
- public void unsafeWriteInt(int pos, int val);
-
- /**
- * Write long in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteLong(long val);
-
- /**
- * Write float in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteFloat(float val);
-
- /**
- * Write double in unsafe mode.
- *
- * @param val Value.
- */
- public void unsafeWriteDouble(double val);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableStream.java
deleted file mode 100644
index 18d4609..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/PortableStream.java
+++ /dev/null
@@ -1,53 +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.binary.streams;
-
-/**
- * Portable stream.
- */
-public interface PortableStream {
- /**
- * @return Position.
- */
- public int position();
-
- /**
- * @param pos Position.
- */
- public void position(int pos);
-
- /**
- * @return Underlying array.
- */
- public byte[] array();
-
- /**
- * @return Copy of data in the stream.
- */
- public byte[] arrayCopy();
-
- /**
- * @return Offheap pointer if stream is offheap based, otherwise {@code 0}.
- */
- public long offheapPointer();
-
- /**
- * @return {@code True} is stream is array based.
- */
- public boolean hasArray();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index 6c6c0d2..88a8027 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.ignite.cache.affinity.AffinityKeyMapper;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.PortableUtils;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.util.typedef.F;
@@ -203,7 +203,7 @@ import org.apache.ignite.internal.util.typedef.F;
if (keepPortable)
return map;
- Map<Object, Object> map0 = PortableUtils.newMap(map);
+ Map<Object, Object> map0 = BinaryUtils.newMap(map);
for (Map.Entry<Object, Object> e : map.entrySet())
map0.put(unwrapPortable(e.getKey(), keepPortable, cpy), unwrapPortable(e.getValue(), keepPortable, cpy));
@@ -241,7 +241,7 @@ import org.apache.ignite.internal.util.typedef.F;
* @return Unwrapped set.
*/
private Set<Object> unwrapPortables(Set<Object> set, boolean keepPortable, boolean cpy) {
- Set<Object> set0 = PortableUtils.newSet(set);
+ Set<Object> set0 = BinaryUtils.newSet(set);
for (Object obj : set)
set0.add(unwrapPortable(obj, keepPortable, cpy));
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java
new file mode 100644
index 0000000..f6204fb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java
@@ -0,0 +1,82 @@
+/*
+ * 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.binary;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Key for portable meta data.
+ */
+class BinaryMetadataKey extends GridCacheUtilityKey<BinaryMetadataKey> implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private int typeId;
+
+ /**
+ * For {@link Externalizable}.
+ */
+ public BinaryMetadataKey() {
+ // No-op.
+ }
+
+ /**
+ * @param typeId Type ID.
+ */
+ BinaryMetadataKey(int typeId) {
+ this.typeId = typeId;
+ }
+
+ /**
+ * @return Type id.
+ */
+ public int typeId() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(typeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ typeId = in.readInt();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean equalsx(BinaryMetadataKey key) {
+ return typeId == key.typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryMetadataKey.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultBinaryAffinityKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultBinaryAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultBinaryAffinityKeyMapper.java
new file mode 100644
index 0000000..c0a4612
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultBinaryAffinityKeyMapper.java
@@ -0,0 +1,51 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.binary.BinaryObject;
+
+/**
+ *
+ */
+public class CacheDefaultBinaryAffinityKeyMapper extends GridCacheDefaultAffinityKeyMapper {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey(Object key) {
+ IgniteKernal kernal = (IgniteKernal)ignite;
+
+ CacheObjectBinaryProcessorImpl proc = (CacheObjectBinaryProcessorImpl)kernal.context().cacheObjects();
+
+ try {
+ key = proc.toPortable(key);
+ }
+ catch (IgniteException e) {
+ U.error(log, "Failed to marshal key to portable: " + key, e);
+ }
+
+ if (key instanceof BinaryObject)
+ return proc.affinityKey((BinaryObject)key);
+ else
+ return super.affinityKey(key);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultPortableAffinityKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultPortableAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultPortableAffinityKeyMapper.java
deleted file mode 100644
index 698cd7b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheDefaultPortableAffinityKeyMapper.java
+++ /dev/null
@@ -1,51 +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.processors.cache.binary;
-
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.binary.BinaryObject;
-
-/**
- *
- */
-public class CacheDefaultPortableAffinityKeyMapper extends GridCacheDefaultAffinityKeyMapper {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public Object affinityKey(Object key) {
- IgniteKernal kernal = (IgniteKernal)ignite;
-
- CacheObjectBinaryProcessorImpl proc = (CacheObjectBinaryProcessorImpl)kernal.context().cacheObjects();
-
- try {
- key = proc.toPortable(key);
- }
- catch (IgniteException e) {
- U.error(log, "Failed to marshal key to portable: " + key, e);
- }
-
- if (key instanceof BinaryObject)
- return proc.affinityKey((BinaryObject)key);
- else
- return super.affinityKey(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
new file mode 100644
index 0000000..039f5ce
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
@@ -0,0 +1,56 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
+
+/**
+ *
+ */
+public class CacheObjectBinaryContext extends CacheObjectContext {
+ /** */
+ private boolean portableEnabled;
+
+ /**
+ * @param kernalCtx Kernal context.
+ * @param portableEnabled Portable enabled flag.
+ * @param cpyOnGet Copy on get flag.
+ * @param storeVal {@code True} if should store unmarshalled value in cache.
+ * @param depEnabled {@code true} if deployment is enabled for the given cache.
+ */
+ public CacheObjectBinaryContext(GridKernalContext kernalCtx,
+ boolean cpyOnGet,
+ boolean storeVal,
+ boolean portableEnabled,
+ boolean depEnabled) {
+ super(kernalCtx, portableEnabled ? new CacheDefaultBinaryAffinityKeyMapper() :
+ new GridCacheDefaultAffinityKeyMapper(), cpyOnGet, storeVal, depEnabled);
+
+ this.portableEnabled = portableEnabled;
+ }
+
+ /**
+ * @return Portable enabled flag.
+ */
+ public boolean portableEnabled() {
+ return portableEnabled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 12e7078..a9f0d74 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -57,12 +57,12 @@ import org.apache.ignite.internal.binary.BinaryObjectEx;
import org.apache.ignite.internal.binary.BinaryObjectImpl;
import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.binary.BinaryTypeImpl;
-import org.apache.ignite.internal.binary.GridPortableMarshaller;
-import org.apache.ignite.internal.binary.PortableContext;
-import org.apache.ignite.internal.binary.PortableUtils;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.binary.streams.PortableInputStream;
-import org.apache.ignite.internal.binary.streams.PortableOffheapInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
@@ -112,7 +112,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private final boolean clientNode;
/** */
- private volatile IgniteCacheProxy<PortableMetadataKey, BinaryMetadata> metaDataCache;
+ private volatile IgniteCacheProxy<BinaryMetadataKey, BinaryMetadata> metaDataCache;
/** */
private final ConcurrentHashMap8<Integer, BinaryTypeImpl> clientMetaDataCache;
@@ -122,18 +122,18 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private static final long serialVersionUID = 0L;
@Override public boolean apply(GridCacheEntryEx e) {
- return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey;
+ return e.key().value(e.context().cacheObjectContext(), false) instanceof BinaryMetadataKey;
}
};
/** */
- private PortableContext portableCtx;
+ private BinaryContext portableCtx;
/** */
private Marshaller marsh;
/** */
- private GridPortableMarshaller portableMarsh;
+ private GridBinaryMarshaller portableMarsh;
/** */
@GridToStringExclude
@@ -170,11 +170,11 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (metaDataCache == null) {
BinaryMetadata oldMeta = metaBuf.get(typeId);
- BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
+ BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
if (oldMeta != mergedMeta) {
synchronized (this) {
- mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
+ mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
if (oldMeta != mergedMeta)
metaBuf.put(typeId, mergedMeta);
@@ -206,12 +206,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
BinaryMarshaller pMarh0 = (BinaryMarshaller)marsh;
- portableCtx = new PortableContext(metaHnd, ctx.config());
+ portableCtx = new BinaryContext(metaHnd, ctx.config());
IgniteUtils.invoke(BinaryMarshaller.class, pMarh0, "setPortableContext", portableCtx,
ctx.config());
- portableMarsh = new GridPortableMarshaller(portableCtx);
+ portableMarsh = new GridBinaryMarshaller(portableCtx);
portables = new IgniteBinaryImpl(ctx, this);
}
@@ -249,7 +249,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
GridCacheQueryManager qryMgr = metaDataCache.context().queries();
- CacheQuery<Map.Entry<PortableMetadataKey, BinaryMetadata>> qry =
+ CacheQuery<Map.Entry<BinaryMetadataKey, BinaryMetadata>> qry =
qryMgr.createScanQuery(new MetaDataPredicate(), null, false);
qry.keepAll(false);
@@ -257,9 +257,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
try {
- CacheQueryFuture<Map.Entry<PortableMetadataKey, BinaryMetadata>> fut = qry.execute();
+ CacheQueryFuture<Map.Entry<BinaryMetadataKey, BinaryMetadata>> fut = qry.execute();
- Map.Entry<PortableMetadataKey, BinaryMetadata> next;
+ Map.Entry<BinaryMetadataKey, BinaryMetadata> next;
while ((next = fut.next()) != null) {
assert next.getKey() != null : next;
@@ -305,7 +305,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @param key Metadata key.
* @param newMeta Metadata.
*/
- private void addClientCacheMetaData(PortableMetadataKey key, final BinaryMetadata newMeta) {
+ private void addClientCacheMetaData(BinaryMetadataKey key, final BinaryMetadata newMeta) {
int key0 = key.typeId();
clientMetaDataCache.compute(key0, new ConcurrentHashMap8.BiFun<Integer, BinaryTypeImpl, BinaryTypeImpl>() {
@@ -315,7 +315,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
BinaryMetadata oldMeta0 = oldMeta != null ? oldMeta.metadata() : null;
try {
- res = PortableUtils.mergeMetadata(oldMeta0, newMeta);
+ res = BinaryUtils.mergeMetadata(oldMeta0, newMeta);
}
catch (BinaryObjectException e) {
res = oldMeta0;
@@ -365,7 +365,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (type != CacheObject.TYPE_BYTE_ARR) {
assert size > 0 : size;
- PortableInputStream in = new PortableOffheapInputStream(ptr, size, forceHeap);
+ BinaryInputStream in = new BinaryOffheapInputStream(ptr, size, forceHeap);
return portableMarsh.unmarshal(in);
}
@@ -379,7 +379,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (obj == null)
return null;
- if (PortableUtils.isPortableType(obj.getClass()))
+ if (BinaryUtils.isPortableType(obj.getClass()))
return obj;
if (obj instanceof Object[]) {
@@ -408,7 +408,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
Collection<Object> pCol;
if (col instanceof Set)
- pCol = (Collection<Object>)PortableUtils.newSet((Set<?>)col);
+ pCol = (Collection<Object>)BinaryUtils.newSet((Set<?>)col);
else
pCol = new ArrayList<>(col.size());
@@ -421,7 +421,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (obj instanceof Map) {
Map<?, ?> map = (Map<?, ?>)obj;
- Map<Object, Object> pMap = PortableUtils.newMap((Map<Object, Object>)obj);
+ Map<Object, Object> pMap = BinaryUtils.newMap((Map<Object, Object>)obj);
for (Map.Entry<?, ?> e : map.entrySet())
pMap.put(marshalToPortable(e.getKey()), marshalToPortable(e.getValue()));
@@ -451,7 +451,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
* @return Marshaller.
*/
- public GridPortableMarshaller marshaller() {
+ public GridBinaryMarshaller marshaller() {
return portableMarsh;
}
@@ -480,11 +480,11 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
- final PortableMetadataKey key = new PortableMetadataKey(typeId);
+ final BinaryMetadataKey key = new BinaryMetadataKey(typeId);
try {
BinaryMetadata oldMeta = metaDataCache.localPeek(key);
- BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
+ BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
BinaryObjectException err = metaDataCache.invoke(key, new MetadataProcessor(mergedMeta));
@@ -505,12 +505,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (typeMeta != null)
return typeMeta;
- BinaryMetadata meta = metaDataCache.getTopologySafe(new PortableMetadataKey(typeId));
+ BinaryMetadata meta = metaDataCache.getTopologySafe(new BinaryMetadataKey(typeId));
return meta != null ? meta.wrap(portableCtx) : null;
}
else {
- PortableMetadataKey key = new PortableMetadataKey(typeId);
+ BinaryMetadataKey key = new BinaryMetadataKey(typeId);
BinaryMetadata meta = metaDataCache.localPeek(key);
@@ -529,16 +529,16 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Override public Map<Integer, BinaryType> metadata(Collection<Integer> typeIds)
throws BinaryObjectException {
try {
- Collection<PortableMetadataKey> keys = new ArrayList<>(typeIds.size());
+ Collection<BinaryMetadataKey> keys = new ArrayList<>(typeIds.size());
for (Integer typeId : typeIds)
- keys.add(new PortableMetadataKey(typeId));
+ keys.add(new BinaryMetadataKey(typeId));
- Map<PortableMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
+ Map<BinaryMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
Map<Integer, BinaryType> res = U.newHashMap(meta.size());
- for (Map.Entry<PortableMetadataKey, BinaryMetadata> e : meta.entrySet())
+ for (Map.Entry<BinaryMetadataKey, BinaryMetadata> e : meta.entrySet())
res.put(e.getKey().typeId(), e.getValue().wrap(portableCtx));
return res;
@@ -559,10 +559,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
});
else {
return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
- new C1<Cache.Entry<PortableMetadataKey, BinaryMetadata>, BinaryType>() {
+ new C1<Cache.Entry<BinaryMetadataKey, BinaryMetadata>, BinaryType>() {
private static final long serialVersionUID = 0L;
- @Override public BinaryType apply(Cache.Entry<PortableMetadataKey, BinaryMetadata> e) {
+ @Override public BinaryType apply(Cache.Entry<BinaryMetadataKey, BinaryMetadata> e) {
return e.getValue().wrap(portableCtx);
}
});
@@ -571,7 +571,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public BinaryObject buildEnum(String typeName, int ord) throws IgniteException {
- typeName = PortableContext.typeName(typeName);
+ typeName = BinaryContext.typeName(typeName);
int typeId = portableCtx.typeId(typeName);
@@ -649,7 +649,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
* @return Portable context.
*/
- public PortableContext portableContext() {
+ public BinaryContext portableContext() {
return portableCtx;
}
@@ -662,7 +662,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
CacheObjectContext ctx0 = super.contextForCache(cfg);
- CacheObjectContext res = new CacheObjectPortableContext(ctx,
+ CacheObjectContext res = new CacheObjectBinaryContext(ctx,
ctx0.copyOnGet(),
ctx0.storeValue(),
portableEnabled,
@@ -675,7 +675,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException {
- if (!((CacheObjectPortableContext)ctx).portableEnabled() || portableMarsh == null)
+ if (!((CacheObjectBinaryContext)ctx).portableEnabled() || portableMarsh == null)
return super.marshal(ctx, val);
byte[] arr = portableMarsh.marshal(val);
@@ -688,7 +688,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
throws IgniteCheckedException {
- if (!((CacheObjectPortableContext)ctx).portableEnabled() || portableMarsh == null)
+ if (!((CacheObjectBinaryContext)ctx).portableEnabled() || portableMarsh == null)
return super.unmarshal(ctx, bytes, clsLdr);
return portableMarsh.unmarshal(bytes, clsLdr);
@@ -696,13 +696,13 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj) {
- if (!((CacheObjectPortableContext)ctx).portableEnabled())
+ if (!((CacheObjectBinaryContext)ctx).portableEnabled())
return super.toCacheKeyObject(ctx, obj, userObj);
if (obj instanceof KeyCacheObject)
return (KeyCacheObject)obj;
- if (((CacheObjectPortableContext)ctx).portableEnabled()) {
+ if (((CacheObjectBinaryContext)ctx).portableEnabled()) {
obj = toPortable(obj);
if (obj instanceof BinaryObject)
@@ -715,7 +715,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj,
boolean userObj) {
- if (!((CacheObjectPortableContext)ctx).portableEnabled())
+ if (!((CacheObjectBinaryContext)ctx).portableEnabled())
return super.toCacheObject(ctx, obj, userObj);
if (obj == null || obj instanceof CacheObject)
@@ -740,7 +740,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public CacheObject toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp)
throws IgniteCheckedException {
- if (!((CacheObjectPortableContext)ctx.cacheObjectContext()).portableEnabled())
+ if (!((CacheObjectBinaryContext)ctx.cacheObjectContext()).portableEnabled())
return super.toCacheObject(ctx, valPtr, tmp);
Object val = unmarshal(valPtr, !tmp);
@@ -753,7 +753,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public Object unwrapTemporary(GridCacheContext ctx, Object obj) throws BinaryObjectException {
- if (!((CacheObjectPortableContext)ctx.cacheObjectContext()).portableEnabled())
+ if (!((CacheObjectBinaryContext)ctx.cacheObjectContext()).portableEnabled())
return obj;
if (obj instanceof BinaryObjectOffheapImpl)
@@ -781,7 +781,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* Processor responsible for metadata update.
*/
private static class MetadataProcessor
- implements EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
+ implements EntryProcessor<BinaryMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -805,12 +805,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
- @Override public BinaryObjectException process(MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
+ @Override public BinaryObjectException process(MutableEntry<BinaryMetadataKey, BinaryMetadata> entry,
Object... args) {
try {
BinaryMetadata oldMeta = entry.getValue();
- BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);
+ BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta);
if (mergedMeta != oldMeta)
entry.setValue(mergedMeta);
@@ -841,15 +841,15 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*
*/
- class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey, BinaryMetadata> {
+ class MetaDataEntryListener implements CacheEntryUpdatedListener<BinaryMetadataKey, BinaryMetadata> {
/** {@inheritDoc} */
@Override public void onUpdated(
- Iterable<CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata>> evts)
+ Iterable<CacheEntryEvent<? extends BinaryMetadataKey, ? extends BinaryMetadata>> evts)
throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata> evt : evts) {
+ for (CacheEntryEvent<? extends BinaryMetadataKey, ? extends BinaryMetadata> evt : evts) {
assert evt.getEventType() == EventType.CREATED || evt.getEventType() == EventType.UPDATED : evt;
- PortableMetadataKey key = evt.getKey();
+ BinaryMetadataKey key = evt.getKey();
final BinaryMetadata newMeta = evt.getValue();
@@ -874,7 +874,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean evaluate(CacheEntryEvent<?, ?> evt) throws CacheEntryListenerException {
- return evt.getKey() instanceof PortableMetadataKey;
+ return evt.getKey() instanceof BinaryMetadataKey;
}
/** {@inheritDoc} */
@@ -892,7 +892,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean apply(Object key, Object val) {
- return key instanceof PortableMetadataKey;
+ return key instanceof BinaryMetadataKey;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectPortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectPortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectPortableContext.java
deleted file mode 100644
index c2b5261..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectPortableContext.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.processors.cache.binary;
-
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
-
-/**
- *
- */
-public class CacheObjectPortableContext extends CacheObjectContext {
- /** */
- private boolean portableEnabled;
-
- /**
- * @param kernalCtx Kernal context.
- * @param portableEnabled Portable enabled flag.
- * @param cpyOnGet Copy on get flag.
- * @param storeVal {@code True} if should store unmarshalled value in cache.
- * @param depEnabled {@code true} if deployment is enabled for the given cache.
- */
- public CacheObjectPortableContext(GridKernalContext kernalCtx,
- boolean cpyOnGet,
- boolean storeVal,
- boolean portableEnabled,
- boolean depEnabled) {
- super(kernalCtx, portableEnabled ? new CacheDefaultBinaryAffinityKeyMapper() :
- new GridCacheDefaultAffinityKeyMapper(), cpyOnGet, storeVal, depEnabled);
-
- this.portableEnabled = portableEnabled;
- }
-
- /**
- * @return Portable enabled flag.
- */
- public boolean portableEnabled() {
- return portableEnabled;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/PortableMetadataKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/PortableMetadataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/PortableMetadataKey.java
deleted file mode 100644
index 3b0ce8e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/PortableMetadataKey.java
+++ /dev/null
@@ -1,82 +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.processors.cache.binary;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Key for portable meta data.
- */
-class PortableMetadataKey extends GridCacheUtilityKey<PortableMetadataKey> implements Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private int typeId;
-
- /**
- * For {@link Externalizable}.
- */
- public PortableMetadataKey() {
- // No-op.
- }
-
- /**
- * @param typeId Type ID.
- */
- PortableMetadataKey(int typeId) {
- this.typeId = typeId;
- }
-
- /**
- * @return Type id.
- */
- public int typeId() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(typeId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- typeId = in.readInt();
- }
-
- /** {@inheritDoc} */
- @Override protected boolean equalsx(PortableMetadataKey key) {
- return typeId == key.typeId;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PortableMetadataKey.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index e8c9d4d..f69ea3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -38,7 +38,7 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.BinaryTypeImpl;
-import org.apache.ignite.internal.binary.GridPortableMarshaller;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter;
import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilterImpl;
@@ -94,7 +94,7 @@ public class PlatformContextImpl implements PlatformContext {
private final GridKernalContext ctx;
/** Marshaller. */
- private final GridPortableMarshaller marsh;
+ private final GridBinaryMarshaller marsh;
/** Memory manager. */
private final PlatformMemoryManagerImpl mem;
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index caea840..b2bd5d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -25,8 +25,8 @@ import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.MarshallerContextImpl;
import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-import org.apache.ignite.internal.binary.GridPortableMarshaller;
-import org.apache.ignite.internal.binary.PortableContext;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
@@ -239,9 +239,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
* @return Marshaller.
*/
@SuppressWarnings("deprecation")
- private static GridPortableMarshaller marshaller() {
+ private static GridBinaryMarshaller marshaller() {
try {
- PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
+ BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
BinaryMarshaller marsh = new BinaryMarshaller();
@@ -249,7 +249,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
ctx.configure(marsh, new IgniteConfiguration());
- return new GridPortableMarshaller(ctx);
+ return new GridBinaryMarshaller(ctx);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
index 321e592..e4d1e46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
@@ -17,12 +17,12 @@
package org.apache.ignite.internal.processors.platform.memory;
-import org.apache.ignite.internal.binary.streams.PortableInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
/**
* Interop output stream,
*/
-public interface PlatformInputStream extends PortableInputStream {
+public interface PlatformInputStream extends BinaryInputStream {
/**
* Synchronize input. Must be called before start reading data from a memory changed by another platform.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
index 7894f0c..95cbac2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
@@ -17,12 +17,12 @@
package org.apache.ignite.internal.processors.platform.memory;
-import org.apache.ignite.internal.binary.streams.PortableOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
/**
* Interop output stream.
*/
-public interface PlatformOutputStream extends PortableOutputStream {
+public interface PlatformOutputStream extends BinaryOutputStream {
/**
* Synchronize output stream with underlying memory
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ad9cea/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientBinaryMetaData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientBinaryMetaData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientBinaryMetaData.java
new file mode 100644
index 0000000..daa056b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientBinaryMetaData.java
@@ -0,0 +1,71 @@
+/*
+ * 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.rest.client.message;
+
+import java.util.Map;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Portable meta data sent from client.
+ */
+public class GridClientBinaryMetaData {
+ /** */
+ private int typeId;
+
+ /** */
+ private String typeName;
+
+ /** */
+ private Map<String, Integer> fields;
+
+ /** */
+ private String affKeyFieldName;
+
+ /**
+ * @return Type ID.
+ */
+ public int typeId() {
+ return typeId;
+ }
+
+ /**
+ * @return Type name.
+ */
+ public String typeName() {
+ return typeName;
+ }
+
+ /**
+ * @return Fields.
+ */
+ public Map<String, Integer> fields() {
+ return fields;
+ }
+
+ /**
+ * @return Affinity key field name.
+ */
+ public String affinityKeyFieldName() {
+ return affKeyFieldName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridClientBinaryMetaData.class, this);
+ }
+}