List of usage examples for java.lang Integer SIZE
int SIZE
To view the source code for java.lang Integer SIZE.
Click Source Link
From source file:org.apache.sqoop.connector.idf.CSVIntermediateDataFormat.java
/** * {@inheritDoc}/*from ww w .j a va 2 s. c o m*/ */ @Override public Object[] getObjectData() { if (schema.isEmpty()) { throw new SqoopException(IntermediateDataFormatError.INTERMEDIATE_DATA_FORMAT_0006); } String[] fields = getFields(); if (fields == null) { return null; } if (fields.length != schema.getColumns().size()) { throw new SqoopException(IntermediateDataFormatError.INTERMEDIATE_DATA_FORMAT_0005, "The data " + getTextData() + " has the wrong number of fields."); } Object[] out = new Object[fields.length]; Column[] cols = schema.getColumns().toArray(new Column[fields.length]); for (int i = 0; i < fields.length; i++) { Type colType = cols[i].getType(); if (fields[i].equals("NULL")) { out[i] = null; continue; } Long byteSize; switch (colType) { case TEXT: out[i] = unescapeStrings(fields[i]); break; case BINARY: out[i] = unescapeByteArray(fields[i]); break; case FIXED_POINT: byteSize = ((FixedPoint) cols[i]).getByteSize(); if (byteSize != null && byteSize <= Integer.SIZE) { out[i] = Integer.valueOf(fields[i]); } else { out[i] = Long.valueOf(fields[i]); } break; case FLOATING_POINT: byteSize = ((FloatingPoint) cols[i]).getByteSize(); if (byteSize != null && byteSize <= Float.SIZE) { out[i] = Float.valueOf(fields[i]); } else { out[i] = Double.valueOf(fields[i]); } break; case DECIMAL: out[i] = new BigDecimal(fields[i]); break; case DATE: out[i] = LocalDate.parse(fields[i]); break; case DATE_TIME: // A datetime string with a space as date-time separator will not be // parsed expectedly. The expected separator is "T". See also: // https://github.com/JodaOrg/joda-time/issues/11 String iso8601 = fields[i].replace(" ", "T"); out[i] = LocalDateTime.parse(iso8601); break; case BIT: out[i] = Boolean.valueOf(fields[i].equals("1") || fields[i].toLowerCase().equals("true")); break; default: throw new SqoopException(IntermediateDataFormatError.INTERMEDIATE_DATA_FORMAT_0004, "Column type from schema was not recognized for " + colType); } } return out; }
From source file:org.apache.pig.impl.util.avro.AvroTupleWrapper.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private long getMemorySize(final IndexedRecord r) { int total = 0; final int bitsPerByte = 8; for (Field f : r.getSchema().getFields()) { switch (f.schema().getType()) { case BOOLEAN: case ENUM: case INT: total += Integer.SIZE << bitsPerByte; break; case DOUBLE: total += Double.SIZE << bitsPerByte; break; case FLOAT: total += Float.SIZE << bitsPerByte; break; case NULL: break; case STRING: total += ((String) r.get(f.pos())).length() * (Character.SIZE << bitsPerByte); break; case BYTES: total += ((Byte[]) r.get(f.pos())).length; break; case RECORD: total += new AvroTupleWrapper((IndexedRecord) r.get(f.pos())).getMemorySize(); break; case ARRAY: total += new AvroBagWrapper((GenericArray) r.get(f.pos())).getMemorySize(); break; }/*from w w w . j ava 2 s.c o m*/ } return total; }
From source file:odcplot.OdcPlot.java
public OdcPlot() { this.bits = new byte[maxBits]; bitMask = new int[Integer.SIZE]; int v = 1;//from w w w.j a va 2s. co m for (int i = 0; i < bitMask.length; i++) { bitMask[i] = v; v = v << 1; } }
From source file:org.apache.hadoop.util.TestGSet.java
/** * A long running test with various data sets and parameters. * It may take ~5 hours, /*w w w . ja v a 2s . c o m*/ * If you are changing the implementation, * please un-comment the following line in order to run the test. */ //@Test public void runMultipleTestGSet() { for (int offset = -2; offset <= 2; offset++) { runTestGSet(1, offset); for (int i = 1; i < Integer.SIZE - 1; i++) { runTestGSet((1 << i) + 1, offset); } } }
From source file:com.xsdn.main.util.Ip4Network.java
/** * Construct a new instance./*from ww w.j av a 2s . com*/ * * <p> * This constructor specifies 32 as CIDR prefix length. * </p> * * @param addr An integer value which represents an IPv4 address. */ public Ip4Network(int addr) { this(addr, Integer.SIZE); }
From source file:com.delphix.session.impl.frame.SerialNumber.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { serialBits = in.readByte() & 0xff; // Unsigned byte if (serialBits < Byte.SIZE) { serialNumber = in.readByte();/*from w w w . ja v a2 s . c o m*/ } else if (serialBits < Short.SIZE) { serialNumber = in.readShort(); } else if (serialBits < Integer.SIZE) { serialNumber = in.readInt(); } else { serialNumber = in.readLong(); } }
From source file:org.wso2.carbon.analytics.datasource.core.util.GenericUtils.java
private static int calculateBufferSizePerElement(String name, Object value) throws AnalyticsException { int count = 0; /* column name length value + data type (including null) */ count += Integer.SIZE / 8 + 1; /* column name */ count += name.getBytes(StandardCharsets.UTF_8).length; if (value instanceof String) { /* string length + value */ count += Integer.SIZE / 8; count += ((String) value).getBytes(StandardCharsets.UTF_8).length; } else if (value instanceof Long) { count += Long.SIZE / 8;//from w ww. ja v a 2 s .com } else if (value instanceof Double) { count += Double.SIZE / 8; } else if (value instanceof Boolean) { count += Byte.SIZE / 8; } else if (value instanceof Integer) { count += Integer.SIZE / 8; } else if (value instanceof Float) { count += Float.SIZE / 8; } else if (value instanceof byte[]) { count += Integer.SIZE / 8; count += ((byte[]) value).length; } else if (value != null) { count += Integer.SIZE / 8; count += GenericUtils.serializeObject(value).length; } return count; }
From source file:com.delphix.session.impl.frame.SerialNumber.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeByte(serialBits);/*ww w . ja va 2 s.c o m*/ if (serialBits < Byte.SIZE) { out.writeByte((int) serialNumber); } else if (serialBits < Short.SIZE) { out.writeShort((int) serialNumber); } else if (serialBits < Integer.SIZE) { out.writeInt((int) serialNumber); } else { out.writeLong(serialNumber); } }
From source file:com.xsdn.main.util.Ip4Network.java
/** * Construct a new instance.//from w w w. ja v a 2 s. com * * <p> * This constructor specifies 32 as CIDR prefix length. * </p> * * @param bytes A byte array which represents an IPv4 address. * @throws NullPointerException * {@code bytes} is {@code null}. * @throws IllegalArgumentException * The given byte address does not represent an IPv4 address. */ public Ip4Network(byte[] bytes) { this(bytes, Integer.SIZE); }
From source file:de.rwhq.btree.BTree.java
public int getMaxInnerKeys() { final int realSize = rm.getPageSize() - InnerNode.Header.size() - Integer.SIZE / 8; return realSize / (Integer.SIZE / 8 + keySerializer.getSerializedLength()); }