Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@
@InterfaceAudience.Public
public class OrderedBlob extends OrderedBytesBase<byte[]> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedBlob ASCENDING = new OrderedBlob(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will b removed in 4.0.0
*/
@Deprecated
public static final OrderedBlob DESCENDING = new OrderedBlob(Order.DESCENDING);

protected OrderedBlob(Order order) {
/**
* Creates a new {@code byte[]} with variable length.
*
* @param order the {@link Order} to use
*/
public OrderedBlob(Order order) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is intentional? User can use the above ASCENDING and DESCENDING directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess so. @ndimiduk probably can answer this question better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's precisely it. See my last comment on JIRA. The original design of this part of the API was to try to prevent callers from needless allocations. That couldn't be done uniformly, though, as some of these implementations require explicit construction parameters. I myself filed a ticket wondering why I had left some constructors private. I believe the uniformity of public constructors across all concrete types is more consistent that having static constants in most, but not all, places.

This is definitely a subjective area of the API design and I'd love to get other opinions :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it consistent, how about making the constructors public for consistency reasons and deprecate the static constants (and remove them in another release) to make it more consistent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think deprecating the static constants is appropriate, then I have no objection. There's always a balance between minimizing our supported surface area and downstream convenience. I've not followed things very closely as of late, but it seems we're on a pretty strong kick to deprecate/drop old interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should discuss this on the dev list. @Apache9 Is your question answered? What do you think? Should we leave it as is or should we deprecate the static constants?

super(order);
}

Expand Down Expand Up @@ -65,6 +78,12 @@ public int encode(PositionedByteRange dst, byte[] val) {

/**
* Write a subset of {@code val} to {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @param voff the offset in {@code dst} where to write {@code val} to
* @param vlen the lenght of {@code val}
* @return the number of bytes written
*/
public int encode(PositionedByteRange dst, byte[] val, int voff, int vlen) {
return OrderedBytes.encodeBlobCopy(dst, val, voff, vlen, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@
*/
@InterfaceAudience.Public
public class OrderedBlobVar extends OrderedBytesBase<byte[]> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedBlobVar ASCENDING = new OrderedBlobVar(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedBlobVar DESCENDING = new OrderedBlobVar(Order.DESCENDING);

protected OrderedBlobVar(Order order) {
public OrderedBlobVar(Order order) {
super(order);
}

Expand All @@ -58,7 +65,13 @@ public int encode(PositionedByteRange dst, byte[] val) {
}

/**
* Write a subset of {@code val} to {@code buff}.
* Write a subset of {@code val} to {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @param voff the offset in {@code dst} where to write {@code val} to
* @param vlen the lenght of {@code val}
* @return the number of bytes written
*/
public int encode(PositionedByteRange dst, byte[] val, int voff, int vlen) {
return OrderedBytes.encodeBlobVar(dst, val, voff, vlen, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class OrderedBytesBase<T> implements DataType<T> {

protected final Order order;

protected OrderedBytesBase(Order order) {
public OrderedBytesBase(Order order) {
this.order = order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedFloat32 extends OrderedBytesBase<Float> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedFloat32 ASCENDING = new OrderedFloat32(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedFloat32 DESCENDING = new OrderedFloat32(Order.DESCENDING);

protected OrderedFloat32(Order order) {
/**
* Creates a new 32-bit {@code float} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedFloat32(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Float val) {

/**
* Read a {@code float} value from the buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to read the {@code float} from
* @return the {@code float} read from the buffer
*/
public float decodeFloat(PositionedByteRange dst) {
return OrderedBytes.decodeFloat32(dst);
}

/**
* Write instance {@code val} into buffer {@code buff}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeFloat(PositionedByteRange dst, float val) {
return OrderedBytes.encodeFloat32(dst, val, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedFloat64 extends OrderedBytesBase<Double> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedFloat64 ASCENDING = new OrderedFloat64(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedFloat64 DESCENDING = new OrderedFloat64(Order.DESCENDING);

protected OrderedFloat64(Order order) {
/**
* Creates a new 64-bite {@code double} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedFloat64(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Double val) {

/**
* Read a {@code double} value from the buffer {@code src}.
*
* @param src the {@link PositionedByteRange} to read the {@code double} from
* @return the {@code double} floating-point value with the same bit pattern
*/
public double decodeDouble(PositionedByteRange src) {
return OrderedBytes.decodeFloat64(src);
}

/**
* Write instance {@code val} into buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeDouble(PositionedByteRange dst, double val) {
return OrderedBytes.encodeFloat64(dst, val, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedInt16 extends OrderedBytesBase<Short> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt16 ASCENDING = new OrderedInt16(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt16 DESCENDING = new OrderedInt16(Order.DESCENDING);

protected OrderedInt16(Order order) {
/**
* Creates a new 16-bit {@code short} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedInt16(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Short val) {

/**
* Read a {@code short} value from the buffer {@code src}.
*
* @param src the {@link PositionedByteRange} to read the {@code float} from
* @return the {@code short} read from buffer
*/
public short decodeShort(PositionedByteRange src) {
return OrderedBytes.decodeInt16(src);
}

/**
* Write instance {@code val} into buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeShort(PositionedByteRange dst, short val) {
return OrderedBytes.encodeInt16(dst, val, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedInt32 extends OrderedBytesBase<Integer> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt32 ASCENDING = new OrderedInt32(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt32 DESCENDING = new OrderedInt32(Order.DESCENDING);

protected OrderedInt32(Order order) {
/**
* Creates a new 32-bit {@code int} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedInt32(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Integer val) {

/**
* Read an {@code int} value from the buffer {@code src}.
*
* @param src the {@link PositionedByteRange} to read the {@code int} from
* @return the {@code int} read from the buffer
*/
public int decodeInt(PositionedByteRange src) {
return OrderedBytes.decodeInt32(src);
}

/**
* Write instance {@code val} into buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeInt(PositionedByteRange dst, int val) {
return OrderedBytes.encodeInt32(dst, val, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedInt64 extends OrderedBytesBase<Long> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt64 ASCENDING = new OrderedInt64(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt64 DESCENDING = new OrderedInt64(Order.DESCENDING);

protected OrderedInt64(Order order) {
/**
* Creates a new 64-bit {@code long} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedInt64(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Long val) {

/**
* Read a {@code long} value from the buffer {@code src}.
*
* @param src the {@link PositionedByteRange} to read the {@code long} from
* @return the {@code long} read from the buffer
*/
public long decodeLong(PositionedByteRange src) {
return OrderedBytes.decodeInt64(src);
}

/**
* Write instance {@code val} into buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeLong(PositionedByteRange dst, long val) {
return OrderedBytes.encodeInt64(dst, val, order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,23 @@
*/
@InterfaceAudience.Public
public class OrderedInt8 extends OrderedBytesBase<Byte> {

/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt8 ASCENDING = new OrderedInt8(Order.ASCENDING);
/**
* @deprecated since 3.0.0 and will be removed in 4.0.0
*/
@Deprecated
public static final OrderedInt8 DESCENDING = new OrderedInt8(Order.DESCENDING);

protected OrderedInt8(Order order) {
/**
* Creates a new 8-bit {@code byte} with a fixed-length encoding.
*
* @param order the {@link Order} to use
*/
public OrderedInt8(Order order) {
super(order);
}

Expand Down Expand Up @@ -66,13 +78,20 @@ public int encode(PositionedByteRange dst, Byte val) {

/**
* Read a {@code byte} value from the buffer {@code src}.
*
* @param src the {@link PositionedByteRange} to read the {@code byte} from
* @return the {@code byte} read from the buffer
*/
public byte decodeByte(PositionedByteRange src) {
return OrderedBytes.decodeInt8(src);
}

/**
* Write instance {@code val} into buffer {@code dst}.
*
* @param dst the {@link PositionedByteRange} to write to
* @param val the value to write to {@code dst}
* @return the number of bytes written
*/
public int encodeByte(PositionedByteRange dst, byte val) {
return OrderedBytes.encodeInt8(dst, val, order);
Expand Down
Loading