@Override public int compareTo(BlobKey o) { // compare the hashes first final byte[] aarr = this.key; final byte[] barr = o.key; final int len = Math.min(aarr.length, barr.length); for (int i = 0; i < len; ++i) { final int a = (aarr[i] & 0xff); final int b = (barr[i] & 0xff); if (a != b) { return a - b; } } if (aarr.length == barr.length) { // same hash contents - compare the BLOB types int typeCompare = this.type.compareTo(o.type); if (typeCompare == 0) { // same type - compare random components return this.random.compareTo(o.random); } else { return typeCompare; } } else { return aarr.length - barr.length; } }
/** * Constructs and writes the header data for a PUT request to the given output stream. * * @param outputStream * the output stream to write the PUT header data to * @param jobId * the ID of job the BLOB belongs to (or <tt>null</tt> if job-unrelated) * @param blobType * whether the BLOB should become permanent or transient * * @throws IOException * thrown if an I/O error occurs while writing the header data to the output stream */ private static void sendPutHeader( OutputStream outputStream, @Nullable JobID jobId, BlobKey.BlobType blobType) throws IOException { // Signal type of operation outputStream.write(PUT_OPERATION); if (jobId == null) { outputStream.write(JOB_UNRELATED_CONTENT); } else { outputStream.write(JOB_RELATED_CONTENT); outputStream.write(jobId.getBytes()); } outputStream.write(blobType.ordinal()); }
/** * Constructs and writes the header data for a PUT request to the given output stream. * * @param outputStream * the output stream to write the PUT header data to * @param jobId * the ID of job the BLOB belongs to (or <tt>null</tt> if job-unrelated) * @param blobType * whether the BLOB should become permanent or transient * * @throws IOException * thrown if an I/O error occurs while writing the header data to the output stream */ private static void sendPutHeader( OutputStream outputStream, @Nullable JobID jobId, BlobKey.BlobType blobType) throws IOException { // Signal type of operation outputStream.write(PUT_OPERATION); if (jobId == null) { outputStream.write(JOB_UNRELATED_CONTENT); } else { outputStream.write(JOB_RELATED_CONTENT); outputStream.write(jobId.getBytes()); } outputStream.write(blobType.ordinal()); }
@Override public int compareTo(BlobKey o) { // compare the hashes first final byte[] aarr = this.key; final byte[] barr = o.key; final int len = Math.min(aarr.length, barr.length); for (int i = 0; i < len; ++i) { final int a = (aarr[i] & 0xff); final int b = (barr[i] & 0xff); if (a != b) { return a - b; } } if (aarr.length == barr.length) { // same hash contents - compare the BLOB types int typeCompare = this.type.compareTo(o.type); if (typeCompare == 0) { // same type - compare random components return this.random.compareTo(o.random); } else { return typeCompare; } } else { return aarr.length - barr.length; } }
@Override public int compareTo(BlobKey o) { // compare the hashes first final byte[] aarr = this.key; final byte[] barr = o.key; final int len = Math.min(aarr.length, barr.length); for (int i = 0; i < len; ++i) { final int a = (aarr[i] & 0xff); final int b = (barr[i] & 0xff); if (a != b) { return a - b; } } if (aarr.length == barr.length) { // same hash contents - compare the BLOB types int typeCompare = this.type.compareTo(o.type); if (typeCompare == 0) { // same type - compare random components return this.random.compareTo(o.random); } else { return typeCompare; } } else { return aarr.length - barr.length; } }
/** * Constructs and writes the header data for a PUT request to the given output stream. * * @param outputStream * the output stream to write the PUT header data to * @param jobId * the ID of job the BLOB belongs to (or <tt>null</tt> if job-unrelated) * @param blobType * whether the BLOB should become permanent or transient * * @throws IOException * thrown if an I/O error occurs while writing the header data to the output stream */ private static void sendPutHeader( OutputStream outputStream, @Nullable JobID jobId, BlobKey.BlobType blobType) throws IOException { // Signal type of operation outputStream.write(PUT_OPERATION); if (jobId == null) { outputStream.write(JOB_UNRELATED_CONTENT); } else { outputStream.write(JOB_RELATED_CONTENT); outputStream.write(jobId.getBytes()); } outputStream.write(blobType.ordinal()); }
/** * Auxiliary method to write this BLOB key to an output stream. * * @param outputStream * the output stream to write the BLOB key to * @throws IOException * thrown if an I/O error occurs while writing the BLOB key */ void writeToOutputStream(final OutputStream outputStream) throws IOException { outputStream.write(this.key); outputStream.write(this.type.ordinal()); outputStream.write(this.random.getBytes()); } }
/** * Auxiliary method to write this BLOB key to an output stream. * * @param outputStream * the output stream to write the BLOB key to * @throws IOException * thrown if an I/O error occurs while writing the BLOB key */ void writeToOutputStream(final OutputStream outputStream) throws IOException { outputStream.write(this.key); outputStream.write(this.type.ordinal()); outputStream.write(this.random.getBytes()); } }
/** * Auxiliary method to write this BLOB key to an output stream. * * @param outputStream * the output stream to write the BLOB key to * @throws IOException * thrown if an I/O error occurs while writing the BLOB key */ void writeToOutputStream(final OutputStream outputStream) throws IOException { outputStream.write(this.key); outputStream.write(this.type.ordinal()); outputStream.write(this.random.getBytes()); } }
@Override public int hashCode() { int result = Arrays.hashCode(this.key); result = 37 * result + this.type.hashCode(); result = 37 * result + this.random.hashCode(); return result; }
@Override public int hashCode() { int result = Arrays.hashCode(this.key); result = 37 * result + this.type.hashCode(); result = 37 * result + this.random.hashCode(); return result; }
@Override public int hashCode() { int result = Arrays.hashCode(this.key); result = 37 * result + this.type.hashCode(); result = 37 * result + this.random.hashCode(); return result; }