case INT64: case UNIXTIME_MICROS: to.addLong(i, from.getLong(i)); break; case INT32:
if (pci.kuduColumn.isNullable()) { ((NullableBigIntVector.Mutator) pci.vv.getMutator()) .setSafe(rowIndex, result.getLong(pci.index)); } else { ((BigIntVector.Mutator) pci.vv.getMutator()) .setSafe(rowIndex, result.getLong(pci.index)); if (pci.kuduColumn.isNullable()) { ((NullableTimeStampVector.Mutator) pci.vv.getMutator()) .setSafe(rowIndex, result.getLong(pci.index) / 1000); } else { ((TimeStampVector.Mutator) pci.vv.getMutator()) .setSafe(rowIndex, result.getLong(pci.index) / 1000);
return result.getInt(jpaColumnName); case INT64: return result.getLong(jpaColumnName); case INT8: return result.getByte(jpaColumnName);
/** * Get the specified column's long * * If this is a UNIXTIME_MICROS column, the long value corresponds to a number of microseconds * since midnight, January 1, 1970 UTC. * * @param columnName name of the column to get data for * @return a positive long * @throws IllegalArgumentException if the column doesn't exist or is null */ public long getLong(String columnName) { return getLong(this.schema.getColumnIndex(columnName)); }
@Override protected void map(NullWritable key, RowResult value, Mapper.Context context) throws IOException, InterruptedException { // Add as many heads as we need, then we skip the rest. do { if (headsCache.size() < numUpdatesPerMapper) { value = (RowResult)context.getCurrentValue(); headsCache.add(new Pair<Long, Long>(value.getLong(0), value.getLong(1))); } } while (context.nextKeyValue()); // At this point we've exhausted the scanner and hopefully gathered all the linked list // heads we needed. LOG.info("Processing " + headsCache.size() + " linked lists, out of " + numUpdatesPerMapper); processAllHeads(context); }
private static CINode getCINode(RowResult result, CINode node) { node.key = getStringFromKeys(result.getLong(0), result.getLong(1)); if (result.isNull(2) || result.isNull(3)) { node.prev = "NO_REFERENCE"; } else { node.prev = getStringFromKeys(result.getLong(2), result.getLong(3)); } node.rowId = result.getInt(4); node.client = result.getString(5); node.updateCount = result.getInt(6); return node; }
@Override protected void map(NullWritable key, RowResult value, Mapper.Context context) throws IOException, InterruptedException { Bytes.setLong(rowKey, value.getLong(0)); Bytes.setLong(rowKey, value.getLong(1), 8); row.set(rowKey, 0, rowKey.length); // Emit that the row is defined context.write(row, DEF); if (value.isNull(2)) { LOG.warn(String.format("Prev is not set for: %s", Bytes.pretty(rowKey))); } else { Bytes.setLong(prev, value.getLong(2)); Bytes.setLong(prev, value.getLong(3), 8); ref.set(prev, 0, prev.length); // Emit which row is referenced by this row. context.write(ref, row); } } }
public static long getLong(Type type, RowResult row, int field) { if (type == TimestampType.TIMESTAMP) { return row.getLong(field) / 1000; } else if (type == BigintType.BIGINT) { return row.getLong(field); } else if (type == IntegerType.INTEGER) { return row.getInt(field); } else if (type == SmallintType.SMALLINT) { return row.getShort(field); } else if (type == TinyintType.TINYINT) { return row.getByte(field); } else if (type == RealType.REAL) { return floatToRawIntBits(row.getFloat(field)); } else if (type instanceof DecimalType) { DecimalType dtype = (DecimalType) type; if (dtype.isShort()) { return row.getDecimal(field).unscaledValue().longValue(); } else { throw new IllegalStateException("getLong not supported for long decimal: " + type); } } else { throw new IllegalStateException("getLong not implemented for " + type); } }
private void walk(long headKeyOne, long headKeyTwo, int maxNumNodes) throws KuduException { CommandLineParser parser = new CommandLineParser(getConf()); client = parser.getClient(); table = client.openTable(getTableName(getConf())); long prevKeyOne = headKeyOne; long prevKeyTwo = headKeyTwo; CINode node = new CINode(); int nodesCount = 0; do { RowResult rr = nextNode(prevKeyOne, prevKeyTwo); if (rr == null) { System.err.println(getStringFromKeys(prevKeyOne, prevKeyTwo) + " doesn't exist!"); break; } getCINode(rr, node); printCINodeString(node); if (rr.isNull(2) || rr.isNull(3)) { System.err.println("Last node didn't have a reference, breaking"); break; } prevKeyOne = rr.getLong(2); prevKeyTwo = rr.getLong(3); nodesCount++; } while ((headKeyOne != prevKeyOne && headKeyTwo != prevKeyTwo) && (nodesCount < maxNumNodes)); }
/** * Get a copy of the specified column's binary data. * @param columnIndex Column index in the schema * @return a byte[] with the binary data. * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public byte[] getBinaryCopy(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); // C++ puts a Slice in rowData which is 16 bytes long for simplicity, // but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; byte[] ret = new byte[(int)length]; System.arraycopy(indirectData.getRawArray(), indirectData.getRawOffset() + (int) offset, ret, 0, (int) length); return ret; }
/** * Get the specified column's binary data. * * This doesn't copy the data and instead returns a ByteBuffer that wraps it. * * @param columnIndex Column index in the schema * @return a ByteBuffer with the binary data. * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public ByteBuffer getBinary(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.BINARY); // C++ puts a Slice in rowData which is 16 bytes long for simplicity, // but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; return ByteBuffer.wrap(indirectData.getRawArray(), indirectData.getRawOffset() + (int) offset, (int) length); }
/** * Get the specified column's string. * @param columnIndex Column index in the schema * @return a string * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public String getString(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.STRING); // C++ puts a Slice in rowData which is 16 bytes long for simplity, but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; return Bytes.getString(indirectData.getRawArray(), indirectData.getRawOffset() + (int)offset, (int)length); }
case INT64: case UNIXTIME_MICROS: values.setField(i, name, row.getLong(i)); break; default:
case INT64: case UNIXTIME_MICROS: to.addLong(i, from.getLong(i)); break; case INT32: