public void writeDouble(double d) throws IOException { writeFixed64(Double.doubleToRawLongBits(d)); }
private void writeHeader(OutputStream out) throws IOException { OutputBuffer header = new OutputBuffer(); header.write(MAGIC); // magic header.writeFixed64(rowCount); // row count header.writeFixed32(columnCount); // column count metaData.write(header); // file metadata for (ColumnOutputBuffer column : columns) column.getMeta().write(header); // column metadata for (long start : computeStarts(header.size())) header.writeFixed64(start); // column starts header.writeTo(out); }
@Test public void testFixed64() throws Exception { Random random = TestUtil.createRandom(); OutputBuffer out = new OutputBuffer(); for (int i = 0; i < COUNT; i++) out.writeFixed64(random.nextLong()); InputBuffer in = new InputBuffer(new InputBytes(out.toByteArray())); random = TestUtil.createRandom(); for (int i = 0; i < COUNT; i++) Assert.assertEquals(random.nextLong(), in.readFixed64()); }
writeFixed32((Integer)value); break; case FIXED64: writeFixed64((Long)value); break; case FLOAT: writeFloat((Float)value); break;
public void writeDouble(double d) throws IOException { writeFixed64(Double.doubleToRawLongBits(d)); }
private void writeHeader(OutputStream out) throws IOException { OutputBuffer header = new OutputBuffer(); header.write(MAGIC); // magic header.writeFixed64(rowCount); // row count header.writeFixed32(columnCount); // column count metaData.write(header); // file metadata for (ColumnOutputBuffer column : columns) column.getMeta().write(header); // column metadata for (long start : computeStarts(header.size())) header.writeFixed64(start); // column starts header.writeTo(out); }
@Test public void testFixed64() throws Exception { Random random = TestUtil.createRandom(); OutputBuffer out = new OutputBuffer(); for (int i = 0; i < COUNT; i++) out.writeFixed64(random.nextLong()); InputBuffer in = new InputBuffer(new InputBytes(out.toByteArray())); random = TestUtil.createRandom(); for (int i = 0; i < COUNT; i++) Assert.assertEquals(random.nextLong(), in.readFixed64()); }
public void writeValue(Object value, ValueType type) throws IOException { switch (type) { case NULL: break; case INT: writeInt((Integer)value); break; case LONG: writeLong((Long)value); break; case FIXED32: writeFixed32((Integer)value); break; case FIXED64: writeFixed64((Long)value); break; case FLOAT: writeFloat((Float)value); break; case DOUBLE: writeDouble((Double)value); break; case STRING: writeString((String)value); break; case BYTES: if (value instanceof ByteBuffer) writeBytes((ByteBuffer)value); else writeBytes((byte[])value); break; default: throw new TrevniRuntimeException("Unknown value type: "+type); } }