Scans through an Amazon DynamoDB table and returns a single page of
matching results.
@param scanExpression The scan expression.
@return The scan results.
@see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#scanPage
549550
public ScanResultPage<T> scanPage(DynamoDBScanExpression scanExpression) {
        return mapper.<T>scanPage(model.targetType(), scanExpression);
    }
401663
private Object getValue(PageContext pc, SQL sql, Query querySource, int row, Collection.Key key, Object value) throws PageException {
	if (value instanceof ZSelectItem) return executeExp(pc, sql, querySource, ((ZSelectItem) value).getExpression(), row);
	return querySource.getAt(key, row);
    }
686445
static QuerySpecification getCheckSelect(Session session, Table t,
            Expression e) {

        CompileContext     compileContext = new CompileContext(session);
        QuerySpecification s = new QuerySpecification(compileContext);

        s.exprColumns    = new Expression[1];
        s.exprColumns[0] = EXPR_TRUE;

        RangeVariable range = new RangeVariable(t, null, null, null,
            compileContext);

        s.rangeVariables = new RangeVariable[]{ range };

        HsqlList unresolved = e.resolveColumnReferences(s.rangeVariables,
            null);

        ExpressionColumn.checkColumnsResolved(unresolved);
        e.resolveTypes(session, null);

        if (Type.SQL_BOOLEAN != e.getDataType()) {
            throw Error.error(ErrorCode.X_42568);
        }

        Expression condition = new ExpressionLogical(OpTypes.NOT, e);

        s.queryCondition = condition;

        s.resolveReferences(session);
        s.resolveTypes(session);

        return s;
    }
536573
public static Query withValue(String expression) {
        String[] parts = split(expression);
        if (parts != null) {
            String field = parts[0];
            String operator = parts[1];
            String value = parts[2];

            BinOp binOp = BinOp.getOp(operator);
            if (binOp != null) {
                return withValue(field, binOp, value);
            }
            NaryOp naryOp = NaryOp.getOp(operator);
            if (naryOp != null) {
                Literal[] values = Literal.values(value.substring(1, value.length() - 1).split("\\s*,\\s*"));
                return withValues(field, naryOp, values);
            }
        }
        throw new IllegalArgumentException("'" + expression + "' is incorrect");
    }
873311
private void readPage(byte[] buffer, Table table)
   {
      int magicNumber = getShort(buffer, 0);
      if (magicNumber == 0x4400)
      {
         //System.out.println(ByteArrayHelper.hexdump(buffer, 0, 6, true, 16, ""));
         int recordSize = m_definition.getRecordSize();
         RowValidator rowValidator = m_definition.getRowValidator();
         String primaryKeyColumnName = m_definition.getPrimaryKeyColumnName();

         int index = 6;
         while (index + recordSize <= buffer.length)
         {
            //System.out.println(ByteArrayHelper.hexdump(buffer, index, recordSize, true, 16, ""));
            int btrieveValue = getShort(buffer, index);
            if (btrieveValue != 0)
            {
               Map<String, Object> row = new HashMap<String, Object>();
               row.put("ROW_VERSION", Integer.valueOf(btrieveValue));
               for (ColumnDefinition column : m_definition.getColumns())
               {
                  Object value = column.read(index, buffer);
                  //System.out.println(column.getName() + ": " + value);
                  row.put(column.getName(), value);
               }

               if (rowValidator == null || rowValidator.validRow(row))
               {
                  table.addRow(primaryKeyColumnName, row);
               }
            }
            index += recordSize;
         }
      }
   }
809941
private IndexExpression indexedExpression(List<IndexExpression> clause) {
        for (IndexExpression indexExpression : clause) {
            ByteBuffer columnName = indexExpression.column;
            if (indexedColumnName.equals(columnName)) {
                return indexExpression;
            }
        }
        return null;
    }
1145986
public StashRowIterator scan(String table)
            throws StashNotAvailableException, TableNotStashedException {
        List<StashSplit> splits = getSplits(table);
        return new StashScanIterator(_s3, _bucket, _rootPath, splits);
    }
188610
public StashRowIterable scan(final String table)
            throws StashNotAvailableException, TableNotStashedException {
        try {
            final StashReader stashReader = _stashReader.getLockedView();

            return new StashRowIterable() {
                @Override
                protected StashRowIterator createStashRowIterator() {
                    return stashReader.scan(table);
                }
            };
        } catch (TableNotStashedException e) {
            throw propagateTableNotStashed(e);
        }
    }
