Java Code Examples for com.google.cloud.spanner.Type#array()
The following examples show how to use
com.google.cloud.spanner.Type#array() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpannerSchema.java From beam with Apache License 2.0 | 5 votes |
private static Type parseSpannerType(String spannerType) { spannerType = spannerType.toUpperCase(); if ("BOOL".equals(spannerType)) { return Type.bool(); } if ("INT64".equals(spannerType)) { return Type.int64(); } if ("FLOAT64".equals(spannerType)) { return Type.float64(); } if (spannerType.startsWith("STRING")) { return Type.string(); } if (spannerType.startsWith("BYTES")) { return Type.bytes(); } if ("TIMESTAMP".equals(spannerType)) { return Type.timestamp(); } if ("DATE".equals(spannerType)) { return Type.date(); } if (spannerType.startsWith("ARRAY")) { // Substring "ARRAY<xxx>" String spannerArrayType = spannerType.substring(6, spannerType.length() - 1); Type itemType = parseSpannerType(spannerArrayType); return Type.array(itemType); } throw new IllegalArgumentException("Unknown spanner type " + spannerType); }
Example 2
Source File: RandomDdlGenerator.java From DataflowTemplates with Apache License 2.0 | 4 votes |
private Type generateType(Type.Code[] codes, int arrayPercentage) { boolean isArray = getRandom().nextInt(100) <= arrayPercentage; Type.Code code = randomCode(codes); return isArray ? Type.array(typeOf(code)) : typeOf(code); }