本文整理汇总了Java中com.microsoft.azure.storage.table.TableQuery类的典型用法代码示例。如果您正苦于以下问题:Java TableQuery类的具体用法?Java TableQuery怎么用?Java TableQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableQuery类属于com.microsoft.azure.storage.table包,在下文中一共展示了TableQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: partitionRangeQuery
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
/**
* Demonstrate a partition range query whereby we are searching within a partition for a set of entities that are within a specific range.
*
* @param table The {@link CloudTable} object
* @param partitionKey The partition within which to search
* @param startRowKey The lowest bound of the row key range within which to search
* @param endRowKey The highest bound of the row key range within which to search
*
* @throws StorageException
*/
private static void partitionRangeQuery(CloudTable table, String partitionKey, String startRowKey, String endRowKey) throws StorageException {
// Create the range scan query
TableQuery<CustomerEntity> rangeQuery = TableQuery.from(CustomerEntity.class).where(
TableQuery.combineFilters(
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.EQUAL, partitionKey),
TableQuery.Operators.AND,
TableQuery.combineFilters(
TableQuery.generateFilterCondition("RowKey", QueryComparisons.GREATER_THAN_OR_EQUAL, startRowKey),
TableQuery.Operators.AND,
TableQuery.generateFilterCondition("RowKey", QueryComparisons.LESS_THAN_OR_EQUAL, endRowKey))));
// Iterate through the results
for (CustomerEntity entity : table.execute(rangeQuery)) {
System.out.println(String.format("\tCustomer: %s,%s\t%s\t%s\t%s", entity.getPartitionKey(), entity.getRowKey(), entity.getEmail(), entity.getHomePhoneNumber(), entity.getWorkPhoneNumber()));
}
}
示例2: generateCombinedFilterConditions
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
public String generateCombinedFilterConditions() {
String filter = "";
if (isValidFilterExpession()) {
for (int idx = 0; idx < column.getValue().size(); idx++) {
String c = column.getValue().get(idx);
String cfn = function.getValue().get(idx);
String cop = predicate.getValue().get(idx);
String typ = fieldType.getValue().get(idx);
String f = Comparison.getQueryComparisons(cfn);
String v = operand.getValue().get(idx);
String p = Predicate.getOperator(cop);
EdmType t = SupportedFieldType.getEdmType(typ);
String flt = TableQuery.generateFilterCondition(c, f, v, t);
if (!filter.isEmpty()) {
filter = TableQuery.combineFilters(filter, p, flt);
} else {
filter = flt;
}
}
}
return filter;
}
示例3: getEndpointSchema
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
@Override
public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException {
try {
AzureStorageTableService tableService = new AzureStorageTableService(getAzureConnection(container));
TableQuery<DynamicTableEntity> partitionQuery;
partitionQuery = TableQuery.from(DynamicTableEntity.class).take(1);
Iterable<DynamicTableEntity> entities = tableService.executeQuery(schemaName, partitionQuery);
if (entities.iterator().hasNext()) {
DynamicTableEntity result = entities.iterator().next();
return AzureStorageAvroRegistry.get().inferSchema(result);
} else {
return null;
}
} catch (InvalidKeyException | URISyntaxException | StorageException e) {
LOGGER.error(e.getLocalizedMessage());
throw new ComponentException(e);
}
}
示例4: createFilter
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
public String createFilter(final Integer minLevel, final String traceId, final String exceptionId)
{
final List<String> filters = new ArrayList<>();
if (minLevel != null)
filters.add(TableQuery.generateFilterCondition("level", TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL, minLevel));
if (traceId != null)
{
filters.add(TableQuery.generateFilterCondition("traceId",
TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL,
traceId));
filters.add(TableQuery.generateFilterCondition("traceId", TableQuery.QueryComparisons.LESS_THAN, increment(traceId)));
}
if (exceptionId != null)
filters.add(TableQuery.generateFilterCondition("exception-id", TableQuery.QueryComparisons.EQUAL, exceptionId));
return andFilters(filters);
}
示例5: search
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
public List<LogLineTableEntity> search(final DateTime from, DateTime to, final String filter, final long limit)
{
final String partitionAndRowQuery = createPartitionAndRowQuery(from, to);
final String logLineFilter = andFilters(partitionAndRowQuery, filter);
if (log.isTraceEnabled())
log.trace("Search logs: " + logLineFilter);
final Iterable<LogLineTableEntity> resultset = logdata.execute(TableQuery.from(LogLineTableEntity.class)
.where(logLineFilter));
// Fetch back the requested number of results
// N.B. we need to sort them according to when they were emitted because in Azure they're broken up
// by service by time
List<LogLineTableEntity> results = StreamSupport.stream(resultset.spliterator(), false)
.limit(limit)
.sorted(Comparator.comparing(LogLineTableEntity:: getDateTimeWhen))
.collect(Collectors.toList());
return results;
}
示例6: BasicQuery
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
/**
* Illustrates how to form and execute a query operation.
*
* @throws StorageException
*/
public static void BasicQuery() throws StorageException {
// Retrieve a single entity.
// Retrieve the entity with partition key of "Smith" and row key of "Jeff".
TableOperation retrieveSmithJeff = TableOperation.retrieve("Smith", "Jeff", CustomerEntity.class);
// Submit the operation to the table service and get the specific entity.
@SuppressWarnings("unused")
CustomerEntity specificEntity = table.execute(retrieveSmithJeff).getResultAsType();
// Retrieve all entities in a partition.
// Create a filter condition where the partition key is "Smith".
String partitionFilter = TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.EQUAL, "Smith");
// Specify a partition query, using "Smith" as the partition key filter.
TableQuery<CustomerEntity> partitionQuery = TableQuery.from(CustomerEntity.class).where(partitionFilter);
// Loop through the results, displaying information about the entity.
for (CustomerEntity entity : table.execute(partitionQuery)) {
System.out.println(entity.getPartitionKey() + " " + entity.getRowKey() + "\t" + entity.getEmail() + "\t"
+ entity.getPhoneNumber());
}
}
示例7: getUserForTimLocalId
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
@Override
public Optional<User> getUserForTimLocalId(String userId) throws AuthenticationUnavailableException {
String query = "(PartitionKey eq 'users') and (id eq '" + userId + "')";
Iterator<DynamicTableEntity> users = table.execute(TableQuery.from(DynamicTableEntity.class)
.where(query)
.take(2)).iterator();
if (users.hasNext()) {
Optional<User> result = Optional.of(propsToObject(users.next()));
if (users.hasNext()) {
LOG.error("Multiple items found for query " + query);
}
return result;
} else {
return Optional.empty();
}
}
示例8: deleteVreAuthorizations
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
@Override
public void deleteVreAuthorizations(String vreId) throws AuthorizationUnavailableException {
String condition = TableQuery.generateFilterCondition(
"PartitionKey",
TableQuery.QueryComparisons.EQUAL,
vreId
);
TableBatchOperation deletes = new TableBatchOperation();
for (DynamicTableEntity entity : table.execute(TableQuery.from(DynamicTableEntity.class).where(condition))) {
deletes.delete(entity);
}
try {
table.execute(deletes);
} catch (StorageException e) {
LOG.error("deleteVreAuthorizations failed", e);
throw new AuthorizationUnavailableException("Could not delete authorizations");
}
}
示例9: partitionScan
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
/**
* Demonstrate a partition scan whereby we are searching for all the entities within a partition.
* Note this is not as efficient as a range scan - but definitely more efficient than a full table scan.
*
* @param table The {@link CloudTable} object
* @param partitionKey The partition within which to search
*
* @throws StorageException
*/
private static void partitionScan(CloudTable table, String partitionKey) throws StorageException {
// Create the partition scan query
TableQuery<CustomerEntity> partitionScanQuery = TableQuery.from(CustomerEntity.class).where(
(TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.EQUAL, partitionKey)));
// Iterate through the results
for (CustomerEntity entity : table.execute(partitionScanQuery)) {
System.out.println(String.format("\tCustomer: %s,%s\t%s\t%s\t%s", entity.getPartitionKey(), entity.getRowKey(), entity.getEmail(), entity.getHomePhoneNumber(), entity.getWorkPhoneNumber()));
}
}
示例10: start
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
@Override
public boolean start() throws IOException {
String tableName = properties.tableName.getValue();
String filter = "";
if (properties.useFilterExpression.getValue()) {
filter = properties.filterExpression.generateCombinedFilterConditions();
LOGGER.debug(i18nMessages.getMessage("debug.FilterApplied", filter));
}
try {
TableQuery<DynamicTableEntity> partitionQuery;
if (filter.isEmpty()) {
partitionQuery = TableQuery.from(DynamicTableEntity.class);
} else {
partitionQuery = TableQuery.from(DynamicTableEntity.class).where(filter);
}
// Using execute will automatically and lazily follow the continuation tokens from page to page of results.
// So, we bypass the 1000 entities limit.
Iterable<DynamicTableEntity> entities = tableService.executeQuery(tableName, partitionQuery);
recordsIterator = entities.iterator();
if (recordsIterator.hasNext()) {
started = true;
result.totalCount++;
current = recordsIterator.next();
}
} catch (InvalidKeyException | URISyntaxException | StorageException e) {
LOGGER.error(e.getLocalizedMessage());
if (properties.dieOnError.getValue()) {
throw new ComponentException(e);
}
}
return started;
}
示例11: allDependenciesFor
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
@Override
public Collection<DependencyModel> allDependenciesFor(DependencyId dependencyId, ServiceId serviceId) {
try (Timer.Context timerContext = dependencyConfigs.time()) {
return Entities.toDependencyModelList(tableClient.search(
TableId.DEPENDENCY, TableQuery
.from(DependencyEntity.class)
.where(TableQuery.combineFilters(
partitionEquals(dependencyId),
TableQuery.Operators.AND,
serviceIdEquals(serviceId)))));
}
}
示例12: allServiceEntities
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
private ImmutableList<ServiceEntity> allServiceEntities(ServiceId serviceId) {
try (Timer.Context timerContext = listService.time()) {
return tableClient.search(TableId.SERVICE, TableQuery
.from(ServiceEntity.class)
.where(partitionKeyEquals(serviceId)));
}
}
示例13: partitionKeyEquals
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
private static String partitionKeyEquals(ServiceId serviceId) {
return TableQuery
.generateFilterCondition(
PARTITION_KEY,
TableQuery.QueryComparisons.EQUAL,
serviceId.getId());
}
示例14: getConfiguration
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
private ImmutableList<DependencyEntity> getConfiguration(DependencyId dependencyId, long targetTimeStamp) {
try (Timer.Context timerContext = dependencyConfigs.time()) {
return tableClient.search(TableId.DEPENDENCY, TableQuery
.from(DependencyEntity.class)
.where(TableQuery.combineFilters(
partitionEquals(dependencyId),
TableQuery.Operators.AND,
timestampEquals(targetTimeStamp))));
}
}
示例15: timestampEquals
import com.microsoft.azure.storage.table.TableQuery; //导入依赖的package包/类
private static String timestampEquals(long timestamp) {
return TableQuery.generateFilterCondition(
ROW_KEY,
TableQuery.QueryComparisons.EQUAL,
String.valueOf(timestamp)
);
}