Skip to content

Commit

Permalink
ORC-1013: Renaming a parameter in constructors of TreeWriter's derive…
Browse files Browse the repository at this point in the history
…d classes (#922)

### What changes were proposed in this pull request?

This PR renames `WriterContext writer` parameter to `WriterContext context` like `TreeWriter`.

### Why are the changes needed?

For consistency.

### How was this patch tested?

There's no function change so passing the existing unit tests should be sufficient.
  • Loading branch information
autumnust authored Oct 9, 2021
1 parent 93af6b0 commit 9dbf833
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class BinaryTreeWriter extends TreeWriterBase {

public BinaryTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.stream = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.stream = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.isDirectV2 = isNewWriteFormat(writer);
this.length = createIntegerWriter(writer.createStream(
this.isDirectV2 = isNewWriteFormat(context);
this.length = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.LENGTH, encryption)),
false, isDirectV2, writer);
false, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class BooleanTreeWriter extends TreeWriterBase {

public BooleanTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
PositionedOutputStream out = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
PositionedOutputStream out = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.writer = new BitFieldWriter(out, 1);
if (rowIndexPosition != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class ByteTreeWriter extends TreeWriterBase {

public ByteTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.writer = new RunLengthByteWriter(writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.writer = new RunLengthByteWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption)));
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class CharTreeWriter extends StringBaseTreeWriter {

CharTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
maxLength = schema.getMaxLength();
// utf-8 is currently 4 bytes long, but it could be upto 6
padding = new byte[6*maxLength];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ public class DateTreeWriter extends TreeWriterBase {

public DateTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
OutStream out = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
OutStream out = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.isDirectV2 = isNewWriteFormat(writer);
this.writer = createIntegerWriter(out, true, isDirectV2, writer);
this.isDirectV2 = isNewWriteFormat(context);
this.writer = createIntegerWriter(out, true, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
useProleptic = writer.getProlepticGregorian();
useProleptic = context.getProlepticGregorian();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class Decimal64TreeWriter extends TreeWriterBase {

public Decimal64TreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
OutStream stream = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
OutStream stream = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
// Use RLEv2 until we have the new RLEv3.
valueWriter = new RunLengthIntegerWriterV2(stream, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public class DecimalTreeWriter extends TreeWriterBase {

public DecimalTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.isDirectV2 = isNewWriteFormat(writer);
valueStream = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.isDirectV2 = isNewWriteFormat(context);
valueStream = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
scratchLongs = new long[HiveDecimal.SCRATCH_LONGS_LEN];
scratchBuffer = new byte[HiveDecimal.SCRATCH_BUFFER_LEN_TO_BYTES];
this.scaleStream = createIntegerWriter(writer.createStream(
this.scaleStream = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.SECONDARY, encryption)),
true, isDirectV2, writer);
true, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class DoubleTreeWriter extends TreeWriterBase {

public DoubleTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.stream = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.stream = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.utils = new SerializationUtils();
if (rowIndexPosition != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class FloatTreeWriter extends TreeWriterBase {

public FloatTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.stream = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.stream = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.utils = new SerializationUtils();
if (rowIndexPosition != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class IntegerTreeWriter extends TreeWriterBase {

public IntegerTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
OutStream out = writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
OutStream out = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
this.isDirectV2 = isNewWriteFormat(writer);
this.writer = createIntegerWriter(out, true, isDirectV2, writer);
this.isDirectV2 = isNewWriteFormat(context);
this.writer = createIntegerWriter(out, true, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public class ListTreeWriter extends TreeWriterBase {

ListTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.isDirectV2 = isNewWriteFormat(writer);
childWriter = Factory.create(schema.getChildren().get(0), encryption, writer);
lengths = createIntegerWriter(writer.createStream(
WriterContext context) throws IOException {
super(schema, encryption, context);
this.isDirectV2 = isNewWriteFormat(context);
childWriter = Factory.create(schema.getChildren().get(0), encryption, context);
lengths = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.LENGTH, encryption)),
false, isDirectV2, writer);
false, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
Expand Down
14 changes: 7 additions & 7 deletions java/core/src/java/org/apache/orc/impl/writer/MapTreeWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public class MapTreeWriter extends TreeWriterBase {

MapTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
this.isDirectV2 = isNewWriteFormat(writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
this.isDirectV2 = isNewWriteFormat(context);
List<TypeDescription> children = schema.getChildren();
keyWriter = Factory.create(children.get(0), encryption, writer);
valueWriter = Factory.create(children.get(1), encryption, writer);
lengths = createIntegerWriter(writer.createStream(
keyWriter = Factory.create(children.get(0), encryption, context);
valueWriter = Factory.create(children.get(1), encryption, context);
lengths = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.LENGTH, encryption)),
false, isDirectV2, writer);
false, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,27 @@ private static Dictionary createDict(Configuration conf) {

StringBaseTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
Configuration conf = writer.getConfiguration();
WriterContext context) throws IOException {
super(schema, encryption, context);
Configuration conf = context.getConfiguration();

this.dictionary = createDict(conf);
this.isDirectV2 = isNewWriteFormat(writer);
directStreamOutput = writer.createStream(
this.isDirectV2 = isNewWriteFormat(context);
directStreamOutput = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption));
stringOutput = writer.createStream(
stringOutput = context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DICTIONARY_DATA, encryption));
lengthOutput = createIntegerWriter(writer.createStream(
lengthOutput = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.LENGTH, encryption)),
false, isDirectV2, writer);
false, isDirectV2, context);
rowOutput = createIntegerWriter(directStreamOutput, false, isDirectV2,
writer);
context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
rowIndexValueCount.add(0L);
buildIndex = writer.buildIndex();
dictionaryKeySizeThreshold = writer.getDictionaryKeySizeThreshold(id);
buildIndex = context.buildIndex();
dictionaryKeySizeThreshold = context.getDictionaryKeySizeThreshold(id);
strideDictionaryCheck =
OrcConf.ROW_INDEX_STRIDE_DICTIONARY_CHECK.getBoolean(conf);
if (dictionaryKeySizeThreshold <= 0.0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class StringTreeWriter extends StringBaseTreeWriter {
StringTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class StructTreeWriter extends TreeWriterBase {

public StructTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
List<TypeDescription> children = schema.getChildren();
childrenWriters = new TreeWriter[children.size()];
for (int i = 0; i < childrenWriters.length; ++i) {
childrenWriters[i] = Factory.create(children.get(i), encryption, writer);
childrenWriters[i] = Factory.create(children.get(i), encryption, context);
}
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ public class TimestampTreeWriter extends TreeWriterBase {

public TimestampTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer,
WriterContext context,
boolean instantType) throws IOException {
super(schema, encryption, writer);
this.isDirectV2 = isNewWriteFormat(writer);
this.seconds = createIntegerWriter(writer.createStream(
super(schema, encryption, context);
this.isDirectV2 = isNewWriteFormat(context);
this.seconds = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption)),
true, isDirectV2, writer);
this.nanos = createIntegerWriter(writer.createStream(
true, isDirectV2, context);
this.nanos = createIntegerWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.SECONDARY, encryption)),
false, isDirectV2, writer);
false, isDirectV2, context);
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
}
this.alwaysUTC = instantType || writer.getUseUTCTimestamp();
this.alwaysUTC = instantType || context.getUseUTCTimestamp();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
if (this.alwaysUTC) {
Expand All @@ -82,7 +82,7 @@ public TimestampTreeWriter(TypeDescription schema,
} catch (ParseException e) {
throw new IOException("Unable to create base timestamp tree writer", e);
}
useProleptic = writer.getProlepticGregorian();
useProleptic = context.getProlepticGregorian();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public class UnionTreeWriter extends TreeWriterBase {

UnionTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
List<TypeDescription> children = schema.getChildren();
childrenWriters = new TreeWriterBase[children.size()];
for (int i = 0; i < childrenWriters.length; ++i) {
childrenWriters[i] = Factory.create(children.get(i), encryption, writer);
childrenWriters[i] = Factory.create(children.get(i), encryption, context);
}
tags =
new RunLengthByteWriter(writer.createStream(
new RunLengthByteWriter(context.createStream(
new StreamName(id, OrcProto.Stream.Kind.DATA, encryption)));
if (rowIndexPosition != null) {
recordPosition(rowIndexPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class VarcharTreeWriter extends StringBaseTreeWriter {

VarcharTreeWriter(TypeDescription schema,
WriterEncryptionVariant encryption,
WriterContext writer) throws IOException {
super(schema, encryption, writer);
WriterContext context) throws IOException {
super(schema, encryption, context);
maxLength = schema.getMaxLength();
}

Expand Down

0 comments on commit 9dbf833

Please sign in to comment.