public OrcOiBatchToRowReader(RecordReader<NullWritable, VectorizedRowBatch> vrbReader, VectorizedRowBatchCtx vrbCtx, List<Integer> includedCols) { super(vrbReader, vrbCtx, includedCols); this.recordIdentifier = new RecordIdentifier(); this.isNull = true; }
@Override public RecordIdentifier createKey() { return new RecordIdentifier(); }
BigRow(int myint, long mylong, String mytext, float myfloat, double mydouble, long rowId, long origTxn, int bucket) { this.myint = myint; this.mylong = mylong; this.mytext = new Text(mytext); this.myfloat = myfloat; this.mydouble = mydouble; ROW__ID = new RecordIdentifier(origTxn, bucket, rowId); }
MyRow(String val, long rowId, long origTxn, int bucket) { field = new Text(val); ROW__ID = new RecordIdentifier(origTxn, bucket, rowId); }
MyRow(String val, long rowId, long origTxn, int bucket) { col1 = new Text(val); ROW__ID = new RecordIdentifier(origTxn, bucket, rowId); }
@Override public void readFields(DataInput dataInput) throws IOException { boolean notNull = dataInput.readBoolean(); if (notNull) { partVal = new Text(); partVal.readFields(dataInput); } notNull = dataInput.readBoolean(); if (notNull) { recId = new RecordIdentifier(); recId.readFields(dataInput); } } @Override
@Test public void testMixedOutOfSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 4)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 0)), is(false)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 5)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 6)), is(false)); }
@Test public void testMixedInSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 1)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 1)), is(true)); }
@Test public void testTxIdOutOfSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(4L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 0)), is(false)); }
@Test public void testTxIdInSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(1L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(4L, BUCKET_ID, 0)), is(true)); }
@Override public Object attachBucketIdToRecord(Object record) { int bucketId = computeBucketId(record); int bucketProperty = BucketCodec.V1.encode(new AcidOutputFormat.Options(null).bucket(bucketId)); RecordIdentifier recordIdentifier = new RecordIdentifier(INVALID_TRANSACTION_ID, bucketProperty, INVALID_ROW_ID); structObjectInspector.setStructFieldData(record, recordIdentifierField, recordIdentifier); return record; }
@Test public void testNegativeTxId() { assertThat(validator.isInSequence(new RecordIdentifier(-1L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); }
@Test public void testRowIdInSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 1)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 4)), is(true)); }
@Test public void testRowIdOutOfSequence() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 4)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 1)), is(false)); }
@Test public void testReset() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 4)), is(true)); // New partition for example validator.reset(); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 1)), is(true)); }
@Test public void testNegativeRowId() { assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, -1)), is(true)); assertThat(validator.isInSequence(new RecordIdentifier(0L, BUCKET_ID, 0)), is(true)); }
DummyRow(long val, long rowId, long origTxn, int bucket) { field = new LongWritable(val); bucket = BucketCodec.V1.encode(new AcidOutputFormat.Options(null).bucket(bucket)); ROW__ID = new RecordIdentifier(origTxn, bucket, rowId); }
BigRow(byte[] val, long rowId, long origTxn, int bucket) { field = new BytesWritable(val); bucket = BucketCodec.V1.encode(new AcidOutputFormat.Options(null).bucket(bucket)); this.rowId = new RecordIdentifier(origTxn, bucket, rowId); }
@Test public void testExtractRecordIdentifier() { RecordIdentifier recordIdentifier = new RecordIdentifier(10L, 4, 20L); MutableRecord record = new MutableRecord(1, "hello", recordIdentifier); assertThat(inspector.extractRecordIdentifier(record), is(recordIdentifier)); }
@Test public void testAttachBucketIdToRecord() { MutableRecord record = new MutableRecord(1, "hello"); capturingBucketIdResolver.attachBucketIdToRecord(record); assertThat(record.rowId, is(new RecordIdentifier(-1L, BucketCodec.V1.encode(new AcidOutputFormat.Options(null).bucket(1)), -1L))); assertThat(record.id, is(1)); assertThat(record.msg.toString(), is("hello")); }