@Override protected Long decodeUnchecked(byte[] data, int offset, int len) { return super.decodeUnchecked(data, offset, len) ^ 0x8000000000000000L; } }
@Override public byte[] encode(Long l) { return super.encode(l ^ 0x8000000000000000L); }
public static long getTimeClosed(Key k, Text buff) { k.getRow(buff); int offset = 0; // find the last offset while (true) { int nextOffset = buff.find(ROW_SEPARATOR.toString(), offset + 1); if (nextOffset == -1) { break; } offset = nextOffset; } if (offset == -1) { throw new IllegalArgumentException( "Row does not contain expected separator for OrderSection"); } byte[] encodedLong = new byte[offset]; System.arraycopy(buff.getBytes(), 0, encodedLong, 0, offset); return longEncoder.decode(encodedLong); }
public static long getTimeClosed(Key k, Text buff) { k.getRow(buff); int offset = 0; // find the last offset while (true) { int nextOffset = buff.find(ROW_SEPARATOR.toString(), offset + 1); if (-1 == nextOffset) { break; } offset = nextOffset; } if (-1 == offset) { throw new IllegalArgumentException( "Row does not contain expected separator for OrderSection"); } byte[] encodedLong = new byte[offset]; System.arraycopy(buff.getBytes(), 0, encodedLong, 0, offset); return longEncoder.decode(encodedLong); }
@Override public byte[] encode(Double d) { long l = Double.doubleToRawLongBits(d); if (l < 0) l = ~l; else l = l ^ 0x8000000000000000L; return longEncoder.encode(l); }
@Override protected Double decodeUnchecked(byte[] data, int offset, int len) { long l = longEncoder.decodeUnchecked(data, offset, len); if (l < 0) l = l ^ 0x8000000000000000L; else l = ~l; return Double.longBitsToDouble(l); }
/** * Creates the Mutation for the Order section for the given file and time * * @param file * Filename * @param timeInMillis * Time in millis that the file was closed * @return Mutation for the Order section */ public static Mutation createMutation(String file, long timeInMillis) { requireNonNull(file); checkArgument(timeInMillis >= 0, "timeInMillis must be greater than zero"); // Encode the time so it sorts properly byte[] rowPrefix = longEncoder.encode(timeInMillis); Text row = new Text(rowPrefix); // Normalize the file using Path Path p = new Path(file); String pathString = p.toUri().toString(); log.trace("Normalized {} into {}", file, pathString); // Append the file as a suffix to the row row.append((ROW_SEPARATOR + pathString).getBytes(UTF_8), 0, pathString.length() + ROW_SEPARATOR.getLength()); // Make the mutation and add the column update return new Mutation(row); }
@Override protected Long decodeUnchecked(byte[] data, int offset, int len) { return super.decodeUnchecked(data, offset, len) ^ 0x8000000000000000l; } }
@Override public byte[] encode(Long l) { return super.encode(l ^ 0x8000000000000000l); }
@Override protected Double decodeUnchecked(byte[] data, int offset, int len) { long l = longEncoder.decodeUnchecked(data, offset, len); if (l < 0) l = l ^ 0x8000000000000000l; else l = ~l; return Double.longBitsToDouble(l); }
@Override public byte[] encode(Double d) { long l = Double.doubleToRawLongBits(d); if (l < 0) l = ~l; else l = l ^ 0x8000000000000000l; return longEncoder.encode(l); }
/** * Creates the Mutation for the Order section for the given file and time * * @param file * Filename * @param timeInMillis * Time in millis that the file was closed * @return Mutation for the Order section */ public static Mutation createMutation(String file, long timeInMillis) { requireNonNull(file); checkArgument(timeInMillis >= 0, "timeInMillis must be greater than zero"); // Encode the time so it sorts properly byte[] rowPrefix = longEncoder.encode(timeInMillis); Text row = new Text(rowPrefix); // Normalize the file using Path Path p = new Path(file); String pathString = p.toUri().toString(); log.trace("Normalized {} into {}", file, pathString); // Append the file as a suffix to the row row.append((ROW_SEPARATOR + pathString).getBytes(UTF_8), 0, pathString.length() + ROW_SEPARATOR.getLength()); // Make the mutation and add the column update return new Mutation(row); }