当前位置: 首页>>代码示例>>Java>>正文


Java DoubleBuffer类代码示例

本文整理汇总了Java中java.nio.DoubleBuffer的典型用法代码示例。如果您正苦于以下问题:Java DoubleBuffer类的具体用法?Java DoubleBuffer怎么用?Java DoubleBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DoubleBuffer类属于java.nio包,在下文中一共展示了DoubleBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import java.nio.DoubleBuffer; //导入依赖的package包/类
private void create() throws IOException{
  if( isCreate ){
    return;
  }

  ICompressor compressor = FindCompressor.get( columnBinary.compressorClassName );
  byte[] binary = compressor.decompress( columnBinary.binary , binaryStart , binaryLength );
  ByteBuffer wrapBuffer = ByteBuffer.wrap( binary );
  int nullFlagBinaryLength = wrapBuffer.getInt();
  int doubleBinaryLength = wrapBuffer.getInt();
  int nullFlagBinaryStart = Integer.BYTES * 2;
  int doubleBinaryStart = nullFlagBinaryStart + nullFlagBinaryLength;

  DoubleBuffer doubleBuffer = ByteBuffer.wrap( binary , doubleBinaryStart , doubleBinaryLength ).asDoubleBuffer();

  IDicManager dicManager = new DoubleDicManager( binary , nullFlagBinaryStart , nullFlagBinaryLength , doubleBuffer );
  column = new PrimitiveColumn( columnBinary.columnType , columnBinary.columnName );
  column.setCellManager( new BufferDirectCellManager( ColumnType.DOUBLE , dicManager , nullFlagBinaryLength ) );

  isCreate = true;
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:22,代码来源:DumpDoubleColumnBinaryMaker.java

示例2: clone

import java.nio.DoubleBuffer; //导入依赖的package包/类
/**
 * Creates a clone of the given buffer. The clone's capacity is 
 * equal to the given buffer's limit.
 * 
 * @param buf The buffer to clone
 * @return The cloned buffer
 */
public static Buffer clone(Buffer buf) {
    if (buf instanceof FloatBuffer) {
        return clone((FloatBuffer) buf);
    } else if (buf instanceof ShortBuffer) {
        return clone((ShortBuffer) buf);
    } else if (buf instanceof ByteBuffer) {
        return clone((ByteBuffer) buf);
    } else if (buf instanceof IntBuffer) {
        return clone((IntBuffer) buf);
    } else if (buf instanceof DoubleBuffer) {
        return clone((DoubleBuffer) buf);
    } else {
        throw new UnsupportedOperationException();
    }
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:23,代码来源:BufferUtils.java

示例3: testDoubleGet

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Test(dataProvider = "doubleViewProvider")
public void testDoubleGet(String desc, IntFunction<ByteBuffer> fbb,
                          Function<ByteBuffer, DoubleBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    DoubleBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        double fromBytes = getDoubleFromBytes(bb, o + i * 8);
        double fromMethodView = bb.getDouble(o + i * 8);
        assertValues(i, fromBytes, fromMethodView, bb);

        double fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        double v = getDoubleFromBytes(bb, o + i * 8);
        double a = bb.getDouble();
        assertValues(i, v, a, bb);

        double b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例4: doUpdate

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
  Random rand = new Random(System.currentTimeMillis());

  try {
    rows[0].getLock().writeLock().lock();
    double min = scalars[0];
    double max = scalars[1];
    double factor = max - min;

    DoubleBuffer data = rows[0].getData();
    int size = rows[0].size();
    for (int i = 0; i < size; i++) {
      data.put(i, factor * rand.nextDouble() + min);
    }
  } finally {
    rows[0].getLock().writeLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:20,代码来源:RandomUniform.java

示例5: initializeCrossline

import java.nio.DoubleBuffer; //导入依赖的package包/类
private void initializeCrossline(DrawContext dc) {
	DoubleBuffer verts = crossLine;

	if (verts == null)
		verts = Buffers.newDirectDoubleBuffer(points.size() * 3);

	for (LatLon point : points)
	{
		double alt = 
			elevation + baseHeight * exageration * (yMax - yMin) * crossLinePercent;
		
		Vec4 p1 =
			dc.getGlobe().computePointFromPosition(point.getLatitude(), point.getLongitude(), alt);

		verts.put(p1.x - referenceCenter.x);
		verts.put(p1.y - referenceCenter.y);
		verts.put(p1.z - referenceCenter.z);
	}
	
	this.crossLine = verts;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:22,代码来源:FenceDiagram.java

示例6: readPcRasterMapValues

import java.nio.DoubleBuffer; //导入依赖的package包/类
public static synchronized void readPcRasterMapValues(Jep jep, String variableName, double[] dest) throws JepException {
    String bufferName = "readPcRasterMapValues" + dest.length;
    Map<Integer, DoubleBuffer> map = readPcRasterMapValuesBuffers.get(jep);
    if (map == null) {
        map = new HashMap<Integer, DoubleBuffer>();
        readPcRasterMapValuesBuffers.put(jep, map);
    }
    DoubleBuffer buffer = map.get(dest.length);
    if (buffer == null) {
        buffer = buffers.get(dest.length);
        if (buffer == null) {
            buffer = createNativeDoubleBuffer(dest.length);
            buffers.put(dest.length, buffer);
        }
        declareDoubleArray(jep, bufferName, buffer);
        map.put(dest.length, buffer);
    }
    jep.eval(bufferName + "[:]=reshape(pcr2numpy(" + variableName + ", 1E31), " + dest.length + ')');
    buffer.rewind();
    buffer.get(dest);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:22,代码来源:WflowPythonToJavaAdapter.java

示例7: updateDoubleDenseToDoubleDense

import java.nio.DoubleBuffer; //导入依赖的package包/类
public void updateDoubleDenseToDoubleDense(int size, ByteBuf buf, ServerDenseDoubleRow row,
    int compressRatio) {
  int bitPerItem = 8 * 8 / compressRatio;

  DoubleBuffer data = row.getData();

  LOG.debug("update double to double, size: " + size);

  if (size <= 0)
    return;

  double maxAbs = buf.readDouble();
  int maxPoint = (int) Math.pow(2, bitPerItem - 1) - 1;

  for (int i = 0; i < size - 1; i++) {
    byte[] itemBytes = new byte[bitPerItem / 8];
    buf.readBytes(itemBytes);
    int point = byteArray2int(itemBytes);
    double parsedValue = (double) point / (double) maxPoint * maxAbs;
    data.put(i, data.get(i) + parsedValue);
  }

  LOG.info(String.format("parse compressed %d double data, max abs: %f, max point: %d", size - 1,
      maxAbs, maxPoint));
}
 
开发者ID:Tencent,项目名称:angel,代码行数:26,代码来源:DefaultRowUpdater.java

示例8: byteArray2DoubleArray

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Nullable
private static double[] byteArray2DoubleArray(byte... array) {
    if (array == null) {
        return null;
    }

    final int len = array.length;
    final double[] res = new double[len >> 3];

    try {
        final DoubleBuffer buffer = ByteBuffer.wrap(array).asDoubleBuffer();

        for (int i = 0, iLen = len >> 3; i < iLen; ++i) {
            res[i] = buffer.get();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return res;
}
 
开发者ID:huazhouwang,项目名称:Synapse,代码行数:22,代码来源:DbHelper.java

示例9: toBinary

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
public ColumnBinary toBinary(final ColumnBinaryMakerConfig commonConfig , final ColumnBinaryMakerCustomConfigNode currentConfigNode , final IColumn column ) throws IOException{
  ColumnBinaryMakerConfig currentConfig = commonConfig;
  if( currentConfigNode != null ){
    currentConfig = currentConfigNode.getCurrentConfig();
  }
  byte[] binaryRaw = new byte[ getBinaryLength( column.size() ) ];
  ByteBuffer lengthBuffer = ByteBuffer.wrap( binaryRaw );
  lengthBuffer.putInt( column.size() );
  lengthBuffer.putInt( column.size() * Double.BYTES );

  ByteBuffer nullFlagBuffer = ByteBuffer.wrap( binaryRaw , Integer.BYTES * 2 , column.size() );
  DoubleBuffer doubleBuffer = ByteBuffer.wrap( binaryRaw , ( Integer.BYTES * 2 + column.size() ) , ( column.size() * Double.BYTES ) ).asDoubleBuffer();

  int rowCount = 0;
  for( int i = 0 ; i < column.size() ; i++ ){
    ICell cell = column.get(i);
    if( cell.getType() == ColumnType.NULL ){
      nullFlagBuffer.put( (byte)1 );
      doubleBuffer.put( (double)0 );
    }
    else{
      rowCount++;
      PrimitiveCell byteCell = (PrimitiveCell) cell;
      nullFlagBuffer.put( (byte)0 );
      doubleBuffer.put( byteCell.getRow().getDouble() );
    }
  }

  byte[] binary = currentConfig.compressorClass.compress( binaryRaw , 0 , binaryRaw.length );

  return new ColumnBinary( this.getClass().getName() , currentConfig.compressorClass.getClass().getName() , column.getColumnName() , ColumnType.DOUBLE , rowCount , binaryRaw.length , rowCount * Double.BYTES , -1 , binary , 0 , binary.length , null );
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:34,代码来源:DumpDoubleColumnBinaryMaker.java

示例10: asDoubleBuffer

import java.nio.DoubleBuffer; //导入依赖的package包/类
public DoubleBuffer asDoubleBuffer()
{
	DoubleBuffer buffer = DoubleBuffer.allocate(4*4);

	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			buffer.put(data[i][j]);

	buffer.flip();
	return buffer;
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:12,代码来源:Matrix4d.java

示例11: writeDoubleBuffer

import java.nio.DoubleBuffer; //导入依赖的package包/类
private static void writeDoubleBuffer(DoubleBuffer buf) {
    Buffer viewedBuffer = bufferViews.get(buf);
    if (viewedBuffer != null) {
        bufferEndiannessWritten.put(viewedBuffer, buf.order());
    } else {
        throw new AssertionError();
    }
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:9,代码来源:RT.java

示例12: doProcessRow

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  double qSum = 0;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    qSum += Math.pow(data.get(i), 2);
  }
  return qSum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Nrm2.java

示例13: doProcessRow

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  double sum = 0.0;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    sum += data.get(i);
  }
  return sum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Sum.java

示例14: doProcessRow

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  double min = Double.POSITIVE_INFINITY;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    min = Math.min(min, data.get(i));
  }
  return min;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Min.java

示例15: doProcessRow

import java.nio.DoubleBuffer; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  double max = Double.NEGATIVE_INFINITY;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    max = Math.max(max, data.get(i));
  }
  return max;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Max.java


注:本文中的java.nio.DoubleBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。