@Test (groups = "serializationTest") public void testIsSupportedForFastSpecificDatumWriter() { Schema testSchema = Schema.parse("{\"type\": \"record\", \"name\": \"test_record\", \"fields\":[]}"); FastSpecificDatumWriter fastWriter = FastDatumReaderWriterUtil.getFastSpecificDatumWriter(testSchema); Assert.assertNotNull(fastWriter); FastSpecificDatumWriter newFastWriter = FastDatumReaderWriterUtil.getFastSpecificDatumWriter(testSchema); Assert.assertSame(fastWriter, newFastWriter); }
public static <T> FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema) { FastSpecificDatumWriter<T> fastDatumWriter = null; reentrantReadWriteLock.readLock().lock(); try { fastDatumWriter = (FastSpecificDatumWriter<T>)fastSpecificDatumWriterCache.get(writerSchema); } finally { reentrantReadWriteLock.readLock().unlock(); } if (fastDatumWriter == null) { reentrantReadWriteLock.writeLock().lock(); try { fastDatumWriter = new FastSpecificDatumWriter<>(writerSchema); fastSpecificDatumWriterCache.put(writerSchema, fastDatumWriter); } finally { reentrantReadWriteLock.writeLock().unlock(); } } return (FastSpecificDatumWriter<T>) fastDatumWriter; }
FastDatumReaderWriterUtil { public static <T> FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema) { FastSpecificDatumWriter<T> fastDatumWriter = null; reentrantReadWriteLock.readLock().lock(); try { fastDatumWriter = (FastSpecificDatumWriter<T>)fastSpecificDatumWriterCache.get(writerSchema); } finally { reentrantReadWriteLock.readLock().unlock(); } if (fastDatumWriter == null) { reentrantReadWriteLock.writeLock().lock(); try { fastDatumWriter = new FastSpecificDatumWriter<>(writerSchema); fastSpecificDatumWriterCache.put(writerSchema, fastDatumWriter); } finally { reentrantReadWriteLock.writeLock().unlock(); } } return (FastSpecificDatumWriter<T>) fastDatumWriter; } }
FastDatumReaderWriterUtil { public static <T> FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema) { FastSpecificDatumWriter<T> fastDatumWriter = null; reentrantReadWriteLock.readLock().lock(); try { fastDatumWriter = (FastSpecificDatumWriter<T>)fastSpecificDatumWriterCache.get(writerSchema); } finally { reentrantReadWriteLock.readLock().unlock(); } if (fastDatumWriter == null) { reentrantReadWriteLock.writeLock().lock(); try { fastDatumWriter = new FastSpecificDatumWriter<>(writerSchema); fastSpecificDatumWriterCache.put(writerSchema, fastDatumWriter); } finally { reentrantReadWriteLock.writeLock().unlock(); } } return (FastSpecificDatumWriter<T>) fastDatumWriter; } private  FastDatumReaderWriterUtil(); }
FastDatumReaderWriterUtil { public static <T> FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema) { FastSpecificDatumWriter<T> fastDatumWriter = null; reentrantReadWriteLock.readLock().lock(); try { fastDatumWriter = (FastSpecificDatumWriter<T>)fastSpecificDatumWriterCache.get(writerSchema); } finally { reentrantReadWriteLock.readLock().unlock(); } if (fastDatumWriter == null) { reentrantReadWriteLock.writeLock().lock(); try { fastDatumWriter = new FastSpecificDatumWriter<>(writerSchema); fastSpecificDatumWriterCache.put(writerSchema, fastDatumWriter); } finally { reentrantReadWriteLock.writeLock().unlock(); } } return (FastSpecificDatumWriter<T>) fastDatumWriter; } private  FastDatumReaderWriterUtil(); static FastGenericDatumReader<T> getFastGenericDatumReader(Schema schema); static FastGenericDatumReader<T> getFastGenericDatumReader(Schema writerSchema, Schema readerSchema); static FastGenericDatumWriter<T> getFastGenericDatumWriter(Schema writerSchema); static FastSpecificDatumReader<T> getFastSpecificDatumReader(Schema schema); static FastSpecificDatumReader<T> getFastSpecificDatumReader(Schema writerSchema, Schema readerSchema); static FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema); }
FastDatumReaderWriterUtil { public static <T> FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema) { FastSpecificDatumWriter<T> fastDatumWriter = null; reentrantReadWriteLock.readLock().lock(); try { fastDatumWriter = (FastSpecificDatumWriter<T>)fastSpecificDatumWriterCache.get(writerSchema); } finally { reentrantReadWriteLock.readLock().unlock(); } if (fastDatumWriter == null) { reentrantReadWriteLock.writeLock().lock(); try { fastDatumWriter = new FastSpecificDatumWriter<>(writerSchema); fastSpecificDatumWriterCache.put(writerSchema, fastDatumWriter); } finally { reentrantReadWriteLock.writeLock().unlock(); } } return (FastSpecificDatumWriter<T>) fastDatumWriter; } private  FastDatumReaderWriterUtil(); static FastGenericDatumReader<T> getFastGenericDatumReader(Schema schema); static FastGenericDatumReader<T> getFastGenericDatumReader(Schema writerSchema, Schema readerSchema); static FastGenericDatumWriter<T> getFastGenericDatumWriter(Schema writerSchema); static FastSpecificDatumReader<T> getFastSpecificDatumReader(Schema schema); static FastSpecificDatumReader<T> getFastSpecificDatumReader(Schema writerSchema, Schema readerSchema); static FastSpecificDatumWriter<T> getFastSpecificDatumWriter(Schema writerSchema);  }