Search in sources :

Example 1 with Memoized

use of com.google.auto.value.extension.memoized.Memoized in project gerrit by GerritCodeReview.

the class ExternalId method toString.

/**
 * Exports this external ID as Git config file text.
 *
 * <p>The Git config has exactly one externalId subsection with an accountId and optionally email
 * and password:
 *
 * <pre>
 * [externalId "username:jdoe"]
 *   accountId = 1003407
 *   email = jdoe@example.com
 *   password = bcrypt:4:LCbmSBDivK/hhGVQMfkDpA==:XcWn0pKYSVU/UJgOvhidkEtmqCp6oKB7
 * </pre>
 */
@Override
@Memoized
public String toString() {
    Config c = new Config();
    writeToConfig(c);
    return c.toText();
}
Also used : Config(org.eclipse.jgit.lib.Config) Memoized(com.google.auto.value.extension.memoized.Memoized)

Example 2 with Memoized

use of com.google.auto.value.extension.memoized.Memoized in project zipkin by openzipkin.

the class ElasticsearchHttpStorage method http.

// hosts resolution might imply a network call, and we might make a new okhttp instance
@Memoized
HttpCall.Factory http() {
    List<String> hosts = hostsSupplier().get();
    if (hosts.isEmpty())
        throw new IllegalArgumentException("no hosts configured");
    OkHttpClient ok = hosts.size() == 1 ? client() : client().newBuilder().dns(PseudoAddressRecordSet.create(hosts, client().dns())).build();
    ok.dispatcher().setMaxRequests(maxRequests());
    ok.dispatcher().setMaxRequestsPerHost(maxRequests());
    return new HttpCall.Factory(ok, HttpUrl.parse(hosts.get(0)));
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Memoized(com.google.auto.value.extension.memoized.Memoized)

Example 3 with Memoized

use of com.google.auto.value.extension.memoized.Memoized in project grakn by graknlabs.

the class RelationshipAtom method getRoleVarMap.

/**
 * @return map containing roleType - (rolePlayer var - rolePlayer type) pairs
 */
@Memoized
public Multimap<Role, Var> getRoleVarMap() {
    ImmutableMultimap.Builder<Role, Var> builder = ImmutableMultimap.builder();
    GraknTx graph = getParentQuery().tx();
    getRelationPlayers().forEach(c -> {
        Var varName = c.getRolePlayer().var();
        VarPatternAdmin rolePattern = c.getRole().orElse(null);
        if (rolePattern != null) {
            // try directly
            Label typeLabel = rolePattern.getTypeLabel().orElse(null);
            Role role = typeLabel != null ? graph.getRole(typeLabel.getValue()) : null;
            // try indirectly
            if (role == null && rolePattern.var().isUserDefinedName()) {
                IdPredicate rolePredicate = getIdPredicate(rolePattern.var());
                if (rolePredicate != null) {
                    Role r = graph.getConcept(rolePredicate.getPredicate());
                    if (r == null)
                        throw GraqlQueryException.idNotFound(rolePredicate.getPredicate());
                    role = r;
                }
            }
            if (role != null)
                builder.put(role, varName);
        }
    });
    return builder.build();
}
Also used : Role(ai.grakn.concept.Role) GraknTx(ai.grakn.GraknTx) IdPredicate(ai.grakn.graql.internal.reasoner.atom.predicate.IdPredicate) VarPatternAdmin(ai.grakn.graql.admin.VarPatternAdmin) Var(ai.grakn.graql.Var) Label(ai.grakn.concept.Label) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) Memoized(com.google.auto.value.extension.memoized.Memoized)

Aggregations

Memoized (com.google.auto.value.extension.memoized.Memoized)3 GraknTx (ai.grakn.GraknTx)1 Label (ai.grakn.concept.Label)1 Role (ai.grakn.concept.Role)1 Var (ai.grakn.graql.Var)1 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)1 IdPredicate (ai.grakn.graql.internal.reasoner.atom.predicate.IdPredicate)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 OkHttpClient (okhttp3.OkHttpClient)1 Config (org.eclipse.jgit.lib.Config)1