本文整理汇总了Java中com.facebook.presto.spi.type.DoubleType类的典型用法代码示例。如果您正苦于以下问题:Java DoubleType类的具体用法?Java DoubleType怎么用?Java DoubleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleType类属于com.facebook.presto.spi.type包,在下文中一共展示了DoubleType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testPoly_contains
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testPoly_contains() throws Exception {
double[] poly = new double[]{
45, 9.5,
45.5, 9.5,
45.5, 9,
46, 9,
46, 10,
45, 10
};
Block blockPoly = toBlock(poly);
assertFalse(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 6, 3));
assertFalse(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 45, 9));
assertTrue(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 45.7, 9.7));
}
开发者ID:Cuebiq,项目名称:presto-cuebiq-functions,代码行数:20,代码来源:PolyContainsTest.java
示例2: jdbcType
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
public static JDBCType jdbcType(Type type)
{
if (type.equals(BooleanType.BOOLEAN)) {
return JDBCType.BOOLEAN;
}
if (type.equals(BigintType.BIGINT) || type.equals(TimestampType.TIMESTAMP)) {
return JDBCType.BIGINT;
}
if (type.equals(DoubleType.DOUBLE)) {
return JDBCType.DOUBLE;
}
if (type.equals(DateType.DATE)) {
return JDBCType.INTEGER;
}
if (type.equals(VarcharType.VARCHAR)) {
return JDBCType.VARBINARY;
}
return null;
}
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:ShardPredicate.java
示例3: doComputeColumnStats
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private static ColumnStats doComputeColumnStats(OrcReader orcReader, long columnId, Type type)
throws IOException
{
int columnIndex = columnIndex(orcReader.getColumnNames(), columnId);
OrcRecordReader reader = orcReader.createRecordReader(ImmutableMap.of(columnIndex, type), OrcPredicate.TRUE, UTC, new AggregatedMemoryContext());
if (type.equals(BooleanType.BOOLEAN)) {
return indexBoolean(type, reader, columnIndex, columnId);
}
if (type.equals(BigintType.BIGINT) ||
type.equals(DateType.DATE) ||
type.equals(TimestampType.TIMESTAMP)) {
return indexLong(type, reader, columnIndex, columnId);
}
if (type.equals(DoubleType.DOUBLE)) {
return indexDouble(type, reader, columnIndex, columnId);
}
if (type.equals(VarcharType.VARCHAR)) {
return indexString(type, reader, columnIndex, columnId);
}
return null;
}
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:ShardStats.java
示例4: output
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@OutputFunction("map<double,double>")
public static void output(State state, BlockBuilder out)
{
if (state.get() == null) {
out.appendNull();
}
else {
Map<Double, Double> value = state.get().getBuckets();
BlockBuilder blockBuilder = DoubleType.DOUBLE.createBlockBuilder(new BlockBuilderStatus(), value.size() * 2);
for (Map.Entry<Double, Double> entry : value.entrySet()) {
DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getKey());
DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getValue());
}
Block block = blockBuilder.build();
out.writeObject(block);
out.closeEntry();
}
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:NumericHistogramAggregation.java
示例5: serializeSessionProperty
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@NotNull
public static String serializeSessionProperty(Type type, Object value)
{
if (value == null) {
throw new PrestoException(INVALID_SESSION_PROPERTY, "Session property can not be null");
}
if (BooleanType.BOOLEAN.equals(type)) {
return value.toString();
}
if (BigintType.BIGINT.equals(type)) {
return value.toString();
}
if (DoubleType.DOUBLE.equals(type)) {
return value.toString();
}
if (VarcharType.VARCHAR.equals(type)) {
return value.toString();
}
if (type instanceof ArrayType || type instanceof MapType) {
return getJsonCodecForType(type).toJson(value);
}
throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:SessionPropertyManager.java
示例6: deserializeSessionProperty
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@NotNull
private static Object deserializeSessionProperty(Type type, String value)
{
if (value == null) {
throw new PrestoException(INVALID_SESSION_PROPERTY, "Session property can not be null");
}
if (VarcharType.VARCHAR.equals(type)) {
return value;
}
if (BooleanType.BOOLEAN.equals(type)) {
return Boolean.valueOf(value);
}
if (BigintType.BIGINT.equals(type)) {
return Long.valueOf(value);
}
if (DoubleType.DOUBLE.equals(type)) {
return Double.valueOf(value);
}
if (type instanceof ArrayType || type instanceof MapType) {
return getJsonCodecForType(type).fromJson(value);
}
throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:SessionPropertyManager.java
示例7: getJsonCodecForType
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private static <T> JsonCodec<T> getJsonCodecForType(Type type)
{
if (VarcharType.VARCHAR.equals(type)) {
return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(String.class);
}
if (BooleanType.BOOLEAN.equals(type)) {
return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Boolean.class);
}
if (BigintType.BIGINT.equals(type)) {
return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Long.class);
}
if (DoubleType.DOUBLE.equals(type)) {
return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Double.class);
}
if (type instanceof ArrayType) {
Type elementType = ((ArrayType) type).getElementType();
return (JsonCodec<T>) JSON_CODEC_FACTORY.listJsonCodec(getJsonCodecForType(elementType));
}
if (type instanceof MapType) {
Type keyType = ((MapType) type).getKeyType();
Type valueType = ((MapType) type).getValueType();
return (JsonCodec<T>) JSON_CODEC_FACTORY.mapJsonCodec(getMapKeyType(keyType), getJsonCodecForType(valueType));
}
throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:SessionPropertyManager.java
示例8: getMapKeyType
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private static Class<?> getMapKeyType(Type type)
{
if (VarcharType.VARCHAR.equals(type)) {
return String.class;
}
if (BooleanType.BOOLEAN.equals(type)) {
return Boolean.class;
}
if (BigintType.BIGINT.equals(type)) {
return Long.class;
}
if (DoubleType.DOUBLE.equals(type)) {
return Double.class;
}
throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property map key type %s is not supported", type));
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:SessionPropertyManager.java
示例9: testNonExistent
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testNonExistent()
throws Exception
{
byte[] json = "{}".getBytes(StandardCharsets.UTF_8);
JsonRowDecoder rowDecoder = new JsonRowDecoder(PROVIDER.get());
DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "very/deep/varchar", null, null, false, false, false);
DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", BigintType.BIGINT, "no_bigint", null, null, false, false, false);
DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", DoubleType.DOUBLE, "double/is_missing", null, null, false, false, false);
DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "hello", null, null, false, false, false);
List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
Set<FieldValueProvider> providers = new HashSet<>();
boolean corrupt = rowDecoder.decodeRow(json, null, providers, columns, buildMap(columns));
assertFalse(corrupt);
assertEquals(providers.size(), columns.size());
checkIsNull(providers, row1);
checkIsNull(providers, row2);
checkIsNull(providers, row3);
checkIsNull(providers, row4);
}
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:TestJsonDecoder.java
示例10: testNulls
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testNulls()
{
String csv = ",,,";
CsvRowDecoder rowDecoder = new CsvRowDecoder();
DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false, false);
DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", BigintType.BIGINT, "1", null, null, false, false, false);
DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", DoubleType.DOUBLE, "2", null, null, false, false, false);
DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "3", null, null, false, false, false);
List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
Set<FieldValueProvider> providers = new HashSet<>();
boolean corrupt = rowDecoder.decodeRow(csv.getBytes(StandardCharsets.UTF_8), null, providers, columns, buildMap(columns));
assertFalse(corrupt);
assertEquals(providers.size(), columns.size());
checkValue(providers, row1, "");
checkValue(providers, row2, 0);
checkValue(providers, row3, 0.0d);
checkValue(providers, row4, false);
}
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestCsvDecoder.java
示例11: testNonExistent
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testNonExistent()
throws Exception
{
byte[] json = "{}".getBytes(StandardCharsets.UTF_8);
JsonKinesisRowDecoder rowDecoder = new JsonKinesisRowDecoder(PROVIDER.get());
KinesisColumnHandle row1 = new KinesisColumnHandle("", 0, "row1", VarcharType.VARCHAR, "very/deep/varchar", null, null, false, false);
KinesisColumnHandle row2 = new KinesisColumnHandle("", 1, "row2", BigintType.BIGINT, "no_bigint", null, null, false, false);
KinesisColumnHandle row3 = new KinesisColumnHandle("", 2, "row3", DoubleType.DOUBLE, "double/is_missing", null, null, false, false);
KinesisColumnHandle row4 = new KinesisColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "hello", null, null, false, false);
List<KinesisColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
Set<KinesisFieldValueProvider> providers = new HashSet<>();
boolean valid = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
assertTrue(valid);
assertEquals(providers.size(), columns.size());
DecoderTestUtil.checkIsNull(providers, row1);
DecoderTestUtil.checkIsNull(providers, row2);
DecoderTestUtil.checkIsNull(providers, row3);
DecoderTestUtil.checkIsNull(providers, row4);
}
开发者ID:qubole,项目名称:presto-kinesis,代码行数:26,代码来源:TestJsonDecoder.java
示例12: toConjuncts
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private List<String> toConjuncts(List<JdbcColumnHandle> columns, TupleDomain<ColumnHandle> tupleDomain)
{
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (JdbcColumnHandle column : columns) {
Type type = column.getColumnType();
if (type.equals(BigintType.BIGINT) || type.equals(DoubleType.DOUBLE) || type.equals(BooleanType.BOOLEAN)) {
Domain domain = tupleDomain.getDomains().get().get(column);
if (domain != null) {
builder.add(toPredicate(column.getColumnName(), domain));
}
}
}
return builder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:QueryBuilder.java
示例13: testDouble
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testDouble()
throws Exception
{
InternalAggregationFunction doubleAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, VARBINARY, DOUBLE));
Block block = createDoublesBlock(null, 2.0, null, 3.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN);
assertAggregation(doubleAgg, 1.0, expectedChecksum(DoubleType.DOUBLE, block), block);
}
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:TestChecksumAggregation.java
示例14: featuresHelper
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private static Block featuresHelper(double... features)
{
BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), features.length, 8 + 8);
for (int i = 0; i < features.length; i++) {
BigintType.BIGINT.writeLong(blockBuilder, i);
DoubleType.DOUBLE.writeDouble(blockBuilder, features[i]);
}
return blockBuilder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:MLFunctions.java
示例15: getPage
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private static Page getPage()
throws JsonProcessingException
{
Type mapType = typeManager.getParameterizedType("map", ImmutableList.of(parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.DOUBLE)), ImmutableList.of());
int datapoints = 100;
RowPageBuilder builder = RowPageBuilder.rowPageBuilder(BigintType.BIGINT, mapType, VarcharType.VARCHAR);
Random rand = new Random(0);
for (int i = 0; i < datapoints; i++) {
long label = rand.nextDouble() < 0.5 ? 0 : 1;
builder.row(label, mapSliceOf(BigintType.BIGINT, DoubleType.DOUBLE, 0, label + rand.nextGaussian()), "C=1");
}
return builder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:TestLearnAggregations.java
示例16: getRowColumnInspector
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
public static ObjectInspector getRowColumnInspector(Type type)
{
if (type.equals(BooleanType.BOOLEAN)) {
return writableBooleanObjectInspector;
}
if (type.equals(BigintType.BIGINT)) {
return writableLongObjectInspector;
}
if (type.equals(DoubleType.DOUBLE)) {
return writableDoubleObjectInspector;
}
if (type.equals(VarcharType.VARCHAR)) {
return writableStringObjectInspector;
}
if (type.equals(VarbinaryType.VARBINARY)) {
return writableBinaryObjectInspector;
}
if (type.equals(DateType.DATE)) {
return writableDateObjectInspector;
}
if (type.equals(TimestampType.TIMESTAMP)) {
return writableTimestampObjectInspector;
}
if (isArrayType(type) || isMapType(type) || isRowType(type)) {
return getJavaObjectInspector(type);
}
throw new IllegalArgumentException("unsupported type: " + type);
}
开发者ID:y-lan,项目名称:presto,代码行数:37,代码来源:HiveWriteUtils.java
示例17: testSimple
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testSimple()
{
String csv = "\"row 1\",row2,\"row3\",100,\"200\",300,4.5";
CsvRowDecoder rowDecoder = new CsvRowDecoder();
DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false, false);
DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", VarcharType.VARCHAR, "1", null, null, false, false, false);
DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", VarcharType.VARCHAR, "2", null, null, false, false, false);
DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BigintType.BIGINT, "3", null, null, false, false, false);
DecoderTestColumnHandle row5 = new DecoderTestColumnHandle("", 4, "row5", BigintType.BIGINT, "4", null, null, false, false, false);
DecoderTestColumnHandle row6 = new DecoderTestColumnHandle("", 5, "row6", BigintType.BIGINT, "5", null, null, false, false, false);
DecoderTestColumnHandle row7 = new DecoderTestColumnHandle("", 6, "row7", DoubleType.DOUBLE, "6", null, null, false, false, false);
List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5, row6, row7);
Set<FieldValueProvider> providers = new HashSet<>();
boolean corrupt = rowDecoder.decodeRow(csv.getBytes(StandardCharsets.UTF_8), null, providers, columns, buildMap(columns));
assertFalse(corrupt);
assertEquals(providers.size(), columns.size());
checkValue(providers, row1, "row 1");
checkValue(providers, row2, "row2");
checkValue(providers, row3, "row3");
checkValue(providers, row4, 100);
checkValue(providers, row5, 200);
checkValue(providers, row6, 300);
checkValue(providers, row7, 4.5d);
}
开发者ID:y-lan,项目名称:presto,代码行数:31,代码来源:TestCsvDecoder.java
示例18: getType
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private Type getType(TableType columnType) {
switch (columnType) {
case BOOLEAN:
return BooleanType.BOOLEAN;
case NUMBER:
return DoubleType.DOUBLE;
case STRING:
return VarcharType.VARCHAR;
default:
throw new PrestoException(SpreadsheetErrorCode.INTERNAL_ERROR, "Not Supported [" + columnType + "]");
}
}
开发者ID:fortitudetec,项目名称:presto-plugins,代码行数:13,代码来源:SpreadsheetMetadata.java
示例19: testSimple
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
@Test
public void testSimple()
{
String csv = "\"row 1\",row2,\"row3\",100,\"200\",300,4.5";
CsvKinesisRowDecoder rowDecoder = new CsvKinesisRowDecoder();
KinesisColumnHandle row1 = new KinesisColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false);
KinesisColumnHandle row2 = new KinesisColumnHandle("", 1, "row2", VarcharType.VARCHAR, "1", null, null, false, false);
KinesisColumnHandle row3 = new KinesisColumnHandle("", 2, "row3", VarcharType.VARCHAR, "2", null, null, false, false);
KinesisColumnHandle row4 = new KinesisColumnHandle("", 3, "row4", BigintType.BIGINT, "3", null, null, false, false);
KinesisColumnHandle row5 = new KinesisColumnHandle("", 4, "row5", BigintType.BIGINT, "4", null, null, false, false);
KinesisColumnHandle row6 = new KinesisColumnHandle("", 5, "row6", BigintType.BIGINT, "5", null, null, false, false);
KinesisColumnHandle row7 = new KinesisColumnHandle("", 6, "row7", DoubleType.DOUBLE, "6", null, null, false, false);
List<KinesisColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5, row6, row7);
Set<KinesisFieldValueProvider> providers = new HashSet<>();
boolean valid = rowDecoder.decodeRow(csv.getBytes(StandardCharsets.UTF_8), providers, columns, buildMap(columns));
assertTrue(valid);
assertEquals(providers.size(), columns.size());
DecoderTestUtil.checkValue(providers, row1, "row 1");
DecoderTestUtil.checkValue(providers, row2, "row2");
DecoderTestUtil.checkValue(providers, row3, "row3");
DecoderTestUtil.checkValue(providers, row4, 100);
DecoderTestUtil.checkValue(providers, row5, 200);
DecoderTestUtil.checkValue(providers, row6, 300);
DecoderTestUtil.checkValue(providers, row7, 4.5d);
}
开发者ID:qubole,项目名称:presto-kinesis,代码行数:31,代码来源:TestCsvDecoder.java
示例20: getType
import com.facebook.presto.spi.type.DoubleType; //导入依赖的package包/类
private Type getType(String typeName)
{
log.debug("Get type " + typeName);
typeName = typeName.toLowerCase();
// check if type is varchar(xx)
Pattern vcpattern = Pattern.compile("varchar\\(\\s*(\\d+)\\s*\\)");
Matcher vcmatcher = vcpattern.matcher(typeName);
if (vcmatcher.find()) {
String vlen = vcmatcher.group(1);
if (!vlen.isEmpty()) {
return VarcharType.createVarcharType(Integer.parseInt(vlen));
}
return UnknownType.UNKNOWN;
}
// check if type is char(xx)
Pattern cpattern = Pattern.compile("char\\(\\s*(\\d+)\\s*\\)");
Matcher cmatcher = cpattern.matcher(typeName);
if (cmatcher.find()) {
String clen = cmatcher.group(1);
if (!clen.isEmpty()) {
return CharType.createCharType(Integer.parseInt(clen));
}
return UnknownType.UNKNOWN;
}
// check if type is decimal(precision, scale)
Pattern dpattern = Pattern.compile("decimal\\((\\d+)\\s*,?\\s*(\\d*)\\)");
Matcher dmatcher = dpattern.matcher(typeName);
if (dmatcher.find()) {
String dprecision = dmatcher.group(1);
String dscale = dmatcher.group(2);
if (dprecision.isEmpty()) {
return UnknownType.UNKNOWN;
}
if (dscale.isEmpty()) {
return DecimalType.createDecimalType(Integer.parseInt(dprecision));
}
return DecimalType.createDecimalType(Integer.parseInt(dprecision), Integer.parseInt(dscale));
}
switch (typeName) {
case "boolean": return BooleanType.BOOLEAN;
case "tinyint": return TinyintType.TINYINT;
case "smallint": return SmallintType.SMALLINT;
case "integer": return IntegerType.INTEGER;
case "bigint": return BigintType.BIGINT;
case "real": return RealType.REAL;
case "double": return DoubleType.DOUBLE;
case "date": return DateType.DATE;
case "time": return TimeType.TIME;
case "timestamp": return TimestampType.TIMESTAMP;
default: return UnknownType.UNKNOWN;
}
}
开发者ID:dbiir,项目名称:paraflow,代码行数:53,代码来源:MetaDataQuery.java
注:本文中的com.facebook.presto.spi.type.DoubleType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论