Search in sources :

Example 16 with Integer

use of java.lang.Integer in project storio by pushtorefresh.

the class BoxedTypesMethodsConstructorStorIOSQLiteGetResolver method mapFromCursor.

/**
     * {@inheritDoc}
     */
@Override
@NonNull
public BoxedTypesMethodsConstructor mapFromCursor(@NonNull Cursor cursor) {
    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }
    BoxedTypesMethodsConstructor object = new BoxedTypesMethodsConstructor(field1, field2, field3, field4, field5, field6);
    return object;
}
Also used : Integer(java.lang.Integer) Float(java.lang.Float) Long(java.lang.Long) Boolean(java.lang.Boolean) Double(java.lang.Double) Short(java.lang.Short) NonNull(android.support.annotation.NonNull) Override(java.lang.Override)

Example 17 with Integer

use of java.lang.Integer in project storio by pushtorefresh.

the class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver method mapFromCursor.

/**
     * {@inheritDoc}
     */
@Override
@NonNull
public BoxedTypesMethodsFactoryMethodIgnoreNull mapFromCursor(@NonNull Cursor cursor) {
    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }
    BoxedTypesMethodsFactoryMethodIgnoreNull object = BoxedTypesMethodsFactoryMethodIgnoreNull.create(field1, field2, field3, field4, field5, field6);
    return object;
}
Also used : Integer(java.lang.Integer) Float(java.lang.Float) Long(java.lang.Long) Boolean(java.lang.Boolean) Double(java.lang.Double) Short(java.lang.Short) NonNull(android.support.annotation.NonNull) Override(java.lang.Override)

Example 18 with Integer

use of java.lang.Integer in project storio by pushtorefresh.

the class BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver method mapFromCursor.

/**
     * {@inheritDoc}
     */
@Override
@NonNull
public BoxedTypesMethodsFactoryMethod mapFromCursor(@NonNull Cursor cursor) {
    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }
    BoxedTypesMethodsFactoryMethod object = BoxedTypesMethodsFactoryMethod.create(field1, field2, field3, field4, field5, field6);
    return object;
}
Also used : Integer(java.lang.Integer) Float(java.lang.Float) Long(java.lang.Long) Boolean(java.lang.Boolean) Double(java.lang.Double) Short(java.lang.Short) NonNull(android.support.annotation.NonNull) Override(java.lang.Override)

Example 19 with Integer

use of java.lang.Integer in project geode by apache.

the class PRQueryProcessor method doBucketQuery.

/**
   * @throws ForceReattemptException if bucket was moved so caller should try query again
   */
private void doBucketQuery(final Integer bId, final PartitionedRegionDataStore prds, final DefaultQuery query, final Object[] params, final PRQueryResultCollector rq) throws QueryException, ForceReattemptException, InterruptedException {
    final BucketRegion bukRegion = (BucketRegion) prds.localBucket2RegionMap.get(bId);
    final PartitionedRegion pr = prds.getPartitionedRegion();
    try {
        pr.checkReadiness();
        if (bukRegion == null) {
            if (pr.isLocallyDestroyed || pr.isClosed) {
                throw new RegionDestroyedException("PR destroyed during query", pr.getFullPath());
            } else {
                throw new ForceReattemptException("Bucket id " + pr.bucketStringForLogs(bId) + " not found on VM " + pr.getMyId());
            }
        }
        bukRegion.waitForData();
        SelectResults results = null;
        // If the query has LIMIT and is not order by, apply the limit while building the result set.
        int limit = -1;
        if (query.getSimpleSelect().getOrderByAttrs() == null) {
            limit = query.getLimit(params);
        }
        if (!bukRegion.isBucketDestroyed()) {
            // If the result queue has reached the limit, no need to
            // execute the query. Handle the bucket destroy condition
            // and add the end bucket token.
            int numBucketsProcessed = getNumBucketsProcessed();
            if (limit < 0 || (rq.size() - numBucketsProcessed) < limit) {
                results = (SelectResults) query.prExecuteOnBucket(params, pr, bukRegion);
                this.resultType = results.getCollectionType().getElementType();
            }
            if (!bukRegion.isBucketDestroyed()) {
                // here before we can start adding to the results queue
                if (results != null) {
                    for (Object r : results) {
                        if (r == null) {
                            // Blocking queue does not support adding null.
                            rq.put(DefaultQuery.NULL_RESULT);
                        } else {
                            // Avoid if query is distinct as this Integer could be a region value.
                            if (!query.getSimpleSelect().isDistinct() && query.getSimpleSelect().isCount() && r instanceof Integer) {
                                if ((Integer) r != 0) {
                                    rq.put(r);
                                }
                            } else {
                                rq.put(r);
                            }
                        }
                        // Check if limit is satisfied.
                        if (limit >= 0 && (rq.size() - numBucketsProcessed) >= limit) {
                            break;
                        }
                    }
                }
                rq.put(new EndOfBucket(bId));
                this.incNumBucketsProcessed();
                // success
                return;
            }
        }
        // if we get here then the bucket must have been moved
        checkForBucketMoved(bId, bukRegion, pr);
        Assert.assertTrue(false, "checkForBucketMoved should have thrown ForceReattemptException");
    } catch (RegionDestroyedException rde) {
        checkForBucketMoved(bId, bukRegion, pr);
        throw rde;
    } catch (QueryException qe) {
        checkForBucketMoved(bId, bukRegion, pr);
        throw qe;
    }
}
Also used : Integer(java.lang.Integer) QueryException(org.apache.geode.cache.query.QueryException) SelectResults(org.apache.geode.cache.query.SelectResults) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException)

Aggregations

Integer (java.lang.Integer)19 Double (java.lang.Double)9 Float (java.lang.Float)9 Override (java.lang.Override)9 Short (java.lang.Short)9 NonNull (android.support.annotation.NonNull)8 Boolean (java.lang.Boolean)8 Long (java.lang.Long)8 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IllegalArgumentException (java.lang.IllegalArgumentException)1 String (java.lang.String)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayDeque (java.util.ArrayDeque)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1