@SuppressWarnings("unchecked") @Override public VectorTypeInformation<?> fromByteBuffer(ByteBuffer buffer) throws IOException, UnsupportedOperationException { try { // Factory type! String typename = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); NumberVector.Factory<NumberVector> factory = (NumberVector.Factory<NumberVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename); String label = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); label = ("".equals(label)) ? null : label; String sername = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); ByteBufferSerializer<NumberVector> serializer = (ByteBufferSerializer<NumberVector>) Class.forName(sername).newInstance(); int mindim = ByteArrayUtil.readSignedVarint(buffer); int maxdim = ByteArrayUtil.readSignedVarint(buffer); return new VectorTypeInformation<NumberVector>(factory, serializer, mindim, maxdim); } catch (ClassInstantiationException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate factory: "+e, e); } catch (ClassNotFoundException e) { throw new UnsupportedOperationException("Cannot deserialize - class not found: "+e, e); } catch (InstantiationException | IllegalAccessException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate serializer: "+e.getMessage(), e); } }
@SuppressWarnings("unchecked") @Override public VectorTypeInformation<?> fromByteBuffer(ByteBuffer buffer) throws IOException, UnsupportedOperationException { try { // Factory type! String typename = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); NumberVector.Factory<NumberVector> factory = (NumberVector.Factory<NumberVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename); String label = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); label = ("".equals(label)) ? null : label; String sername = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); ByteBufferSerializer<NumberVector> serializer = (ByteBufferSerializer<NumberVector>) Class.forName(sername).newInstance(); int mindim = ByteArrayUtil.readSignedVarint(buffer); int maxdim = ByteArrayUtil.readSignedVarint(buffer); return new VectorTypeInformation<NumberVector>(factory, serializer, mindim, maxdim); } catch (ClassInstantiationException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate factory: "+e, e); } catch (ClassNotFoundException e) { throw new UnsupportedOperationException("Cannot deserialize - class not found: "+e, e); } catch (InstantiationException | IllegalAccessException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate serializer: "+e.getMessage(), e); } }
@SuppressWarnings("unchecked") @Override public VectorTypeInformation<?> fromByteBuffer(ByteBuffer buffer) throws IOException, UnsupportedOperationException { try { // Factory type! String typename = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); NumberVector.Factory<DoubleVector> factory = (NumberVector.Factory<DoubleVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename); String label = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); label = ("".equals(label)) ? null : label; String sername = ByteArrayUtil.STRING_SERIALIZER.fromByteBuffer(buffer); ByteBufferSerializer<DoubleVector> serializer = (ByteBufferSerializer<DoubleVector>) Class.forName(sername).newInstance(); int mindim = ByteArrayUtil.readSignedVarint(buffer); int maxdim = ByteArrayUtil.readSignedVarint(buffer); // FIXME: should/must provide a factory now! return new VectorTypeInformation<>(factory, serializer, mindim, maxdim); } catch (UnableToComplyException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate factory: "+e, e); } catch (ClassNotFoundException e) { throw new UnsupportedOperationException("Cannot deserialize - class not found: "+e, e); } catch (InstantiationException | IllegalAccessException e) { throw new UnsupportedOperationException("Cannot deserialize - cannot instantiate serializer: "+e.getMessage(), e); } }
NumberVector.Factory<DoubleVector> factory = (NumberVector.Factory<DoubleVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename);
NumberVector.Factory<NumberVector> factory = (NumberVector.Factory<NumberVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename);
NumberVector.Factory<NumberVector> factory = (NumberVector.Factory<NumberVector>) ClassGenericsUtil.instantiate(NumberVector.Factory.class, typename);