當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。