@Test public void partitionRecordTest() { Schema mockSchema = mock(Schema.class); GenericRecord mockRecord = mock(GenericRecord.class); String mockSchemaString = "returnSchemaString"; when(mockRecord.getSchema()).thenReturn(mockSchema); when(mockSchema.toString()).thenReturn(mockSchemaString); SchemaBasedWriterPartitioner partitioner = new SchemaBasedWriterPartitioner(null, 0, 0); GenericRecord partitionRecord = partitioner.partitionForRecord(mockRecord); Assert.assertEquals(partitionRecord.get(SchemaBasedWriterPartitioner.SCHEMA_STRING), mockSchemaString); }
@Override public GenericRecord partitionForRecord(GenericRecord record) { GenericRecord partition = new GenericData.Record(SCHEMA); partition.put(SCHEMA_STRING, record.getSchema().toString()); return partition; }
SchemaBasedWriterPartitioner implements WriterPartitioner<GenericRecord> { @Override public GenericRecord partitionForRecord(GenericRecord record) { GenericRecord partition = new GenericData.Record(SCHEMA); partition.put(SCHEMA_STRING, record.getSchema().toString()); return partition; } }
SchemaBasedWriterPartitioner implements WriterPartitioner<GenericRecord> { @Override public GenericRecord partitionForRecord(GenericRecord record) { GenericRecord partition = new GenericData.Record(SCHEMA); partition.put(SCHEMA_STRING, record.getSchema().toString()); return partition; } SchemaBasedWriterPartitioner(State state, int numBranches, int branchId); }
SchemaBasedWriterPartitioner implements WriterPartitioner<GenericRecord> { @Override public GenericRecord partitionForRecord(GenericRecord record) { GenericRecord partition = new GenericData.Record(SCHEMA); partition.put(SCHEMA_STRING, record.getSchema().toString()); return partition; } SchemaBasedWriterPartitioner(State state, int numBranches, int branchId); @Override Schema partitionSchema(); @Override GenericRecord partitionForRecord(GenericRecord record); }
SchemaBasedWriterPartitioner implements WriterPartitioner<GenericRecord> { @Override public GenericRecord partitionForRecord(GenericRecord record) { GenericRecord partition = new GenericData.Record(SCHEMA); partition.put(SCHEMA_STRING, record.getSchema().toString()); return partition; } SchemaBasedWriterPartitioner(State state, int numBranches, int branchId); @Override Schema partitionSchema(); @Override GenericRecord partitionForRecord(GenericRecord record); static final String SCHEMA_STRING; }