Search in sources :

Example 1 with IndexComponentsOnlyQuery

use of com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery in project appengine-java-standard by GoogleCloudPlatform.

the class AdminDatastoreService method minimumCompositeIndexesForQuery.

public Set<Index> minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes) {
    List<DatastoreV3Pb.Query> pbQueries = convertQueryToPbs(query, FetchOptions.Builder.withDefaults());
    List<OnestoreEntity.Index> indexPbs = Lists.newArrayListWithCapacity(indexes.size());
    for (Index index : indexes) {
        indexPbs.add(IndexTranslator.convertToPb(index));
    }
    Set<Index> resultSet = new HashSet<Index>();
    for (DatastoreV3Pb.Query queryProto : pbQueries) {
        IndexComponentsOnlyQuery indexQuery = new IndexComponentsOnlyQuery(queryProto);
        OnestoreEntity.Index index = factory.getCompositeIndexManager().minimumCompositeIndexForQuery(indexQuery, indexPbs);
        if (index != null) {
            resultSet.add(IndexTranslator.convertFromPb(index));
        }
    }
    return resultSet;
}
Also used : IndexComponentsOnlyQuery(com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery) IndexComponentsOnlyQuery(com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery) OnestoreEntity(com.google.storage.onestore.v3.OnestoreEntity) DatastoreV3Pb(com.google.apphosting.datastore.DatastoreV3Pb) HashSet(java.util.HashSet)

Example 2 with IndexComponentsOnlyQuery

use of com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery in project appengine-java-standard by GoogleCloudPlatform.

the class AdminDatastoreService method compositeIndexesForQuery.

public Set<Index> compositeIndexesForQuery(Query query) {
    List<DatastoreV3Pb.Query> pbQueries = convertQueryToPbs(query, FetchOptions.Builder.withDefaults());
    Set<Index> resultSet = new HashSet<Index>();
    for (DatastoreV3Pb.Query queryProto : pbQueries) {
        IndexComponentsOnlyQuery indexQuery = new IndexComponentsOnlyQuery(queryProto);
        OnestoreEntity.Index index = factory.getCompositeIndexManager().compositeIndexForQuery(indexQuery);
        if (index != null) {
            resultSet.add(IndexTranslator.convertFromPb(index));
        }
    }
    return resultSet;
}
Also used : IndexComponentsOnlyQuery(com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery) IndexComponentsOnlyQuery(com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery) OnestoreEntity(com.google.storage.onestore.v3.OnestoreEntity) DatastoreV3Pb(com.google.apphosting.datastore.DatastoreV3Pb) HashSet(java.util.HashSet)

Example 3 with IndexComponentsOnlyQuery

use of com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery in project appengine-java-standard by GoogleCloudPlatform.

the class QueryRunnerV3 method addMissingIndexData.

private void addMissingIndexData(DatastoreV3Pb.Query queryProto, DatastoreNeedIndexException e) {
    IndexComponentsOnlyQuery indexQuery = new IndexComponentsOnlyQuery(queryProto);
    CompositeIndexManager mgr = new CompositeIndexManager();
    OnestoreEntity.Index index = mgr.compositeIndexForQuery(indexQuery);
    if (index != null) {
        String xml = mgr.generateXmlForIndex(index, IndexSource.manual);
        e.setMissingIndexDefinitionXml(xml);
    } else {
    // Prod says we need an index but the index manager says we don't.
    // Probably a bug in the index manager.  DatastoreNeedIndexException
    // will report this in the exception message.
    }
}
Also used : IndexComponentsOnlyQuery(com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery) OnestoreEntity(com.google.storage.onestore.v3.OnestoreEntity)

Aggregations

IndexComponentsOnlyQuery (com.google.appengine.api.datastore.CompositeIndexManager.IndexComponentsOnlyQuery)3 OnestoreEntity (com.google.storage.onestore.v3.OnestoreEntity)3 DatastoreV3Pb (com.google.apphosting.datastore.DatastoreV3Pb)2 HashSet (java.util.HashSet)2