Package io.prestosql.util
Class JsonUtil
- java.lang.Object
-
- io.prestosql.util.JsonUtil
-
public final class JsonUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JsonUtil.BlockBuilderAppender
static interface
JsonUtil.JsonGeneratorWriter
static interface
JsonUtil.ObjectKeyProvider
-
Field Summary
Fields Modifier and Type Field Description static com.fasterxml.jackson.core.JsonFactory
JSON_FACTORY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canCastFromJson(Type type)
static boolean
canCastToJson(Type type)
static com.fasterxml.jackson.core.JsonGenerator
createJsonGenerator(com.fasterxml.jackson.core.JsonFactory factory, io.airlift.slice.SliceOutput output)
static com.fasterxml.jackson.core.JsonParser
createJsonParser(com.fasterxml.jackson.core.JsonFactory factory, io.airlift.slice.Slice json)
static Long
currentTokenAsBigint(com.fasterxml.jackson.core.JsonParser parser)
static Boolean
currentTokenAsBoolean(com.fasterxml.jackson.core.JsonParser parser)
static Double
currentTokenAsDouble(com.fasterxml.jackson.core.JsonParser parser)
static Long
currentTokenAsInteger(com.fasterxml.jackson.core.JsonParser parser)
static io.airlift.slice.Slice
currentTokenAsLongDecimal(com.fasterxml.jackson.core.JsonParser parser, int precision, int scale)
static Long
currentTokenAsReal(com.fasterxml.jackson.core.JsonParser parser)
static Long
currentTokenAsShortDecimal(com.fasterxml.jackson.core.JsonParser parser, int precision, int scale)
static Long
currentTokenAsSmallint(com.fasterxml.jackson.core.JsonParser parser)
static Long
currentTokenAsTinyint(com.fasterxml.jackson.core.JsonParser parser)
static io.airlift.slice.Slice
currentTokenAsVarchar(com.fasterxml.jackson.core.JsonParser parser)
static Optional<Map<String,Integer>>
getFieldNameToIndex(List<RowType.Field> rowFields)
static void
parseJsonToSingleRowBlock(com.fasterxml.jackson.core.JsonParser parser, SingleRowBlockWriter singleRowBlockWriter, JsonUtil.BlockBuilderAppender[] fieldAppenders, Optional<Map<String,Integer>> fieldNameToIndex)
static String
truncateIfNecessaryForErrorMessage(io.airlift.slice.Slice json)
-
-
-
Method Detail
-
createJsonParser
public static com.fasterxml.jackson.core.JsonParser createJsonParser(com.fasterxml.jackson.core.JsonFactory factory, io.airlift.slice.Slice json) throws IOException
- Throws:
IOException
-
createJsonGenerator
public static com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(com.fasterxml.jackson.core.JsonFactory factory, io.airlift.slice.SliceOutput output) throws IOException
- Throws:
IOException
-
truncateIfNecessaryForErrorMessage
public static String truncateIfNecessaryForErrorMessage(io.airlift.slice.Slice json)
-
canCastToJson
public static boolean canCastToJson(Type type)
-
canCastFromJson
public static boolean canCastFromJson(Type type)
-
currentTokenAsVarchar
public static io.airlift.slice.Slice currentTokenAsVarchar(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsBigint
public static Long currentTokenAsBigint(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsInteger
public static Long currentTokenAsInteger(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsSmallint
public static Long currentTokenAsSmallint(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsTinyint
public static Long currentTokenAsTinyint(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsDouble
public static Double currentTokenAsDouble(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsReal
public static Long currentTokenAsReal(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsBoolean
public static Boolean currentTokenAsBoolean(com.fasterxml.jackson.core.JsonParser parser) throws IOException
- Throws:
IOException
-
currentTokenAsShortDecimal
public static Long currentTokenAsShortDecimal(com.fasterxml.jackson.core.JsonParser parser, int precision, int scale) throws IOException
- Throws:
IOException
-
currentTokenAsLongDecimal
public static io.airlift.slice.Slice currentTokenAsLongDecimal(com.fasterxml.jackson.core.JsonParser parser, int precision, int scale) throws IOException
- Throws:
IOException
-
getFieldNameToIndex
public static Optional<Map<String,Integer>> getFieldNameToIndex(List<RowType.Field> rowFields)
-
parseJsonToSingleRowBlock
public static void parseJsonToSingleRowBlock(com.fasterxml.jackson.core.JsonParser parser, SingleRowBlockWriter singleRowBlockWriter, JsonUtil.BlockBuilderAppender[] fieldAppenders, Optional<Map<String,Integer>> fieldNameToIndex) throws IOException
- Throws:
IOException
-
-