public static TypeDescriptor getRuntimeTypeDescriptor () { return new TypeDescriptor(Map.class, new TypeDescriptor(String.class), new TypeDescriptor(List.class, new TypeDescriptor(Pair.class, new TypeDescriptor(String.class), new TypeDescriptor(Long.class)))); }
@Test public void testToString () { TypeDescriptor desc = new TypeDescriptor(List.class, new TypeDescriptor(Pair.class, new TypeDescriptor(Double.class), new TypeDescriptor(String.class))); Assert.assertEquals("List<Pair<Double, String>>", desc.toString()); } }
TypeDescriptor numberDescriptor = new TypeDescriptor(Number.class); TypeDescriptor listNumberDescriptor = new TypeDescriptor(List.class, numberDescriptor); TypeDescriptor byteDescriptor = new TypeDescriptor(Byte.class); TypeDescriptor shortDescriptor = new TypeDescriptor(Short.class); TypeDescriptor integerDescriptor = new TypeDescriptor(Integer.class); TypeDescriptor longDescriptor = new TypeDescriptor(Long.class); TypeDescriptor atomicIntegerDescriptor = new TypeDescriptor(AtomicInteger.class); TypeDescriptor atomicLongDescriptor = new TypeDescriptor(AtomicLong.class); TypeDescriptor floatDescriptor = new TypeDescriptor(Float.class); TypeDescriptor doubleDescriptor = new TypeDescriptor(Double.class); TypeDescriptor bigIntegerDescriptor = new TypeDescriptor(BigInteger.class); TypeDescriptor bigDecimalDescriptor = new TypeDescriptor(BigDecimal.class); if ( expandedExpectedBinClass.equals(numberDescriptor) ) { result = serializerBinTypeDescriptor.equals(byteDescriptor) || serializerBinTypeDescriptor.equals(shortDescriptor) || serializerBinTypeDescriptor.equals(integerDescriptor) || serializerBinTypeDescriptor.equals(longDescriptor) || serializerBinTypeDescriptor.equals(atomicIntegerDescriptor) || serializerBinTypeDescriptor.equals(atomicLongDescriptor) || serializerBinTypeDescriptor.equals(floatDescriptor) || serializerBinTypeDescriptor.equals(doubleDescriptor) || serializerBinTypeDescriptor.equals(bigIntegerDescriptor) || serializerBinTypeDescriptor.equals(bigDecimalDescriptor); } else if ( expandedExpectedBinClass.equals(listNumberDescriptor) ) { TypeDescriptor byteListDescriptor = new TypeDescriptor(List.class, byteDescriptor); TypeDescriptor shortListDescriptor = new TypeDescriptor(List.class, shortDescriptor);
private static String getTypeName (TypeDescriptor type) { Class<?> mainType = type.getMainType(); String name; String startSubList; List<TypeDescriptor> genericTypes = type.getGenericTypes(); if (null != genericTypes && !genericTypes.isEmpty()) { name += startSubList;
@Override public String toString () { String result = _mainType.getSimpleName(); if (null != _genericTypes && !_genericTypes.isEmpty()) { result += "<"; for (int i=0; i<_genericTypes.size(); ++i) { if (i>0) result += ", "; result += _genericTypes.get(i).toString(); } result += ">"; } return result; } }
@Override public <T> Put getPutForTile(TileData<T> tile, TileSerializer<T> serializer) throws IOException { TypeDescriptor binType = serializer.getBinTypeDescription(); Put put = super.getPutForTile(tile, serializer); if (List.class == binType.getMainType()) { put = addSlices(put, (TileSerializer) serializer, (TileData) tile); } return put; }
@Override public boolean equals (Object obj) { if (this == obj) return true; if (null == obj) return false; if (!(obj instanceof TypeDescriptor)) return false; TypeDescriptor that = (TypeDescriptor) obj; if (!_mainType.equals(that._mainType)) return false; int thisSize = (null == this._genericTypes ? 0 : this._genericTypes.size()); int thatSize = (null == that._genericTypes ? 0 : that._genericTypes.size()); if (thisSize != thatSize) return false; for (int i = 0; i < thisSize; ++i) { if (!this._genericTypes.get(i).equals(that._genericTypes.get(i))) return false; } return true; }
Matcher m = SLICE_PATTERN.matcher(tableName); TypeDescriptor binType = serializer.getBinTypeDescription(); if (List.class == binType.getMainType() && m.matches()) { String realName = m.group("table"); HBaseColumn[] columns;
/** * All this method does is check the return type of a serializer * programatically, As such, it supercedes the warnings hidden here. * * It will only work, of course, if the serializer is set up correctly * (i.e., without lying about its type_, and if the pass-ed class and * expandedClass actually match; mis-use will, of course, cause errors. */ @SuppressWarnings({"unchecked", "rawtypes"}) public static <T> TileSerializer<T> checkBinClass (TileSerializer<?> serializer, Class<T> expectedBinClass, TypeDescriptor expandedExpectedBinClass) throws ConfigurationException { if (null == serializer) { throw new ConfigurationException("No serializer given for renderer"); } if ( !expandedExpectedBinClass.equals(serializer.getBinTypeDescription()) && !serializerTypeCompatibleToNumber( serializer, expandedExpectedBinClass )) { throw new ConfigurationException("Serialization type does not match rendering type. Serialization class was "+serializer.getBinTypeDescription()+", renderer type was "+expandedExpectedBinClass); } return (TileSerializer) serializer; }
@Override public TypeDescriptor getAcceptedTypeDescriptor () { return new TypeDescriptor(List.class, new TypeDescriptor(Pair.class, new TypeDescriptor(String.class), new TypeDescriptor(Double.class))); }
public GenericAvroArraySerializer (CodecFactory compressionCodec, TypeDescriptor elementTypeDescription) { super(compressionCodec, new TypeDescriptor(List.class, elementTypeDescription)); }
public TypeDescriptor getAcceptedTypeDescriptor() { return new TypeDescriptor( List.class, new TypeDescriptor( Number.class ) ); }
/** * Wrap a primitive type in a type descriptor, making sure while doing so that it * actually is a primitive type. */ static <T> TypeDescriptor getPrimitiveTypeDescriptor (Class<? extends T> type) { if (!isValidPrimitive(type)) throw new IllegalArgumentException("Invalid type "+type+ ": Not one of the prescribed primitives allowed."); return new TypeDescriptor(type); }
@Override public TypeDescriptor getAcceptedTypeDescriptor() { return new TypeDescriptor(getAcceptedBinClass()); }
@Override public TypeDescriptor getAcceptedTypeDescriptor() { return new TypeDescriptor( getAcceptedBinClass() ); }
public PairArrayAvroSerializer (Class<? extends S> keyType, Class<? extends T> valueType, CodecFactory compressionCodec) { super(compressionCodec, new TypeDescriptor(Pair.class, PrimitiveAvroSerializer.getPrimitiveTypeDescriptor(keyType), PrimitiveAvroSerializer.getPrimitiveTypeDescriptor(valueType))); _keyType = keyType; _valueType = valueType; _keyToString = (String.class.equals(keyType)); _valueToString = (String.class.equals(valueType)); }
public PairAvroSerializer (Class<? extends S> keyType, Class<? extends T> valueType, CodecFactory compressionCodec) { super(compressionCodec, new TypeDescriptor(Pair.class, PrimitiveAvroSerializer.getPrimitiveTypeDescriptor(keyType), PrimitiveAvroSerializer.getPrimitiveTypeDescriptor(valueType))); _keyType = keyType; _valueType = valueType; _keyToString = (String.class.equals(keyType)); _valueToString = (String.class.equals(valueType)); }
@Test public void testKryoVectorTileDeSerialization () throws Exception { deserialize(KRYO, VECTOR_DATA, _vectorData, new KryoSerializer<List<Double>>(new TypeDescriptor(List.class, new TypeDescriptor(Double.class)))); }
@Test public void testKryoVectorTileSerialization () throws Exception { serialize(KRYO, VECTOR_DATA, _vectorData, new KryoSerializer<List<Double>>(new TypeDescriptor(List.class, new TypeDescriptor(Double.class)))); }
case Kryo: if (null == _serializer || !(_serializer instanceof KryoSerializer)) { _serializer = new KryoSerializer<Double>(new TypeDescriptor(Double.class)); _bucketSerializer = null; changed = true; case KryoBucketted: if (null == _bucketSerializer|| !(_bucketSerializer instanceof KryoSerializer)) { _bucketSerializer = new KryoSerializer<>(new TypeDescriptor(List.class, new TypeDescriptor(Double.class)), KryoSerializer.Codec.GZIP); _serializer = null; changed = true;