List<Dimension> dimensions,
int dimensionIndex,
int keyOffset,
TupleFactory tf) throws ExecException {
Dimension d = dimensions.get(dimensionIndex);
Object member= input.get(dimensionIndex+1);
// resolve pig byte arrays to java arrays
if ( member instanceof DataByteArray )
member = ((DataByteArray)member).get();
if (d instanceof Hierarchy) {
Hierarchy h = (Hierarchy) d;
int depth = h.getDepth();
for (int i = 0; i < depth; i++) {
h.getKey(member, i, keyHolder, keyOffset);
if (dimensions.size() == dimensionIndex + 1) {
holder.add(tf.newTuple(tf.newTuple(new DataByteArray(keyHolder))));
keyHolder = keyHolder.clone();
} else
walkDimensions(input,
holder,
keyHolder,
dimensions,
dimensionIndex + 1,
keyOffset + d.getKeyLen(),
tf);
}
} else {
// non-hierarchy
d.getKey(member, keyHolder, keyOffset);
if (dimensions.size() == dimensionIndex + 1) {
holder.add(tf.newTuple(tf.newTuple(new DataByteArray(keyHolder))));
keyHolder = keyHolder.clone();
} else
walkDimensions(input, holder, keyHolder, dimensions, dimensionIndex + 1, keyOffset + d.getKeyLen(), tf);
}
}