Examples of RiakIndexes


Examples of com.basho.riak.client.query.indexes.RiakIndexes

                throw new NoKeySpecifedException(domainObject);
            }

            final byte[] value = objectMapper.writeValueAsBytes(domainObject);
            Map<String, String> usermetaData = usermetaConverter.getUsermetaData(domainObject);
            RiakIndexes indexes = riakIndexConverter.getIndexes(domainObject);
            Collection<RiakLink> links = riakLinksConverter.getLinks(domainObject);
            return RiakObjectBuilder.newBuilder(bucket, key)
                .withValue(value)
                .withVClock(vclock)
                .withUsermeta(usermetaData)
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

        try {
            T domainObject = objectMapper.readValue(json, clazz);
            KeyUtil.setKey(domainObject, riakObject.getKey());
            usermetaConverter.populateUsermeta(riakObject.getMeta(), domainObject);
            riakIndexConverter.populateIndexes(new RiakIndexes(riakObject.allBinIndexes(), riakObject.allIntIndexes()),
                                               domainObject);
            riakLinksConverter.populateLinks(riakObject.getLinks(), domainObject);
            return domainObject;
        } catch (JsonProcessingException e) {
            throw new ConversionException(e);
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

                throw new NoKeySpecifedException(domainObject);
            }
           
            final byte[] value = objectMapper.writeValueAsBytes(domainObject);
            Map<String, String> usermetaData = usermetaConverter.getUsermetaData(domainObject);
            RiakIndexes indexes = riakIndexConverter.getIndexes(domainObject);
            Collection<RiakLink> links = riakLinksConverter.getLinks(domainObject);
            return RiakObjectBuilder.newBuilder(bucket, key)
                .withValue(value)
                .withVClock(vclock)
                .withUsermeta(usermetaData)
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

            try {
                T domainObject = objectMapper.readValue(json, clazz);
                KeyUtil.setKey(domainObject, riakObject.getKey());
                VClockUtil.setVClock(domainObject, riakObject.getVClock());
                usermetaConverter.populateUsermeta(riakObject.getMeta(), domainObject);
                riakIndexConverter.populateIndexes(new RiakIndexes(riakObject.allBinIndexes(), riakObject.allIntIndexesV2()),
                                                   domainObject);
                riakLinksConverter.populateLinks(riakObject.getLinks(), domainObject);
                return domainObject;
            } catch (JsonProcessingException e) {
                throw new ConversionException(e);
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

                throw new NoKeySpecifedException(domainObject);
            }
           
            final byte[] value = objectMapper.writeValueAsBytes(domainObject);
            Map<String, String> usermetaData = usermetaConverter.getUsermetaData(domainObject);
            RiakIndexes indexes = riakIndexConverter.getIndexes(domainObject);
            Collection<RiakLink> links = riakLinksConverter.getLinks(domainObject);
            return RiakObjectBuilder.newBuilder(bucket, key)
                .withValue(value)
                .withVClock(vclock)
                .withUsermeta(usermetaData)
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

        try {
            T domainObject = objectMapper.readValue(json, clazz);
            KeyUtil.setKey(domainObject, riakObject.getKey());
            VClockUtil.setVClock(domainObject, riakObject.getVClock());
            usermetaConverter.populateUsermeta(riakObject.getMeta(), domainObject);
            riakIndexConverter.populateIndexes(new RiakIndexes(riakObject.allBinIndexes(), riakObject.allIntIndexes()),
                                               domainObject);
            riakLinksConverter.populateLinks(riakObject.getLinks(), domainObject);
            return domainObject;
        } catch (JsonProcessingException e) {
            throw new ConversionException(e);
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

    /**
     * @return a {@link RiakIndexes} made of the values of the RiakIndex
     *         annotated fields
     */
    public <T> RiakIndexes getIndexes(T obj) {
        final RiakIndexes riakIndexes = new RiakIndexes();

        for (RiakIndexField f : indexFields) {
            if (Set.class.isAssignableFrom(f.getType())) {
                Type t = f.getField().getGenericType();
                if (t instanceof ParameterizedType) {
                    Class genericType = (Class)((ParameterizedType)t).getActualTypeArguments()[0];
                    if (String.class.equals(genericType)) {
                        riakIndexes.addBinSet(f.getIndexName(), (Set<String>)getFieldValue(f.getField(), obj));
                    } else if (Integer.class.equals(genericType)) {
                        riakIndexes.addIntSet(f.getIndexName(), (Set<Integer>)getFieldValue(f.getField(), obj));
                    }
                }
            } else {
                Object val = getFieldValue(f.getField(), obj);
                // null is not an index value
                if (val != null) {
                    if (val instanceof String) {
                        riakIndexes.add(f.getIndexName(), (String) val);
                    } else if (val instanceof Integer) {
                        riakIndexes.add(f.getIndexName(), (Integer) val);
                    }
                }
            }
        }

View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

        try {
            String key = getKey(domainObject, this.defaultKey);
           
            final byte[] value = OBJECT_MAPPER.writeValueAsBytes(domainObject);
            Map<String, String> usermetaData = usermetaConverter.getUsermetaData(domainObject);
            RiakIndexes indexes = riakIndexConverter.getIndexes(domainObject);
            Collection<RiakLink> links = riakLinksConverter.getLinks(domainObject);
            return RiakObjectBuilder.newBuilder(bucket, key)
                .withValue(value)
                .withVClock(vclock)
                .withUsermeta(usermetaData)
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

            try {
                final T domainObject = OBJECT_MAPPER.readValue(riakObject.getValue(), clazz);
                KeyUtil.setKey(domainObject, riakObject.getKey());
                VClockUtil.setVClock(domainObject, riakObject.getVClock());
                usermetaConverter.populateUsermeta(riakObject.getMeta(), domainObject);
                riakIndexConverter.populateIndexes(new RiakIndexes(riakObject.allBinIndexes(), riakObject.allIntIndexesV2()), domainObject);
                riakLinksConverter.populateLinks(riakObject.getLinks(), domainObject);
                return domainObject;
            } catch (JsonProcessingException e) {
                throw new ConversionException(e);
            } catch (IOException e) {
View Full Code Here

Examples of com.basho.riak.client.query.indexes.RiakIndexes

     * @return a {@link RiakIndexes} made of the values of the RiakIndex
     *         annotated fields and methods. For methods it is expected to be
     *         a Set&lt;Long&gt; or Set&lt;String&gt;
     */
    @SuppressWarnings("unchecked") public <T> RiakIndexes getIndexes(T obj) {
        final RiakIndexes riakIndexes = new RiakIndexes();

        for (RiakIndexField f : indexFields) {
            if (Set.class.isAssignableFrom(f.getType())) {
                final Type t = f.getField().getGenericType();
                if (t instanceof ParameterizedType) {
                    Class genericType = (Class)((ParameterizedType)t).getActualTypeArguments()[0];
                    if (String.class.equals(genericType)) {
                        riakIndexes.addBinSet(f.getIndexName(), (Set<String>)getFieldValue(f.getField(), obj));
                    } else if (Long.class.equals(genericType) ||Integer.class.equals(genericType)) {                       
                        riakIndexes.addIntSet(f.getIndexName(), (Set<Long>)getFieldValue(f.getField(), obj));
                    } else if (Integer.class.equals(genericType)) {
                        // Supporting Integer as legacy. All new code should use Long
                        Set<Integer> iSet = (Set<Integer>) getFieldValue(f.getField(), obj);
                        Set<Long> lSet = new HashSet<Long>();
                        for (Integer i : iSet) {
                            lSet.add(i.longValue());
                        }
                        riakIndexes.addIntSet(f.getIndexName(), lSet);
                    }
                }
            } else {
                final Object val = getFieldValue(f.getField(), obj);
                // null is not an index value
                if (val != null) {
                    if (val instanceof String) {
                        riakIndexes.add(f.getIndexName(), (String) val);
                    } else if (val instanceof Long)  {
                        riakIndexes.add(f.getIndexName(), (Long) val);
                    } else if (val instanceof Integer) {
                        // Supporting int / Integer for legacy. New code should use long / Long
                        riakIndexes.add(f.getIndexName(), ((Integer) val).longValue());
                    }
                }
            }
        }

        for (RiakIndexMethod m : indexMethods) {
            if (Set.class.isAssignableFrom(m.getType())) {
                final Type t = m.getMethod().getGenericReturnType();
                if (t instanceof ParameterizedType) {
                    final Object val = getMethodValue(m.getMethod(), obj);
                    if (val != null) {
                        final Class<?> genericType = (Class<?>) ((ParameterizedType) t).getActualTypeArguments()[0];
                        if (String.class.equals(genericType)) {
                            riakIndexes.addBinSet(m.getIndexName(), (Set<String>) val);
                        } else if (Long.class.equals(genericType)) {
                            riakIndexes.addIntSet(m.getIndexName(), (Set<Long>) val);
                        } else if (Integer.class.equals(genericType)) {
                            // Supporting Integer as legacy. All new code should use Long
                            Set<Integer> iSet = (Set<Integer>) val;
                            Set<Long> lSet = new HashSet<Long>();
                            for (Integer i : iSet) {
                                lSet.add(i.longValue());
                            }
                            riakIndexes.addIntSet(m.getIndexName(), lSet);
                        }
                    }
                }
            } else {
                final Object val = getMethodValue(m.getMethod(), obj);
                // null is not an index value
                if (val != null) {
                    if (val instanceof String) {
                        riakIndexes.add(m.getIndexName(), (String) val);
                    } else if (val instanceof Long) {
                        riakIndexes.add(m.getIndexName(), (Long) val);
                    } else if (val instanceof Integer) {
                        riakIndexes.add(m.getIndexName(), ((Integer) val).longValue());
                    }
                }
            }
        }
       
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.