/
githubmirror
/
the-algorithm
Обзор
Документация
Войти
/
githubmirror
/
the-algorithm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/java/com/twitter/search/common/query/MappableField.java
34 строки
1 KB
twitter-team
Twitter Recommendation Algorithm
01 апр 2023, 01:36
01 апр 2023, 01:36
ef4c5eb
Код
Авторство
О чём код?
package com.twitter.search.common.query; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; /** * The indices may map the fields declared here to fields internally without exposing their schemas * to other services. This can be used, for example, to set boosts for URL-like fields in Earlybird * without direct knowledge of the internal Earlybird field name */ public enum MappableField { REFERRAL, URL; static { ImmutableMap.Builder<MappableField, String> builder = ImmutableMap.builder(); for (MappableField mappableField : MappableField.values()) { builder.put(mappableField, mappableField.toString().toLowerCase()); } MAPPABLE_FIELD_TO_NAME_MAP = Maps.immutableEnumMap(builder.build()); } private static final ImmutableMap<MappableField, String> MAPPABLE_FIELD_TO_NAME_MAP; /** Returns the name of the given MappableField. */ public static String mappableFieldName(MappableField mappableField) { return MAPPABLE_FIELD_TO_NAME_MAP.get(mappableField); } /** Returns the name of this MappableField. */ public String getName() { return MAPPABLE_FIELD_TO_NAME_MAP.get(this); } }