public byte[] toBytes() { if (words == null) { return new byte[]{}; } ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Integer.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
boolean needConversion(int index) { IntBuffer readOnly = conversions[index].asReadOnlyBuffer(); readOnly.rewind(); int i = 0; while (readOnly.hasRemaining()) { if (i != readOnly.get()) { return true; } i++; } return false; }
protected IndexSeeker[] toIndexSeekers( List<IndexableAdapter> adapters, ArrayList<IntBuffer> dimConversions, String dimension ) { IndexSeeker[] seekers = new IndexSeeker[adapters.size()]; for (int i = 0; i < adapters.size(); i++) { IntBuffer dimConversion = dimConversions.get(i); if (dimConversion != null) { seekers[i] = new IndexSeekerWithConversion((IntBuffer) dimConversion.asReadOnlyBuffer().rewind()); } else { try (CloseableIndexed<String> dimValueLookup = adapters.get(i).getDimValueLookup(dimension)) { seekers[i] = new IndexSeekerWithoutConversion(dimValueLookup == null ? 0 : dimValueLookup.size()); } catch (IOException e) { throw new UncheckedIOException(e); } } } return seekers; }
/** * Return the value at the given indexes, without checking bounds * * @param rowIndex an int row index * @param columnIndex an int column index * @return the double at the index */ @Override public double getQuick(int rowIndex, int columnIndex) { IntBuffer tmp = data.get(bufferIndex[rowIndex]).asReadOnlyBuffer(); tmp.position(rowOffset[rowIndex]); tmp.limit(rowSize[rowIndex]); tmp = tmp.slice(); return searchForIndex(tmp, columnIndex); }
/** * Returns a view of a row. Changes to the view will affect the original. * * @param rowIndex Which row to return. * @return A vector that references the desired row. */ @Override public Vector viewRow(int rowIndex) { IntBuffer tmp = data.get(bufferIndex[rowIndex]).asReadOnlyBuffer(); tmp.position(rowOffset[rowIndex]); tmp.limit(rowOffset[rowIndex] + rowSize[rowIndex]); tmp = tmp.slice(); return new SparseBinaryVector(tmp, columnSize()); }
result = ((ShortBuffer)data).asReadOnlyBuffer(); } else if( data instanceof IntBuffer ) { result = ((IntBuffer)data).asReadOnlyBuffer(); } else { throw new UnsupportedOperationException( "Cannot get read-only view of buffer type:" + data );
@Test public void testDictIdSeeker() { IntBuffer dimConversions = ByteBuffer.allocateDirect(3 * Integer.BYTES).asIntBuffer(); dimConversions.put(0); dimConversions.put(2); dimConversions.put(4); IndexMerger.IndexSeeker dictIdSeeker = new IndexMerger.IndexSeekerWithConversion( (IntBuffer) dimConversions.asReadOnlyBuffer().rewind() ); Assert.assertEquals(0, dictIdSeeker.seek(0)); Assert.assertEquals(-1, dictIdSeeker.seek(1)); Assert.assertEquals(1, dictIdSeeker.seek(2)); try { dictIdSeeker.seek(5); Assert.fail("Only support access in order"); } catch (ISE ise) { Assert.assertTrue("Only support access in order", true); } Assert.assertEquals(-1, dictIdSeeker.seek(3)); Assert.assertEquals(2, dictIdSeeker.seek(4)); Assert.assertEquals(-1, dictIdSeeker.seek(5)); }
public int compareTo(ImmutableConciseSet other) { return words.asReadOnlyBuffer().compareTo(other.words.asReadOnlyBuffer()); }
/** * @return the buffer chars as a read-only int buffer */ public IntBuffer getBuffer() { return IntBuffer.wrap(pending).asReadOnlyBuffer(); }
public byte[] toBytes() { ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Ints.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
public byte[] toBytes() { if (words == null) { return new byte[]{}; } ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Ints.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
/** * @return the buffer chars as a read-only int buffer */ public IntBuffer getBuffer() { return IntBuffer.wrap(pending).asReadOnlyBuffer(); }
/** * Creates a new window which will store the sample values in the given {@code data} array. */ IntWindow(final int[] data, final int[] transfer) { super(IntBuffer.wrap(data).asReadOnlyBuffer()); this.data = data; this.transfer = transfer; }
public byte[] toBytes() { if (words == null) { return new byte[]{}; } ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Ints.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
public byte[] toBytes() { if (words == null) { return new byte[]{}; } ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Integer.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
public IntBuffer getBaseList(int index) { final int[] array = baseLists.get(index); if (array == null) { return null; } final IntBuffer retVal = IntBuffer.wrap(array); if (index + 1 == baseListCount()) { retVal.limit(maxIndex - (index * ALLOCATION_SIZE)); } return retVal.asReadOnlyBuffer(); }
public IntBuffer getBaseList(int index) { final int[] array = baseLists.get(index); if (array == null) { return null; } final IntBuffer retVal = IntBuffer.wrap(array); if (index + 1 == baseListCount()) { retVal.limit(maxIndex - (index * ALLOCATION_SIZE)); } return retVal.asReadOnlyBuffer(); }
public IntBuffer getBaseList(int index) { final int[] array = baseLists.get(index); if (array == null) { return null; } final IntBuffer retVal = IntBuffer.wrap(array); if (index + 1 == baseListCount()) { retVal.limit(maxIndex - (index * allocateSize)); } return retVal.asReadOnlyBuffer(); }
public IntBuffer getBaseList(int index) { final int[] array = baseLists.get(index); if (array == null) { return null; } final IntBuffer retVal = IntBuffer.wrap(array); if (index + 1 == baseListCount()) { retVal.limit(maxIndex - (index * allocateSize)); } return retVal.asReadOnlyBuffer(); }
public IntBuffer getConversionBuffer() { if (currIndex != conversionBuf.limit() || conversionBuf.hasRemaining()) { throw new ISE( "Asked for incomplete buffer. currIndex[%,d] != buf.limit[%,d]", currIndex, conversionBuf.limit() ); } return (IntBuffer) conversionBuf.asReadOnlyBuffer().rewind(); } }