public SpecificRequestor(Class<?> iface, Transceiver transceiver) throws IOException { this(iface, transceiver, new SpecificData(iface.getClassLoader())); }
public SpecificResponder(Class iface, Object impl) { this(iface, impl, new SpecificData(impl.getClass().getClassLoader())); }
public SpecificResponder(Protocol protocol, Object impl) { this(protocol, impl, new SpecificData(impl.getClass().getClassLoader())); }
/** Create a proxy instance whose methods invoke RPCs. */ public static <T> T getClient(Class<T> iface, Transceiver transceiver) throws IOException { return getClient(iface, transceiver, new SpecificData(iface.getClassLoader())); }
void checkAvroInitialized() { if (datumReader != null) { return; } ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (SpecificRecord.class.isAssignableFrom(recordClazz)) { SpecificData specificData = new SpecificData(cl); this.datumReader = new SpecificDatumReader<>(specificData); this.reader = specificData.getSchema(recordClazz); } else { this.reader = new Schema.Parser().parse(schemaString); GenericData genericData = new GenericData(cl); this.datumReader = new GenericDatumReader<>(null, this.reader, genericData); } this.inputStream = new MutableByteArrayInputStream(); this.decoder = DecoderFactory.get().binaryDecoder(inputStream, null); }
/** Construct for reading instances of a class. */ public SpecificDatumReader(Class<T> c) { this(new SpecificData(c.getClassLoader())); setSchema(getSpecificData().getSchema(c)); }
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") private static <T> AvroFactory<T> fromSpecific(Class<T> type, ClassLoader cl, Optional<Schema> previousSchema) { SpecificData specificData = new SpecificData(cl); Schema newSchema = specificData.getSchema(type); return new AvroFactory<>( specificData, newSchema, new SpecificDatumReader<>(previousSchema.orElse(newSchema), newSchema, specificData), new SpecificDatumWriter<>(newSchema, specificData) ); }
private static Schema tryExtractAvroSchema(ClassLoader cl, Class<?> runtimeType) { if (isGenericRecord(runtimeType)) { return null; } if (isSpecificRecord(runtimeType)) { SpecificData d = new SpecificData(cl); return d.getSchema(runtimeType); } ReflectData d = new ReflectData(cl); return d.getSchema(runtimeType); }
@Test public void testClassLoader() throws Exception { ClassLoader loader = new ClassLoader() {}; SpecificResponder responder = new SpecificResponder(Simple.class, new TestImpl(), new SpecificData(loader)); assertEquals(responder.getSpecificData().getClassLoader(), loader); SpecificRequestor requestor = new SpecificRequestor(Simple.class, client, new SpecificData(loader)); assertEquals(requestor.getSpecificData().getClassLoader(), loader); }
public SpecificRequestor(Class<?> iface, Transceiver transceiver) throws IOException { this(iface, transceiver, new SpecificData(iface.getClassLoader())); }
public SpecificResponder(Class iface, Object impl) { this(iface, impl, new SpecificData(impl.getClass().getClassLoader())); }
public SpecificResponder(Protocol protocol, Object impl) { this(protocol, impl, new SpecificData(impl.getClass().getClassLoader())); }
/** Create a proxy instance whose methods invoke RPCs. */ public static <T> T getClient(Class<T> iface, Transceiver transciever) throws IOException { return getClient(iface, transciever, new SpecificData(iface.getClassLoader())); }
/** * Check if it is Specific Record according to the input schema from job config. * Return true if the input schema is not null and there is a specific class for it. */ public static boolean isSpecificRecordSchema(Schema inputSchema) { return inputSchema != null && new SpecificData().getClass(inputSchema) != null; } }
/** Construct for reading instances of a class. */ public SpecificDatumReader(Class<T> c) { this(new SpecificData(c.getClassLoader())); setSchema(getSpecificData().getSchema(c)); }
/** Construct for reading instances of a class. */ public SpecificDatumReader(Class<T> c) { this(new SpecificData(c.getClassLoader())); setSchema(getSpecificData().getSchema(c)); }
@SuppressWarnings("unchecked") public KeyValueRecords(Schema keySchema, Schema valueSchema, Records records) { keySchema_ = keySchema; valueSchema_ = valueSchema; keyClass_ = new SpecificData().getClass(keySchema_); valueClass_ = new SpecificData().getClass(valueSchema_); records_ = records; schema_ = records_.getSchema(); // Verifies and resolves the schema of Key / value with the RecordService schema. keyIndexToRsIndex_ = RecordUtil.resolveSchema(keySchema_, schema_, RecordUtil.ResolveBy.NAME); valueIndexToRsIndex_ = RecordUtil.resolveSchema(valueSchema_, schema_, RecordUtil.ResolveBy.NAME); }
@SuppressWarnings("unchecked") public SpecificRecords(Schema readerSchema, Records records, RecordUtil.ResolveBy resolveBy) { avroSchema_ = readerSchema; class_ = new SpecificData().getClass(avroSchema_); records_ = records; schema_ = records_.getSchema(); recordIndexToRsIndex_ = RecordUtil.resolveSchema(avroSchema_, schema_, resolveBy); }
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") private static <T> AvroFactory<T> fromSpecific(Class<T> type, ClassLoader cl, Optional<Schema> previousSchema) { SpecificData specificData = new SpecificData(cl); Schema newSchema = specificData.getSchema(type); return new AvroFactory<>( specificData, newSchema, new SpecificDatumReader<>(previousSchema.orElse(newSchema), newSchema, specificData), new SpecificDatumWriter<>(newSchema, specificData) ); }
private static Schema tryExtractAvroSchema(ClassLoader cl, Class<?> runtimeType) { if (isGenericRecord(runtimeType)) { return null; } if (isSpecificRecord(runtimeType)) { SpecificData d = new SpecificData(cl); return d.getSchema(runtimeType); } ReflectData d = new ReflectData(cl); return d.getSchema(runtimeType); }