Package com.basho.riak.client.core.query.indexes

Examples of com.basho.riak.client.core.query.indexes.BigIntIndex


                        }
                    }
                    break;
                case SET_BIG_INT:
                case BIG_INT:
                    BigIntIndex bigIntIndex = container.getIndex(BigIntIndex.named(f.getIndexName()));
                    if (val != null)
                    {
                        if (f.getFieldType() == RiakIndexField.FieldType.SET_BIG_INT)
                        {
                            bigIntIndex.add((Set<BigInteger>) val);
                        }
                        else
                        {
                            bigIntIndex.add((BigInteger) val);
                        }
                    }
                    break;
                case SET_RAW:
                case RAW:
                {
                    // We want to create the index regardless
                    IndexType iType = IndexType.typeFromFullname(f.getIndexName());
                    RawIndex rawIndex = container.getIndex(RawIndex.named(f.getIndexName(), iType));
                    if (val != null)
                    {
                        if (f.getFieldType() == RiakIndexField.FieldType.SET_RAW)
                        {
                            for (byte[] bytes : (Set<byte[]>) val)
                            {
                                rawIndex.add(BinaryValue.create(bytes));
                            }
                        }
                        else
                        {
                            rawIndex.add(BinaryValue.create((byte[])val));
                        }
                    }
                }
                default:
                    break;
            }
           
        }

        for (RiakIndexMethod m : indexMethods)
        {
            Object val;
           
            switch (m.getMethodType())
            {
                case SET_LONG_GETTER:
                case LONG_GETTER:
                    val = getMethodValue(m.getMethod(), obj);
                    // We want to create the index regardless
                    LongIntIndex index = container.getIndex(LongIntIndex.named(m.getIndexName()));
                    if (val != null)
                    {
                        if (m.getMethodType() == RiakIndexMethod.MethodType.SET_LONG_GETTER)
                        {
                            index.add((Set<Long>) val);
                        }
                        else
                        {
                            index.add((Long) val);
                        }
                    }
                    break;
                case SET_STRING_GETTER:
                case STRING_GETTER:
                    val = getMethodValue(m.getMethod(), obj);
                    // We want to create the index regardless
                    StringBinIndex stringBinIndex = container.getIndex(StringBinIndex.named(m.getIndexName()));
                    if (val != null)
                    {
                        if (m.getMethodType() == RiakIndexMethod.MethodType.SET_STRING_GETTER)
                        {
                            stringBinIndex.add((Set<String>) val);
                        }
                        else
                        {
                            stringBinIndex.add((String) val);
                        }
                    }
                    break;
                case SET_BIG_INT_GETTER:
                case BIG_INT_GETTER:
                    val = getMethodValue(m.getMethod(), obj);
                    // We want to create the index regardless
                    BigIntIndex bigIntIndex = container.getIndex(BigIntIndex.named(m.getIndexName()));
                    if (val != null)
                    {
                        if (m.getMethodType() == RiakIndexMethod.MethodType.SET_BIG_INT_GETTER)
                        {
                            bigIntIndex.add((Set<BigInteger>) val);
                        }
                        else
                        {
                            bigIntIndex.add((BigInteger) val);
                        }
                    }
                    break;
                case SET_RAW_GETTER:
                case RAW_GETTER:
View Full Code Here


                    StringBinIndex stringIndex = indexes.getIndex(StringBinIndex.named(f.getIndexName()));
                    val = stringIndex.values();
                    break;
                case SET_BIG_INT:
                case BIG_INT:
                    BigIntIndex bigIntIndex = indexes.getIndex(BigIntIndex.named(f.getIndexName()));
                    val = bigIntIndex.values();
                    break;
                case SET_RAW:
                case RAW:
                    IndexType iType = IndexType.typeFromFullname(f.getIndexName());
                    RawIndex rawIndex = indexes.getIndex((RawIndex.named(f.getIndexName(), iType)));
                    // Convert from BinaryValue to bytes
                    Set<byte[]> byteSet = new HashSet<byte[]>();
                    for (BinaryValue bv : rawIndex.values())
                    {
                        byteSet.add(bv.unsafeGetValue());
                    }
                    val = byteSet;
                    break;
                default:
                    break;
            }
           
            if (val != null)
            {
                if (f.getFieldType() == RiakIndexField.FieldType.LONG ||
                      f.getFieldType() == RiakIndexField.FieldType.STRING ||
                      f.getFieldType() == RiakIndexField.FieldType.BIG_INT ||
                      f.getFieldType() == RiakIndexField.FieldType.RAW)
                {
                    if (!val.isEmpty())
                    {
                        setFieldValue(f.getField(), obj, val.iterator().next()); // take the first value
                    }
                }
                else
                {
                    setFieldValue(f.getField(), obj, val);
                }
            }
        }

        for (RiakIndexMethod m : indexMethods)
        {
            Set<?> val = null;
           
            switch(m.getMethodType())
            {
                case SET_LONG_SETTER:
                case LONG_SETTER:
                    LongIntIndex longIndex = indexes.getIndex(LongIntIndex.named(m.getIndexName()));
                    val = longIndex.values();
                    break;
                case SET_STRING_SETTER:
                case STRING_SETTER:
                    StringBinIndex stringIndex = indexes.getIndex(StringBinIndex.named(m.getIndexName()));
                    val = stringIndex.values();
                    break;
                case SET_BIG_INT_SETTER:
                case BIG_INT_SETTER:
                    BigIntIndex bigIntIndex = indexes.getIndex(BigIntIndex.named(m.getIndexName()));
                    val = bigIntIndex.values();
                    break;
                case SET_RAW_SETTER:
                case RAW_SETTER:
                    IndexType iType = IndexType.typeFromFullname(m.getIndexName());
                    RawIndex rawIndex = indexes.getIndex(RawIndex.named(m.getIndexName(), iType));
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.indexes.BigIntIndex

Copyright © 2018 www.massapicom. 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.