/** * Initializes this StringValue to a copy the given StringValue. * * @param value The initial value. */ public StringValue(StringValue value) { this.value = EMPTY_STRING; setValue(value); }
@Override public StringValue copy(StringValue from, StringValue reuse) { reuse.setValue(from); return reuse; }
/** * Initializes the StringValue to a sub-string of the given StringValue. * * @param value The string containing the substring. * @param offset The offset of the substring. * @param len The length of the substring. */ public StringValue(StringValue value, int offset, int len) { this.value = EMPTY_STRING; setValue(value, offset, len); }
/** * Initializes the StringValue to a sub-string of the given StringValue. * * @param value The string containing the substring. * @param offset The offset of the substring. * @param len The length of the substring. */ public StringValue(StringValue value, int offset, int len) { this.value = EMPTY_STRING; setValue(value, offset, len); }
@Override public StringValue copy(StringValue from, StringValue reuse) { reuse.setValue(from); return reuse; }
/** * Initializes this StringValue to the value of the given string. * * @param value The string containing the value for this StringValue. */ public StringValue(CharSequence value) { this.value = EMPTY_STRING; setValue(value); }
/** * Initializes this StringValue to the value of the given string. * * @param value The string containing the value for this StringValue. */ public StringValue(CharSequence value) { this.value = EMPTY_STRING; setValue(value); }
/** * Initializes this StringValue to a copy the given StringValue. * * @param value The initial value. */ public StringValue(StringValue value) { this.value = EMPTY_STRING; setValue(value); }
/** * Copies a substring of this string into the given target StringValue. The * substring begins at the given <code>start</code> index and ends at <code>end - 1</code>. * * @param target The StringValue object to copy the substring to. * @param start The beginning index, inclusive. * @param end The ending index, exclusive. * @exception IndexOutOfBoundsException * Thrown, if the start is negative, or the end is larger than the length. */ public void substring(StringValue target, int start, int end) { target.setValue(this, start, end - start); }
/** * Copies a substring of this string into the given target StringValue. The * substring begins at the given <code>start</code> index and ends at <code>end - 1</code>. * * @param target The StringValue object to copy the substring to. * @param start The beginning index, inclusive. * @param end The ending index, exclusive. * @exception IndexOutOfBoundsException * Thrown, if the start is negative, or the end is larger than the length. */ public void substring(StringValue target, int start, int end) { target.setValue(this, start, end - start); }
/** * Sets the value of the StringValue to a substring of the given string. * * @param value The new string value. * @param offset The position to start the substring. * @param len The length of the substring. */ public void setValue(StringValue value, int offset, int len) { Validate.notNull(value); setValue(value.value, offset, len); }
/** * Sets the value of the StringValue to the given string. * * @param value The new string value. */ @Override public void setValue(StringValue value) { Validate.notNull(value); setValue(value.value, 0, value.len); }
/** * Sets the value of the StringValue to the given string. * * @param value The new string value. */ @Override public void setValue(StringValue value) { Validate.notNull(value); setValue(value.value, 0, value.len); }
/** * Sets the value of the StringValue to a substring of the given string. * * @param value The new string value. * @param offset The position to start the substring. * @param len The length of the substring. */ public void setValue(StringValue value, int offset, int len) { Validate.notNull(value); setValue(value.value, offset, len); }
/** * Sets the value of the StringValue to the given string. * * @param value The new string value. */ public void setValue(CharSequence value) { Validate.notNull(value); setValue(value, 0, value.length()); }
/** * Sets the value of the StringValue to the given string. * * @param value The new string value. */ public void setValue(CharSequence value) { Validate.notNull(value); setValue(value, 0, value.length()); }
@Override public Record readRecord(Record reuse, byte[] bytes, int offset, int numBytes) { String theRecord = new String(bytes, offset, numBytes); str1.setValue(theRecord.substring(0, theRecord.indexOf('|'))); str2.setValue(theRecord.substring(theRecord.indexOf('|') + 1)); reuse.setField(0, str1); reuse.setField(1, str2); return reuse; } }
@Override public void combine(Iterator<Record> records, Collector<Record> out) throws Exception { int sum = 0; Record record = new Record(); while (records.hasNext()) { record = records.next(); combineValue = record.getField(1, combineValue); sum += Integer.parseInt(combineValue.toString()); LOG.debug("Processed: [" + record.getField(0, StringValue.class).toString() + "," + combineValue.toString() + "]"); } combineValue.setValue(sum + ""); record.setField(1, combineValue); out.collect(record); }
@Override public void map(Record record, Collector<Record> out) throws Exception { final Tuple t = record.getField(1, this.tuple); this.nationName.setValue(t.getStringValueAt(1)); record.setField(1, this.nationName); out.collect(record); } }
@Override public void join(Record value1, Record value2, Collector<Record> out) throws Exception { keyString = value1.getField(0, keyString); keyString.setValue(""+ (Integer.parseInt(keyString.getValue())+1)); value1.setField(0, keyString); valueString = value1.getField(1, valueString); int val1 = Integer.parseInt(valueString.getValue())+2; valueString = value2.getField(1, valueString); int val2 = Integer.parseInt(valueString.getValue())+1; value1.setField(1, new IntValue(val1 - val2)); out.collect(value1); if (LOG.isDebugEnabled()) LOG.debug("Processed: [" + keyString.toString() + "," + val1 + "] + " + "[" + keyString.toString() + "," + val2 + "]"); }