589988
public ArrayNode filter(ComparisonExpression expression) {
		
		ArrayNode result = new ObjectMapper().createArrayNode();
		if (node.isArray()) {
			Iterator<JsonNode> iterator = node.iterator();
			int validObjectsCount = 0;
			int topCount=0;
			while (iterator.hasNext()) {
				JsonNode curNode = iterator.next();
				if (expression==null || (expression!=null && new Query(curNode).is(expression))) {
					validObjectsCount++;
					if (this.skip != null && this.skip.intValue() > 0 && this.skip.intValue() >= validObjectsCount) {
						continue;
					}

					if (this.top != null && topCount >= this.top.intValue()) {
						break;
					}
					result.add(curNode);
					topCount++;
				}
			}
		} else {
			throw new UnsupportedExprException("Filters are only supported on ArrayNode objects");
		}
		return result;
	}
1202994
@Override
	public Scan open() {
		// throws an exception if p is not a tableplan.
		TableScan ts = (TableScan) tp.open();
		Index idx = ii.open(tx);
		return new IndexSelectScan(idx, 
				new SearchRange(ii.fieldNames(), schema(), searchRanges), ts);
	}
1210556
public <T> PaginatedQueryList<T> query(Class<T> clazz, DynamoDBQueryExpression queryExpression) {
        return query(clazz, queryExpression, config);
    }
640927
@Override
	public Expression getValueExpression() {
		return ifThenElse(equalTo(count, literal(0L)), nullOf(getResultType()), div(sum, count));
	}
361542
public String getValueAsString(Expression expr) throws PageException {
	expr.writeOut(this, Expression.MODE_REF);
	return Caster.toString(stack.pop());
    }
323210
@Override
    public R visitLambdaExpression(LambdaExpressionTree node, P p) {
        R r = scan(node.getParameters(), p);
        r = scanAndReduce(node.getBody(), p, r);
        return r;
    }
554577
public static Iterable<Map<String, Object>> scan(DataStore dataStore,
                                                     String table,
                                                     boolean includeDeletes,
                                                     ReadConsistency consistency) {
        return scan(dataStore, table, null, Long.MAX_VALUE, includeDeletes, consistency);
    }
1305034
private Scanner getScanner(final byte[] table) throws HBaseException {
    short metric_width = TSDB.metrics_width();
    final byte[] start_row = 
      Arrays.copyOfRange(Bytes.fromLong(start_id), 8 - metric_width, 8);
    final byte[] end_row = 
      Arrays.copyOfRange(Bytes.fromLong(end_id), 8 - metric_width, 8);
    final Scanner scanner = tsdb.getClient().newScanner(table);
    scanner.setStartKey(start_row);
    scanner.setStopKey(end_row);
    scanner.setFamily(NAME_FAMILY);
    return scanner;
  }
1305935
private List<Audit> _scanRecords(BigInteger entityId, int limit, ScanFilter filter) {
		
		final Scanner scanner = _client.newScanner(tablename);

		String startRow = entityId.toString();
        String stopRow = HBaseUtils._plusOne(startRow);
        scanner.setStartKey(startRow);
        scanner.setStopKey(stopRow);
        scanner.setMaxNumRows(Math.min(limit, MAX_NUM_ROWS));
        scanner.setFilter(filter);
		
		final List<Audit> records = new ArrayList<>(limit);
        final Deferred<List<Audit>> results = new Deferred<List<Audit>>();
		
        final class ScannerCB implements Callback<Object, ArrayList<ArrayList<KeyValue>>> {

            /**
             * Scans rows.
             *
             * @return  The list of audit records.
             */
            public Object scan() {
            	_logger.debug("Getting next set of rows.");
                return scanner.nextRows().addCallback(this);
            }

            @Override
            public Object call(ArrayList<ArrayList<KeyValue>> rows) throws Exception {
            	_logger.debug("Inside nextRows() callback..");
                try {
                    if (rows == null) {
                        results.callback(records);
                        scanner.close();
                        return null;
                    }
                    
                    _logger.debug("Retrieved " + rows.size() + " rows.");
                    
                    for (ArrayList<KeyValue> row : rows) {
                        for(KeyValue kv : row) {
                            byte[] value = kv.value();
                        	   List<Audit> audits = _mapper.readValue(value, new TypeReference<List<Audit>>() {});
                        	   records.addAll(audits);
                        }
                        
                        if (records.size() >= limit) {
                            results.callback(records);
                            scanner.close();
                            return null;
                        }
                    }
                    return scan();
                } catch (Exception e) {
                    scanner.close();
                    return null;
                }
            }
        }
        
        new ScannerCB().scan();
        
        try {
			List<Audit> audits = results.join(SCAN_TIMEOUT_MS);
			if(audits.size() <= limit) {
				return audits;
			}
			
			return audits.subList(0, limit);
			
		} catch (InterruptedException e) {
			throw new SystemException("Interrupted while waiting to obtain results for jobId: " + entityId, e);
		} catch (TimeoutException e) {
			_logger.warn("Timed out while waiting to obtain results for jobId: {}. Will return an empty list.", entityId);
			return Collections.emptyList();
		} catch (Exception e) {
			throw new SystemException("Exception occurred in getting results for jobId: " + entityId, e);
		}
	}