for (int d = 0; d < dim; d++) { Key<?> val = InstantiationUtil.instantiate(types[d], Key.class); val.read(in); bucket[d] = val;
@Override public void write(DataOutput out) throws IOException { out.writeInt(this.dim); out.writeInt(boundaries.length); // write types for (int i = 0; i < dim; i++) { out.writeUTF(boundaries[0][i].getClass().getName()); } for (int i = 0; i < boundaries.length; i++) { for (int d = 0; d < dim; d++) { boundaries[i][d].write(out); } } }
@Override public int compareToReference(TypeComparator<Record> referencedAccessors) { final RecordComparator pra = (RecordComparator) referencedAccessors; for (int i = 0; i < this.keyFields.length; i++) { @SuppressWarnings("unchecked") final int comp = pra.keyHolders[i].compareTo(this.keyHolders[i]); if (comp != 0) { return this.ascending[i] ? comp : -comp; } } return 0; }
@Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields.length; i++) { final Key<?> k = candidate.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields[i]); } else if (!k.equals(this.keyHolders[i])) { return false; } } return true; }
@Override public int hash(Record object) { int i = 0; try { int code = 0; for (; i < this.keyFields.length; i++) { code ^= object.getField(this.keyFields[i], this.transientKeyHolders[i]).hashCode(); code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component } return code; } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyFields[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(this.keyFields[i]); } }
for (int d = 0; d < dim; d++) { Key<?> val = InstantiationUtil.instantiate(types[d], Key.class); val.read(in); bucket[d] = val;
@Override public void write(DataOutput out) throws IOException { out.writeInt(this.dim); out.writeInt(boundaries.length); // write types for (int i = 0; i < dim; i++) { out.writeUTF(boundaries[0][i].getClass().getName()); } for (int i = 0; i < boundaries.length; i++) { for (int d = 0; d < dim; d++) { boundaries[i][d].write(out); } } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compareToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Key k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else { final int comp = k.compareTo(this.keyHolders1[i]); if (comp != 0) { return comp; } } } return 0; } }
@SuppressWarnings("rawtypes") @Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Key k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else if (!k.equals(this.keyHolders1[i])) { return false; } } return true; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compare(Record first, Record second) { int i = 0; try { for (; i < this.keyFields.length; i++) { Key k1 = first.getField(this.keyFields[i], this.keyHolders[i]); Key k2 = second.getField(this.keyFields[i], this.transientKeyHolders[i]); int cmp = k1.compareTo(k2); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException e) { throw new NullKeyFieldException(this.keyFields[i]); } }