• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PropertyProjection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.appengine.api.datastore.PropertyProjection的典型用法代码示例。如果您正苦于以下问题:Java PropertyProjection类的具体用法?Java PropertyProjection怎么用?Java PropertyProjection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropertyProjection类属于com.google.appengine.api.datastore包,在下文中一共展示了PropertyProjection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: projectionQuery_grouping_filtersDuplicates

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void projectionQuery_grouping_filtersDuplicates() {
  putTestData("some duplicate", 0L);
  putTestData("some duplicate", 0L);
  putTestData("too big", 1L);

  // [START grouping]
  Query q = new Query("TestKind");
  q.addProjection(new PropertyProjection("A", String.class));
  q.addProjection(new PropertyProjection("B", Long.class));
  q.setDistinct(true);
  q.setFilter(Query.FilterOperator.LESS_THAN.of("B", 1L));
  q.addSort("B", Query.SortDirection.DESCENDING);
  q.addSort("A");
  // [END grouping]

  List<Entity> entities =
      datastore.prepare(q).asList(FetchOptions.Builder.withLimit(5));
  assertThat(entities).hasSize(1);
  Entity entity = entities.get(0);
  assertThat((String) entity.getProperty("A")).named("entity.A").isEqualTo("some duplicate");
  assertThat((long) entity.getProperty("B")).named("entity.B").isEqualTo(0L);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:24,代码来源:ProjectionTest.java


示例2: projectionQuery_grouping_filtersDuplicates

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void projectionQuery_grouping_filtersDuplicates() {
  putTestData("some duplicate", 0L);
  putTestData("some duplicate", 0L);
  putTestData("too big", 1L);

  // [START grouping]
  Query q = new Query("TestKind");
  q.addProjection(new PropertyProjection("A", String.class));
  q.addProjection(new PropertyProjection("B", Long.class));
  q.setDistinct(true);
  q.setFilter(Query.FilterOperator.LESS_THAN.of("B", 1L));
  q.addSort("B", Query.SortDirection.DESCENDING);
  q.addSort("A");
  // [END grouping]

  List<Entity> entities = datastore.prepare(q).asList(FetchOptions.Builder.withLimit(5));
  assertThat(entities).hasSize(1);
  Entity entity = entities.get(0);
  assertThat((String) entity.getProperty("A")).named("entity.A").isEqualTo("some duplicate");
  assertThat((long) entity.getProperty("B")).named("entity.B").isEqualTo(0L);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:ProjectionTest.java


示例3: getRootPipelinesDisplayName

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Override
public Set<String> getRootPipelinesDisplayName() {
  Query query = new Query(JobRecord.DATA_STORE_KIND);
  query.addProjection(
      new PropertyProjection(JobRecord.ROOT_JOB_DISPLAY_NAME, String.class));
  query.setDistinct(true);
  final PreparedQuery preparedQuery = dataStore.prepare(query);
  return tryFiveTimes(new Operation<Set<String>>("getRootPipelinesDisplayName") {
    @Override
    public Set<String> call() {
      Set<String> pipelines = new LinkedHashSet<>();
      for (Entity entity : preparedQuery.asIterable()) {
        pipelines.add((String) entity.getProperty(JobRecord.ROOT_JOB_DISPLAY_NAME));
      }
      return pipelines;
    }
  });
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:19,代码来源:AppEngineBackEnd.java


示例4: getAsAppEngineQuery

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
public static Query getAsAppEngineQuery(SQuery2 squery) {
  Query query =
      hasAncestor(squery) ? new Query(squery.getKind(), KeyFactory.createKey(squery
          .getAncestorKind(), squery.getAncestorId())) : new Query(squery.getKind());

  // Set keys only
  if (squery.isKeysOnly())
    query.setKeysOnly();

  // Add projections
  for (Projection2 projection : squery.getProjections())
    query.addProjection(new PropertyProjection(projection.getPropertyName(), projection
        .getClazz()));

  // Add sort order
  for (Sort2 sorter : squery.getSorters())
    query.addSort(sorter.getPropertyName(), sorter.isAscending() ? Query.SortDirection.ASCENDING
        : Query.SortDirection.DESCENDING);

  // Add clause
  if (squery.getClause() != null)
    query.setFilter(buildClause(squery, squery.getClause()));
  return query;
}
 
开发者ID:csavelief,项目名称:gwt-sandbox,代码行数:25,代码来源:QueryConverter2.java


示例5: testProjectionQueryOnlyReturnsEntitiesContainingProjectedProperty

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjectionQueryOnlyReturnsEntitiesContainingProjectedProperty() throws Exception {
    String methodName = "testProjectionQueryOnlyReturnsEntitiesContainingProjectedProperty";
    Entity parent = createTestEntityWithUniqueMethodNameKey("Kind", methodName);
    Key key = parent.getKey();

    Entity e1 = createEntity("Kind", key)
        .withProperty("foo", "foo")
        .store();

    Entity e2 = createEntity("Kind", key)
        .withProperty("bar", "bar")
        .store();

    Query query = new Query("Kind")
        .setAncestor(key)
        .addProjection(new PropertyProjection("foo", String.class));

    List<Entity> results = service.prepare(query).asList(withDefaults());
    assertEquals(Collections.singletonList(e1), results);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:22,代码来源:QueryOptimizationsTest.java


示例6: testProjectionQueryReturnsEntitiesContainingProjectedPropertyEvenIfPropertyValueIsNull

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjectionQueryReturnsEntitiesContainingProjectedPropertyEvenIfPropertyValueIsNull() throws Exception {
    String methodName = "testProjectionQueryOnlyReturnsEntitiesContainingProjectedPropertyEvenIfPropertyValueIsNull";
    Entity parent = createTestEntityWithUniqueMethodNameKey("Kind", methodName);
    Key key = parent.getKey();

    Entity e1 = createEntity("Kind", key)
        .withProperty("foo", null)
        .store();

    Query query = new Query("Kind")
        .setAncestor(key)
        .addProjection(new PropertyProjection("foo", String.class));

    List<Entity> results = service.prepare(query).asList(withDefaults());
    assertEquals(Collections.singletonList(e1), results);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:18,代码来源:QueryOptimizationsTest.java


示例7: testProjectionsWithoutType

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjectionsWithoutType() throws Exception {
    String methodName = "testProjectionsWithoutType";
    Entity parent = createTestEntityWithUniqueMethodNameKey("Product", methodName);
    Key key = parent.getKey();

    Entity e = createEntity("Product", key)
        .withProperty("long", 123L)
        .store();

    Query query = new Query("Product")
        .setAncestor(key)
        .addProjection(new PropertyProjection("long", null));

    PreparedQuery preparedQuery = service.prepare(query);
    Entity result = preparedQuery.asSingleEntity();
    assertEquals(e.getKey(), result.getKey());

    RawValue rawValue = (RawValue) result.getProperty("long");
    assertEquals(Long.valueOf(123L), rawValue.asType(Long.class));
    assertEquals(Long.valueOf(123L), rawValue.asStrictType(Long.class));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:23,代码来源:QueryOptimizationsTest.java


示例8: testOrderOfReturnedResultsIsSameAsOrderOfElementsInInStatementWhenUsingProjections

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testOrderOfReturnedResultsIsSameAsOrderOfElementsInInStatementWhenUsingProjections() throws Exception {
    String methodName = "testOrderOfReturnedResultsIsSameAsOrderOfElementsInInStatementWhenUsingProjections";
    Entity parent = createTestEntityWithUniqueMethodNameKey("Product", methodName);
    Key key = parent.getKey();

    Entity b = createEntity("Product", key)
        .withProperty("name", "b")
        .withProperty("price", 1L)
        .store();

    Entity a = createEntity("Product", key)
        .withProperty("name", "a")
        .withProperty("price", 2L)
        .store();

    Query query = new Query("Product")
        .setAncestor(key)
        .addProjection(new PropertyProjection("price", Long.class))
        .setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("a", "b")));
    assertResultsInOrder(query, a, b);

    query = query.setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("b", "a")));
    assertResultsInOrder(query, b, a);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:26,代码来源:QueryOptimizationsTest.java


示例9: testWithPropertyProjection

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testWithPropertyProjection() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("geoptData", GeoPt.class));
    Filter filter1 = Query.CompositeFilterOperator.or(
        Query.FilterOperator.LESS_THAN.of("intList", 5),
        Query.FilterOperator.GREATER_THAN.of("intList", 90));
    Filter filter2 = Query.FilterOperator.EQUAL.of("intList", 52);
    query.setFilter(Query.CompositeFilterOperator.and(filter1, filter2));
    // sql statement
    String sql = "SELECT geoptData FROM " + kindName;
    sql += " WHERE ((intList < 5 or intList > 90) AND intList = 52)";
    sql += " AND __ancestor__ is " + rootKey;
    assertEquals(sql.toLowerCase(), query.toString().toLowerCase());
    // check query result
    List<Entity> results = service.prepare(query).asList(fo);
    Assert.assertTrue(results.size() > 0);
    assertEquals(new GeoPt((float) (2.12), (float) (2.98)), results.get(0).getProperty("geoptData"));
    for (Entity e : results) {
        assertEquals(1, e.getProperties().size());
        assertTrue(e.getProperties().containsKey("geoptData"));
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:24,代码来源:QueryTest.java


示例10: testProjectionQueryOperatingOnlyOnASinglePropertyDoesNotRequireConfiguredIndex

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjectionQueryOperatingOnlyOnASinglePropertyDoesNotRequireConfiguredIndex() throws Exception {
    executeQuery(new Query("Unindexed")
        .addProjection(new PropertyProjection("someProperty", null)));

    executeQuery(new Query("Unindexed")
        .addProjection(new PropertyProjection("someProperty", null))
        .setFilter(new Query.FilterPredicate("someProperty", GREATER_THAN, "a")));

    executeQuery(new Query("Unindexed")
        .addProjection(new PropertyProjection("someProperty", null))
        .setFilter(new Query.FilterPredicate("someProperty", GREATER_THAN, "a"))
        .addSort("someProperty"));

    executeQuery(new Query("Unindexed")
        .addProjection(new PropertyProjection("someProperty", null))
        .setFilter(new Query.FilterPredicate("someProperty", GREATER_THAN, "a"))
        .addSort("someProperty", Query.SortDirection.DESCENDING));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:20,代码来源:RequiredIndexesTest.java


示例11: testDistinctMix

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testDistinctMix() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringData", String.class));
    query.addProjection(new PropertyProjection("floatData", Float.class));
    query.setDistinct(true);
    assertEquals(7, service.prepare(query).countEntities(fo));
    assertTrue(query.getDistinct());
    // distinct false
    query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringData", String.class));
    query.addProjection(new PropertyProjection("floatData", Float.class));
    query.setDistinct(false);
    assertEquals(count, service.prepare(query).countEntities(fo));
    assertFalse(query.getDistinct());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:17,代码来源:DistinctTest.java


示例12: timeZonesArray

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
public static ArrayList<TimeZone> timeZonesArray() {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Query q = new Query(TimeZone.DatastoreProperties.KIND.getName());
    q.addProjection(new PropertyProjection(TimeZone.DatastoreProperties.TIME_ZONE_ID.getName(), String.class));
    PreparedQuery pq = datastore.prepare(q);
    ArrayList<TimeZone> timeZones = new ArrayList<TimeZone>();
    for(Entity result : pq.asIterable())
        timeZones.add(new TimeZone(result));
    return timeZones;
}
 
开发者ID:kerafill1116,项目名称:apollo-datastore,代码行数:11,代码来源:JSTLFunctions.java


示例13: testBasicQuery

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testBasicQuery() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringData", String.class));
    query.addProjection(new PropertyProjection("intData", Integer.class));
    String sql = "SELECT stringData, intData FROM " + kindName + " WHERE __ancestor__ is " + rootKey;
    assertEquals(sql.toLowerCase(), query.toString().toLowerCase());
    List<Entity> results = service.prepare(query).asList(fetchOption);
    assertEquals(count, results.size());
    for (Entity e : results) {
        assertEquals(2, e.getProperties().size());
        assertTrue(e.getProperties().containsKey("stringData"));
        assertTrue(e.getProperties().containsKey("intData"));
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:16,代码来源:IndexQueryTest.java


示例14: testListQuery

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testListQuery() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringList", String.class));
    query.addProjection(new PropertyProjection("intList", Integer.class));
    List<Entity> results = service.prepare(query).asList(fetchOption);
    // Distinct stringList data 2 * Distinct intList data 3 * entity's count 10
    assertEquals(60, results.size());
    Entity e = results.get(0);
    assertEquals(2, e.getProperties().size());
    assertTrue(e.getProperties().containsKey("stringList"));
    assertTrue(e.getProperties().containsKey("intList"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:14,代码来源:IndexQueryTest.java


示例15: testQueryOrder

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testQueryOrder() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("intData", Integer.class));
    query.addSort("stringData", Query.SortDirection.DESCENDING);
    List<Entity> results = service.prepare(query).asList(fetchOption);
    assertEquals(count, results.size());
    int first = new Integer(results.get(0).getProperty("intData").toString());
    int last = new Integer(results.get(count - 1).getProperty("intData").toString());
    assertTrue(first > last);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:12,代码来源:IndexQueryTest.java


示例16: testQueryFilter

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testQueryFilter() {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringData", String.class));
    query.setFilter(new FilterPredicate("intData", FilterOperator.NOT_EQUAL, 50));
    query.addSort("intData");
    List<Entity> results = service.prepare(query).asList(fetchOption);
    assertEquals(count - 1, results.size());
    for (Entity e : results) {
        assertTrue(e.getProperty("stringData").toString().contains("5") == false);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:13,代码来源:IndexQueryTest.java


示例17: checkQueryType

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
private void checkQueryType(String property, Class<?> type) {
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection(property, type));
    String sql = "SELECT " + property + " FROM " + kindName + " WHERE __ancestor__ is " + rootKey;
    assertEquals(sql.toLowerCase(), query.toString().toLowerCase());
    List<Entity> results = service.prepare(query).asList(fetchOption);
    for (Entity e : results) {
        assertEquals(1, e.getProperties().size());
        assertTrue(e.getProperties().containsKey(property));
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:12,代码来源:IndexQueryTest.java


示例18: checkQueryWithLimit

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
private void checkQueryWithLimit(int limit) {
    FetchOptions fo = FetchOptions.Builder.withLimit(limit);
    Query query = new Query(kindName, rootKey);
    query.addProjection(new PropertyProjection("stringData", String.class));
    List<Entity> results = service.prepare(query).asList(fo);
    assertEquals(limit, results.size());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:8,代码来源:IndexQueryTest.java


示例19: testProjections

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjections() throws Exception {
    Entity parent = createTestEntityWithUniqueMethodNameKey("Product", "testProjections");
    Key key = parent.getKey();

    Entity e = createEntity("Product", key)
        .withProperty("price", 123L)
        .withProperty("percent", 0.123)
        .withProperty("x", -0.321)
        .withProperty("diff", -5L)
        .withProperty("weight", 10L)
        .store();

    Query query = new Query("Product")
        .setAncestor(key)
        .addProjection(new PropertyProjection("price", Long.class))
        .addProjection(new PropertyProjection("percent", Double.class))
        .addProjection(new PropertyProjection("x", Double.class))
        .addProjection(new PropertyProjection("diff", Long.class));

    PreparedQuery preparedQuery = service.prepare(query);
    Entity result = preparedQuery.asSingleEntity();
    assertEquals(e.getKey(), result.getKey());
    assertEquals(e.getProperty("price"), result.getProperty("price"));
    assertEquals(e.getProperty("percent"), result.getProperty("percent"));
    assertEquals(e.getProperty("x"), result.getProperty("x"));
    assertEquals(e.getProperty("diff"), result.getProperty("diff"));
    assertNull(result.getProperty("weight"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:30,代码来源:QueryOptimizationsTest.java


示例20: testProjectionQueryOnlyReturnsEntitiesContainingAllProjectedProperties

import com.google.appengine.api.datastore.PropertyProjection; //导入依赖的package包/类
@Test
public void testProjectionQueryOnlyReturnsEntitiesContainingAllProjectedProperties() throws Exception {
    String methodName = "testProjectionQueryOnlyReturnsEntitiesContainingAllProjectedProperties";
    Entity parent = createTestEntityWithUniqueMethodNameKey("Kind", methodName);
    Key key = parent.getKey();

    Entity e1 = createEntity("Kind", key)
        .withProperty("foo", "foo")
        .withProperty("bar", "bar")
        .store();

    Entity e2 = createEntity("Kind", key)
        .withProperty("foo", "foo")
        .store();

    Entity e3 = createEntity("Kind", key)
        .withProperty("bar", "bar")
        .store();

    Entity e4 = createEntity("Kind", key)
        .withProperty("baz", "baz")
        .store();

    Query query = new Query("Kind")
        .setAncestor(key)
        .addProjection(new PropertyProjection("foo", String.class))
        .addProjection(new PropertyProjection("bar", String.class));

    List<Entity> results = service.prepare(query).asList(withDefaults());
    assertEquals(Collections.singletonList(e1), results);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:32,代码来源:QueryOptimizationsTest.java



注:本文中的com.google.appengine.api.datastore.PropertyProjection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PackagePrivate类代码示例发布时间:2022-05-22
下一篇:
Java RunsInEDT类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap