本文整理汇总了Java中com.facebook.presto.spi.type.StandardTypes类的典型用法代码示例。如果您正苦于以下问题:Java StandardTypes类的具体用法?Java StandardTypes怎么用?Java StandardTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StandardTypes类属于com.facebook.presto.spi.type包,在下文中一共展示了StandardTypes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseAgent
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("parse_agent")
@Description("Returns Map, which has keys such as 'category', 'name', 'os', 'version', 'vendor' and 'os_version'")
@SqlType("map<varchar,varchar>")
public Block parseAgent(@TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
Map<String, String> stringMap = Classifier.parse(argument);
if (pageBuilder.isFull()) {
pageBuilder.reset();
}
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry();
for (Map.Entry<String, String> entry : stringMap.entrySet()) {
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getKey()));
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getValue()));
}
blockBuilder.closeEntry();
pageBuilder.declarePosition();
return (Block) mapType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:23,代码来源:ParseAgentFuntion.java
示例2: geohash_encode_dec
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@SqlType(StandardTypes.VARCHAR)
@TypeParameterContainer({@TypeParameter("decimal(lat_precision, lat_scale)")
, @TypeParameter("decimal(lng_precision, lng_scale)")}
)
@Nullable
public static Slice geohash_encode_dec(
@TypeParameter("decimal(lat_precision, lat_scale)") DecimalType latParameter,
@TypeParameter("decimal(lng_precision, lng_scale)") DecimalType lngParameter,
@SqlType("decimal(lat_precision, lat_scale)") Slice lat,
@SqlType("decimal(lng_precision, lng_scale)") Slice lng,
@SqlType(StandardTypes.INTEGER) long precision) {
BigDecimal biglat = new BigDecimal(Decimals.decodeUnscaledValue(lat), latParameter.getScale());
BigDecimal bigLng = new BigDecimal(Decimals.decodeUnscaledValue(lng), lngParameter.getScale());
return GeohashEncode.geohash_encode(biglat.doubleValue(), bigLng.doubleValue(), precision);
}
开发者ID:Cuebiq,项目名称:presto-cuebiq-functions,代码行数:19,代码来源:DecimalGeographicFunctions.java
示例3: testMinDoubleDouble
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Test
public void testMinDoubleDouble()
throws Exception
{
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, StandardTypes.DOUBLE, StandardTypes.DOUBLE, StandardTypes.DOUBLE));
assertAggregation(
function,
1.0,
null,
createDoublesBlock(null, null),
createDoublesBlock(null, null));
assertAggregation(
function,
1.0,
3.0,
createDoublesBlock(3.0, 2.0, 5.0, 3.0),
createDoublesBlock(1.0, 1.5, 2.0, 4.0));
}
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:TestMinMaxByAggregation.java
示例4: input
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@InputFunction
public static void input(EvaluateClassifierPredictionsState state, @SqlType(StandardTypes.VARCHAR) Slice truth, @SqlType(StandardTypes.VARCHAR) Slice prediction)
{
if (truth.equals(prediction)) {
String key = truth.toStringUtf8();
if (!state.getTruePositives().containsKey(key)) {
state.addMemoryUsage(truth.length() + SIZE_OF_INT);
}
state.getTruePositives().put(key, state.getTruePositives().getOrDefault(key, 0) + 1);
}
else {
String truthKey = truth.toStringUtf8();
String predictionKey = prediction.toStringUtf8();
if (!state.getFalsePositives().containsKey(predictionKey)) {
state.addMemoryUsage(prediction.length() + SIZE_OF_INT);
}
state.getFalsePositives().put(predictionKey, state.getFalsePositives().getOrDefault(predictionKey, 0) + 1);
if (!state.getFalseNegatives().containsKey(truthKey)) {
state.addMemoryUsage(truth.length() + SIZE_OF_INT);
}
state.getFalseNegatives().put(truthKey, state.getFalseNegatives().getOrDefault(truthKey, 0) + 1);
}
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:EvaluateClassifierPredictionsAggregation.java
示例5: testMaxDoubleVarchar
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Test
public void testMaxDoubleVarchar()
{
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, StandardTypes.VARCHAR, StandardTypes.VARCHAR, StandardTypes.DOUBLE));
assertAggregation(
function,
1.0,
"a",
createStringsBlock("z", "a", null),
createDoublesBlock(1.0, 2.0, null));
assertAggregation(
function,
1.0,
"hi",
createStringsBlock("zz", "hi", null, "a"),
createDoublesBlock(0.0, 1.0, null, -1.0));
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:TestMinMaxByAggregation.java
示例6: regexpExtract
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Nullable
@Description("returns regex group of extracted string with a pattern")
@ScalarFunction
@SqlType(StandardTypes.VARCHAR)
public static Slice regexpExtract(@SqlType(StandardTypes.VARCHAR) Slice source, @SqlType(RegexpType.NAME) Regex pattern, @SqlType(StandardTypes.BIGINT) long groupIndex)
{
Matcher matcher = pattern.matcher(source.getBytes());
validateGroup(groupIndex, matcher.getEagerRegion());
int group = Ints.checkedCast(groupIndex);
int offset = matcher.search(0, source.length(), Option.DEFAULT);
if (offset == -1) {
return null;
}
Region region = matcher.getEagerRegion();
int beg = region.beg[group];
int end = region.end[group];
if (beg == -1) {
// end == -1 must be true
return null;
}
Slice slice = source.slice(beg, end - beg);
return slice;
}
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:RegexpFunctions.java
示例7: testDuplicateKeysValues
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Test
public void testDuplicateKeysValues()
throws Exception
{
MapType mapType = new MapType(DOUBLE, VARCHAR);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature().toString(), StandardTypes.DOUBLE, StandardTypes.VARCHAR));
assertAggregation(
aggFunc,
1.0,
ImmutableMap.of(1.0, "a"),
createDoublesBlock(1.0, 1.0, 1.0),
createStringsBlock("a", "b", "c"));
mapType = new MapType(DOUBLE, BIGINT);
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature().toString(), StandardTypes.DOUBLE, StandardTypes.BIGINT));
assertAggregation(
aggFunc,
1.0,
ImmutableMap.of(1.0, 99L, 2.0, 99L, 3.0, 99L),
createDoublesBlock(1.0, 2.0, 3.0),
createLongsBlock(99L, 99L, 99L));
}
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:TestMapAggAggregation.java
示例8: bloomFilterPersist
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@SqlType(StandardTypes.BOOLEAN)
@Nullable
@SqlNullable
public static Boolean bloomFilterPersist(@SqlNullable @SqlType(BloomFilterType.TYPE) Slice bloomFilterSlice, @SqlType(StandardTypes.VARCHAR) Slice urlSlice) throws Exception
{
// Nothing todo
if (urlSlice == null) {
return true;
}
BloomFilter bf = getOrLoadBloomFilter(bloomFilterSlice);
// Persist
// we do not try catch here to make sure that errors are communicated clearly to the client
// and typical retry logic continues to work
String url = new String(urlSlice.getBytes());
if (!HTTP_CLIENT.isStarted()) {
log.warn("Http client was not started, trying to start");
HTTP_CLIENT.start();
}
Request post = HTTP_CLIENT.POST(url);
post.content(new StringContentProvider(new String(bf.toBase64())));
post.method("PUT");
post.send();
log.info("Persisted " + bf.toString() + " " + url);
return true;
}
开发者ID:RobinUS2,项目名称:presto-bloomfilter,代码行数:27,代码来源:BloomFilterPersistScalarFunction.java
示例9: isPC
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_pc")
@Description("Returns Boolean: map['category'] is a pc or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean isPC(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_PC);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例10: IsSmartPhone
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_smartphone")
@Description("Returns Boolean: map['category'] is a smartphone or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsSmartPhone(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_SMARTPHONE);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例11: IsMobilePhone
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_mobilephone")
@Description("Returns Boolean: map['category'] is a mobilephone or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsMobilePhone(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_MOBILEPHONE);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例12: IsAppliance
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_appliance")
@Description("Returns Boolean: map['category'] is a appliance or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsAppliance(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_APPLIANCE);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例13: IsCrawler
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_crawler")
@Description("Returns Boolean: map['category'] is a crawler or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsCrawler(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_CRAWLER);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例14: IsMisc
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_misc")
@Description("Returns Boolean: map['category'] is a misc or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsMisc(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.DATASET_CATEGORY_MISC);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例15: IsUnknown
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("is_unknown")
@Description("Returns Boolean: map['category'] is a unknown or not.")
@SqlType(StandardTypes.BOOLEAN)
public static boolean IsUnknown(@SqlNullable @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
return Classifier.parse(argument).get(DataSet.ATTRIBUTE_CATEGORY).equals(DataSet.VALUE_UNKNOWN);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:8,代码来源:ParseAgentFuntion.java
示例16: fromWei
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("fromWei")
@Description("fromWei")
@SqlType(StandardTypes.DOUBLE)
public static double fromWei(@SqlType(StandardTypes.DOUBLE) double num, @SqlType(StandardTypes.VARCHAR) Slice unit) {
String unitStr = unit.toStringUtf8().toUpperCase();
EthereumUnit u = EthereumUnit.valueOf(unitStr);
return u.fromWei(num);
}
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:9,代码来源:EthereumUDFs.java
示例17: toWei
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@ScalarFunction("toWei")
@Description("toWei")
@SqlType(StandardTypes.DOUBLE)
public static double toWei(@SqlType(StandardTypes.DOUBLE) double num, @SqlType(StandardTypes.VARCHAR) Slice unit) {
String unitStr = unit.toStringUtf8().toUpperCase();
EthereumUnit u = EthereumUnit.valueOf(unitStr);
return u.toWei(num);
}
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:9,代码来源:EthereumUDFs.java
示例18: hllCardinality
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Description("Returns the approximate cardinality of a HLL")
@ScalarFunction("cardinality")
@SqlType(StandardTypes.BIGINT)
public static long hllCardinality(@SqlType(HyperLogLogType.TYPE) Slice hll)
{
return (Long) HyperLogLog.fromBytes(hll.getBytes()).approximateSize().estimate();
}
开发者ID:vitillo,项目名称:presto-hyperloglog,代码行数:8,代码来源:HyperLogLogScalarFunctions.java
示例19: hllCreate
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@Description("Create a HLL from a string")
@ScalarFunction("hll_create")
@SqlType(HyperLogLogType.TYPE)
public static Slice hllCreate(@SqlType(StandardTypes.VARCHAR) Slice string, @SqlType(StandardTypes.BIGINT) long bits)
{
HyperLogLogMonoid monoid = new HyperLogLogMonoid((int) bits);
DenseHLL hll = monoid.create(string.getBytes()).toDenseHLL();
return Slices.wrappedBuffer(HyperLogLog.toBytes(hll));
}
开发者ID:vitillo,项目名称:presto-hyperloglog,代码行数:10,代码来源:HyperLogLogScalarFunctions.java
示例20: shuffle_string
import com.facebook.presto.spi.type.StandardTypes; //导入依赖的package包/类
@SqlType(StandardTypes.VARCHAR)
public static Slice shuffle_string(@SqlType(StandardTypes.VARCHAR) Slice string) {
String id = string.toStringUtf8();
Random rnd = new Random(id.charAt(0));
byte[] bytes = id.getBytes();
for (int i = bytes.length; i > 1; i--) {
swap(bytes, i - 1, rnd.nextInt(i));
}
return Slices.wrappedBuffer(bytes);
}
开发者ID:Cuebiq,项目名称:presto-cuebiq-functions,代码行数:12,代码来源:ShuffleString.java
注:本文中的com.facebook.presto.spi.type.StandardTypes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论