Java Code Examples for org.apache.kudu.client.RowResult#getLong()
The following examples show how to use
org.apache.kudu.client.RowResult#getLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeHelper.java From presto-kudu with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: TypeHelper.java From presto with Apache License 2.0 | 5 votes |
public static Object getObject(Type type, RowResult row, int field) { if (row.isNull(field)) { return null; } if (type instanceof VarcharType) { return row.getString(field); } if (type.equals(TimestampType.TIMESTAMP)) { return row.getLong(field) / 1000; } if (type == BigintType.BIGINT) { return row.getLong(field); } if (type == IntegerType.INTEGER) { return row.getInt(field); } if (type == SmallintType.SMALLINT) { return row.getShort(field); } if (type == TinyintType.TINYINT) { return row.getByte(field); } if (type == DoubleType.DOUBLE) { return row.getDouble(field); } if (type == RealType.REAL) { return row.getFloat(field); } if (type == BooleanType.BOOLEAN) { return row.getBoolean(field); } if (type instanceof VarbinaryType) { return Slices.wrappedBuffer(row.getBinary(field)); } if (type instanceof DecimalType) { return row.getDecimal(field); } throw new IllegalStateException("getObject not implemented for " + type); }
Example 3
Source File: TypeHelper.java From presto with Apache License 2.0 | 5 votes |
public static long getLong(Type type, RowResult row, int field) { if (type.equals(TimestampType.TIMESTAMP)) { return row.getLong(field) / 1000; } if (type == BigintType.BIGINT) { return row.getLong(field); } if (type == IntegerType.INTEGER) { return row.getInt(field); } if (type == SmallintType.SMALLINT) { return row.getShort(field); } if (type == TinyintType.TINYINT) { return row.getByte(field); } if (type == RealType.REAL) { return floatToRawIntBits(row.getFloat(field)); } if (type instanceof DecimalType) { DecimalType dtype = (DecimalType) type; if (dtype.isShort()) { return row.getDecimal(field).unscaledValue().longValue(); } throw new IllegalStateException("getLong not supported for long decimal: " + type); } throw new IllegalStateException("getLong not implemented for " + type); }
Example 4
Source File: KuduToBigQuery.java From DataflowTemplates with Apache License 2.0 | 5 votes |
private static Long convertNanoSecondsToMilliSeconds(RowResult input, int colIndex) { if (!input.isNull(colIndex)) { Long timestamp = input.getLong(colIndex) / 1000000; return timestamp; } else { return null; } }
Example 5
Source File: TypeHelper.java From presto-kudu with Apache License 2.0 | 5 votes |
public static Object getObject(Type type, RowResult row, int field) { if (row.isNull(field)) { return null; } else { if (type instanceof VarcharType) { return row.getString(field); } else 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 == DoubleType.DOUBLE) { return row.getDouble(field); } else if (type == RealType.REAL) { return row.getFloat(field); } else if (type == BooleanType.BOOLEAN) { return row.getBoolean(field); } else if (type instanceof VarbinaryType) { return Slices.wrappedBuffer(row.getBinary(field)); } else if (type instanceof DecimalType) { return row.getDecimal(field); } else { throw new IllegalStateException("getObject not implemented for " + type); } } }
Example 6
Source File: KuduInputOperatorCommons.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
public void truncateTable() throws Exception { AbstractKuduPartitionScanner<UnitTestTablePojo,InputOperatorControlTuple> scannerForDeletingRows = unitTestStepwiseScanInputOperator.getScanner(); List<KuduScanToken> scansForAllTablets = unitTestStepwiseScanInputOperator .getPartitioner().getKuduScanTokensForSelectAllColumns(); ApexKuduConnection aCurrentConnection = scannerForDeletingRows.getConnectionPoolForThreads().get(0); KuduSession aSessionForDeletes = aCurrentConnection.getKuduClient().newSession(); KuduTable currentTable = aCurrentConnection.getKuduTable(); for ( KuduScanToken aTabletScanToken : scansForAllTablets) { KuduScanner aScanner = aTabletScanToken.intoScanner(aCurrentConnection.getKuduClient()); while ( aScanner.hasMoreRows()) { RowResultIterator itrForRows = aScanner.nextRows(); while ( itrForRows.hasNext()) { RowResult aRow = itrForRows.next(); int intRowKey = aRow.getInt("introwkey"); String stringRowKey = aRow.getString("stringrowkey"); long timestampRowKey = aRow.getLong("timestamprowkey"); Delete aDeleteOp = currentTable.newDelete(); aDeleteOp.getRow().addInt("introwkey",intRowKey); aDeleteOp.getRow().addString("stringrowkey", stringRowKey); aDeleteOp.getRow().addLong("timestamprowkey",timestampRowKey); aSessionForDeletes.apply(aDeleteOp); } } } aSessionForDeletes.close(); Thread.sleep(2000); // Sleep to allow for scans to complete }