Examples of PortableCollection


Examples of com.hazelcast.spi.impl.PortableCollection

        mm.put("key2", "value1");
        mm.put("key2", "value2");

        final SimpleClient client = getClient();
        client.send(new RemoveAllRequest(name, ss.toData("key1"), getThreadId()));
        PortableCollection result = (PortableCollection) client.receive();
        Collection<Data> coll = result.getCollection();
        assertEquals(1, coll.size());
        assertEquals("value1", ss.toObject(coll.iterator().next()));

        client.send(new RemoveAllRequest(name, ss.toData("key2"), getThreadId()));
        result = (PortableCollection) client.receive();
        coll = result.getCollection();
        assertEquals(2, coll.size());
        assertEquals(0, mm.size());
    }
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        mm.put("key2", "value2");
        mm.put("key3", "value2");

        final SimpleClient client = getClient();
        client.send(new ValuesRequest(name));
        PortableCollection result = (PortableCollection) client.receive();
        Collection<Data> coll = result.getCollection();
        assertEquals(4, coll.size());

        for (Data data : coll) {
            Object obj = ss.toObject(data);
            assertTrue(((String) obj).startsWith("value"));
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return drainTo(objects, -1);
    }

    public int drainTo(Collection<? super E> c, int maxElements) {
        DrainRequest request = new DrainRequest(name, maxElements);
        PortableCollection result = invoke(request);
        Collection<Data> coll = result.getCollection();
        for (Data data : coll) {
            E e = getContext().getSerializationService().toObject(data);
            c.add(e);
        }
        return coll.size();
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return result;
    }

    public Iterator<E> iterator() {
        IteratorRequest request = new IteratorRequest(name);
        PortableCollection result = invoke(request);
        Collection<Data> coll = result.getCollection();
        return new QueueIterator<E>(coll.iterator(), getContext().getSerializationService(), false);
    }
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return new QueueIterator<E>(coll.iterator(), getContext().getSerializationService(), false);
    }

    public Object[] toArray() {
        IteratorRequest request = new IteratorRequest(name);
        PortableCollection result = invoke(request);
        Collection<Data> coll = result.getCollection();
        int i = 0;
        Object[] array = new Object[coll.size()];
        for (Data data : coll) {
            array[i++] = getContext().getSerializationService().toObject(data);
        }
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return array;
    }

    public <T> T[] toArray(T[] ts) {
        IteratorRequest request = new IteratorRequest(name);
        PortableCollection result = invoke(request);
        Collection<Data> coll = result.getCollection();
        int size = coll.size();
        if (ts.length < size) {
            ts = (T[]) java.lang.reflect.Array.newInstance(ts.getClass().getComponentType(), size);
        }
        int i = 0;
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return result;
    }

    public Collection<V> get(K key) {
        TxnMultiMapGetRequest request = new TxnMultiMapGetRequest(getName(), toData(key));
        final PortableCollection portableCollection = invoke(request);
        final Collection<Data> collection = portableCollection.getCollection();
        Collection<V> coll;
        if (collection instanceof List) {
            coll = new ArrayList<V>(collection.size());
        } else {
            coll = new HashSet<V>(collection.size());
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

        return result;
    }

    public Collection<V> remove(Object key) {
        TxnMultiMapRemoveAllRequest request = new TxnMultiMapRemoveAllRequest(getName(), toData(key));
        PortableCollection portableCollection = invoke(request);
        final Collection<Data> collection = portableCollection.getCollection();
        Collection<V> coll;
        if (collection instanceof List) {
            coll = new ArrayList<V>(collection.size());
        } else {
            coll = new HashSet<V>(collection.size());
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

            }
            for (MultiMapRecord record : coll) {
                list.add(serializationService.toData(record.getObject()));
            }
        }
        return new PortableCollection(list);
    }
View Full Code Here

Examples of com.hazelcast.spi.impl.PortableCollection

    @Override
    protected Object filter(Object response) {
        if (response instanceof SerializableCollection) {
            SerializableCollection serializableCollection = (SerializableCollection) response;
            Collection<Data> coll = serializableCollection.getCollection();
            return new PortableCollection(coll);
        }
        return super.filter(response);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.