@Test public void testSegmentSize() { DataAccess da = createDataAccess(name); da.setSegmentSize(20); assertEquals(128, da.getSegmentSize()); da.close(); }
@Override public DataAccess copyTo(DataAccess da) { copyHeader(da); da.ensureCapacity(getCapacity()); long cap = getCapacity(); // currently get/setBytes does not support copying more bytes then segmentSize int segSize = Math.min(da.getSegmentSize(), getSegmentSize()); byte[] bytes = new byte[segSize]; boolean externalIntBased = ((AbstractDataAccess) da).isIntBased(); for (long bytePos = 0; bytePos < cap; bytePos += segSize) { // read if (isIntBased()) { for (int offset = 0; offset < segSize; offset += 4) { bitUtil.fromInt(bytes, getInt(bytePos + offset), offset); } } else { getBytes(bytePos, bytes, segSize); } // write if (externalIntBased) { for (int offset = 0; offset < segSize; offset += 4) { da.setInt(bytePos + offset, bitUtil.toInt(bytes, offset)); } } else { da.setBytes(bytePos, bytes, segSize); } } return da; }
@Test public void testEnsureSize() { Directory dir = new RAMDirectory(); graph = newGHStorage(dir, false).create(defaultSize); int roughEdgeRowLength = 4 * 8; int testIndex = dir.find("edges", DAType.RAM_INT).getSegmentSize() * 3 / roughEdgeRowLength; // we need a big node index to trigger multiple segments, but low enough to avoid OOM graph.edge(0, testIndex, 10, true); // test if optimize works without error graph.optimize(); }
private int fillEmptyIndices(GHBitSet filledIndices) { int len = latSize * lonSize; DataAccess indexCopy = new RAMDirectory().find("temp_index_copy"); indexCopy.setSegmentSize(index.getSegmentSize()).create(index.getCapacity()); GHBitSet indicesCopy = new GHBitSetImpl(len); int initializedCounter = filledIndices.getCardinality();
@Test public void testSet_GetBytes() { DataAccess da = createDataAccess(name); da.create(300); assertEquals(128, da.getSegmentSize()); byte[] bytes = BitUtil.BIG.fromInt(Integer.MAX_VALUE / 3); da.setBytes(8, bytes, bytes.length); bytes = new byte[4]; da.getBytes(8, bytes, bytes.length); assertEquals(Integer.MAX_VALUE / 3, BitUtil.BIG.toInt(bytes)); da.setBytes(127, bytes, bytes.length); da.getBytes(127, bytes, bytes.length); assertEquals(Integer.MAX_VALUE / 3, BitUtil.BIG.toInt(bytes)); da.close(); long bytePos = 4294967296L + 11111; int segmentSizePower = 24; int segmentSizeInBytes = 1 << segmentSizePower; int indexDivisor = segmentSizeInBytes - 1; int bufferIndex = (int) (bytePos >>> segmentSizePower); int index = (int) (bytePos & indexDivisor); assertEquals(256, bufferIndex); assertEquals(11111, index); }
@Override public synchronized int getSegmentSize() { return inner.getSegmentSize(); }
@Override public synchronized int getSegmentSize() { return inner.getSegmentSize(); }
@Override public DataAccess copyTo(DataAccess da) { copyHeader(da); da.ensureCapacity(getCapacity()); long cap = getCapacity(); // currently get/setBytes does not support copying more bytes then segmentSize int segSize = Math.min(da.getSegmentSize(), getSegmentSize()); byte[] bytes = new byte[segSize]; boolean externalIntBased = ((AbstractDataAccess) da).isIntBased(); for (long bytePos = 0; bytePos < cap; bytePos += segSize) { // read if (isIntBased()) { for (int offset = 0; offset < segSize; offset += 4) { bitUtil.fromInt(bytes, getInt(bytePos + offset), offset); } } else { getBytes(bytePos, bytes, segSize); } // write if (externalIntBased) { for (int offset = 0; offset < segSize; offset += 4) { da.setInt(bytePos + offset, bitUtil.toInt(bytes, offset)); } } else { da.setBytes(bytePos, bytes, segSize); } } return da; }
@Override public DataAccess copyTo(DataAccess da) { copyHeader(da); da.ensureCapacity(getCapacity()); long cap = getCapacity(); // currently get/setBytes does not support copying more bytes then segmentSize int segSize = Math.min(da.getSegmentSize(), getSegmentSize()); byte[] bytes = new byte[segSize]; boolean externalIntBased = ((AbstractDataAccess) da).isIntBased(); for (long bytePos = 0; bytePos < cap; bytePos += segSize) { // read if (isIntBased()) { for (int offset = 0; offset < segSize; offset += 4) { bitUtil.fromInt(bytes, getInt(bytePos + offset), offset); } } else { getBytes(bytePos, bytes, segSize); } // write if (externalIntBased) { for (int offset = 0; offset < segSize; offset += 4) { da.setInt(bytePos + offset, bitUtil.toInt(bytes, offset)); } } else { da.setBytes(bytePos, bytes, segSize); } } return da; }
long cap = getCapacity(); int segSize = Math.min(da.getSegmentSize(), getSegmentSize()); byte[] bytes = new byte[segSize]; boolean externalIntBased = ((AbstractDataAccess) da).isIntBased();
private int fillEmptyIndices(GHBitSet filledIndices) { int len = latSize * lonSize; DataAccess indexCopy = new RAMDirectory().find("temp_index_copy"); indexCopy.setSegmentSize(index.getSegmentSize()).create(index.getCapacity()); GHBitSet indicesCopy = new GHBitSetImpl(len); int initializedCounter = filledIndices.getCardinality();
private int fillEmptyIndices(GHBitSet filledIndices) { int len = latSize * lonSize; DataAccess indexCopy = new RAMDirectory().find("temp_index_copy"); indexCopy.setSegmentSize(index.getSegmentSize()).create(index.getCapacity()); GHBitSet indicesCopy = new GHBitSetImpl(len); int initializedCounter = filledIndices.getCardinality();
indexCopy.setSegmentSize(index.getSegmentSize()).create(index.getCapacity()); GHBitSet indicesCopy = new GHBitSetImpl(len); int initializedCounter = filledIndices.getCardinality();