@Override public Status scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { try { String whereStr = String.format("(PartitionKey eq '%s') and (RowKey ge '%s')", partitionKey, startkey); TableQuery<DynamicTableEntity> scanQuery = new TableQuery<DynamicTableEntity>(DynamicTableEntity.class) .where(whereStr).take(recordcount); int cnt = 0; for (DynamicTableEntity entity : cloudTable.execute(scanQuery)) { HashMap<String, EntityProperty> properties = entity.getProperties(); HashMap<String, ByteIterator> cur = new HashMap<String, ByteIterator>(); for (Entry<String, EntityProperty> entry : properties.entrySet()) { String fieldName = entry.getKey(); ByteIterator fieldVal = new ByteArrayByteIterator(entry.getValue().getValueAsByteArray()); if (fields == null || fields.contains(fieldName)) { cur.put(fieldName, fieldVal); } } result.add(cur); if (++cnt == recordcount) { break; } } return Status.OK; } catch (Exception e) { return Status.ERROR; } }
/** * A static factory method that constructs a {@link TableQuery} instance and defines its table entity type. The * method returns the {@link TableQuery} instance reference, allowing additional methods to be chained to modify the * query. * <p> * The created {@link TableQuery} instance is specialized for table entities of the specified class type T. Callers * may specify {@link TableServiceEntity} <code>.class</code> as the class type parameter if no more specialized * type is required. * * @param clazzType * The <code>java.lang.Class</code> of the class <code>T</code> implementing the {@link TableEntity} * interface that represents the table entity type for the query. * * @return * The {@link TableQuery} instance with the entity type specialization set. * */ public static <T extends TableEntity> TableQuery<T> from(final Class<T> clazzType) { return new TableQuery<T>(clazzType); }
/** * A static factory method that constructs a {@link TableQuery} instance and defines its table entity type. The * method returns the {@link TableQuery} instance reference, allowing additional methods to be chained to modify the * query. * <p> * The created {@link TableQuery} instance is specialized for table entities of the specified class type T. Callers * may specify {@link TableServiceEntity} <code>.class</code> as the class type parameter if no more specialized * type is required. * * @param clazzType * The <code>java.lang.Class</code> of the class <code>T</code> implementing the {@link TableEntity} * interface that represents the table entity type for the query. * * @return * The {@link TableQuery} instance with the entity type specialization set. * */ public static <T extends TableEntity> TableQuery<T> from(final Class<T> clazzType) { return new TableQuery<T>(clazzType); }