/** * Returns the subnetwork ID for the specified nodeId or 0 if non is associated e.g. because the * subnetwork is too small. */ public int getSubnetwork(int nodeId) { byte[] bytes = new byte[1]; da.getBytes(nodeId, bytes, bytes.length); return (int) bytes[0]; }
public String get(long pointer) { if (pointer < 0) throw new IllegalStateException("Pointer to access NameIndex cannot be negative:" + pointer); // default if (pointer == 0) return ""; byte[] sizeBytes = new byte[1]; names.getBytes(pointer, sizeBytes, 1); int size = sizeBytes[0] & 0xFF; byte[] bytes = new byte[size]; names.getBytes(pointer + sizeBytes.length, bytes, size); return new String(bytes, Helper.UTF_CS); }
static long binarySearch(DataAccess da, long start, long len, long key) { long high = start + len, low = start - 1, guess; byte[] longBytes = new byte[8]; while (high - low > 1) { // use >>> for average or we could get an integer overflow. guess = (high + low) >>> 1; long tmp = guess << 3; da.getBytes(tmp, longBytes, 8); long guessedKey = bitUtil.toLong(longBytes); if (guessedKey < key) low = guess; else high = guess; } if (high == start + len) return ~(start + len); long tmp = high << 3; da.getBytes(tmp, longBytes, 8); long highKey = bitUtil.toLong(longBytes); if (highKey == key) return high; else return ~high; }
@Override public synchronized boolean loadExisting() { if (!da.loadExisting()) return false; int len = (int) da.getCapacity(); byte[] bytes = new byte[len]; da.getBytes(0, bytes, len); try { loadProperties(map, new StringReader(new String(bytes, UTF_CS))); return true; } catch (IOException ex) { throw new IllegalStateException(ex); } }
@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); }
wayGeometry.getBytes(geoRef, bytes, bytes.length); } else if (mode == 0) return PointList.EMPTY;
@Override public synchronized void getBytes( long bytePos, byte[] values, int length ) { inner.getBytes(bytePos, values, length); }
/** * Returns the subnetwork ID for the specified nodeId or 0 if non is associated e.g. because the * subnetwork is too small. */ public int getSubnetwork(int nodeId) { byte[] bytes = new byte[1]; da.getBytes(nodeId, bytes, bytes.length); return (int) bytes[0]; }
@Override public synchronized void getBytes(long bytePos, byte[] values, int length) { inner.getBytes(bytePos, values, length); }
/** * Returns the subnetwork ID for the specified nodeId or 0 if non is associated e.g. because the * subnetwork is too small. */ public int getSubnetwork(int nodeId) { byte[] bytes = new byte[1]; da.getBytes(nodeId, bytes, bytes.length); return (int) bytes[0]; }
public String get(long pointer) { if (pointer < 0) throw new IllegalStateException("Pointer to access NameIndex cannot be negative:" + pointer); // default if (pointer == 0) return ""; byte[] sizeBytes = new byte[1]; names.getBytes(pointer, sizeBytes, 1); int size = sizeBytes[0] & 0xFF; byte[] bytes = new byte[size]; names.getBytes(pointer + sizeBytes.length, bytes, size); return new String(bytes, Helper.UTF_CS); }
public String get(long pointer) { if (pointer < 0) throw new IllegalStateException("Pointer to access NameIndex cannot be negative:" + pointer); // default if (pointer == 0) return ""; byte[] sizeBytes = new byte[1]; names.getBytes(pointer, sizeBytes, 1); int size = sizeBytes[0] & 0xFF; byte[] bytes = new byte[size]; names.getBytes(pointer + sizeBytes.length, bytes, size); return new String(bytes, Helper.UTF_CS); }
public String get( long pointer ) { if (pointer < 0) throw new IllegalStateException("Pointer to access NameIndex cannot be negative:" + pointer); // default if (pointer == 0) return ""; byte[] sizeBytes = new byte[1]; names.getBytes(pointer, sizeBytes, 1); int size = sizeBytes[0] & 0xFF; byte[] bytes = new byte[size]; names.getBytes(pointer + sizeBytes.length, bytes, size); return new String(bytes, Helper.UTF_CS); }
static long binarySearch(DataAccess da, long start, long len, long key) { long high = start + len, low = start - 1, guess; byte[] longBytes = new byte[8]; while (high - low > 1) { // use >>> for average or we could get an integer overflow. guess = (high + low) >>> 1; long tmp = guess << 3; da.getBytes(tmp, longBytes, 8); long guessedKey = bitUtil.toLong(longBytes); if (guessedKey < key) low = guess; else high = guess; } if (high == start + len) return ~(start + len); long tmp = high << 3; da.getBytes(tmp, longBytes, 8); long highKey = bitUtil.toLong(longBytes); if (highKey == key) return high; else return ~high; }
static long binarySearch( DataAccess da, long start, long len, long key ) { long high = start + len, low = start - 1, guess; byte[] longBytes = new byte[8]; while (high - low > 1) { // use >>> for average or we could get an integer overflow. guess = (high + low) >>> 1; long tmp = guess << 3; da.getBytes(tmp, longBytes, 8); long guessedKey = bitUtil.toLong(longBytes); if (guessedKey < key) low = guess; else high = guess; } if (high == start + len) return ~(start + len); long tmp = high << 3; da.getBytes(tmp, longBytes, 8); long highKey = bitUtil.toLong(longBytes); if (highKey == key) return high; else return ~high; }
static long binarySearch(DataAccess da, long start, long len, long key) { long high = start + len, low = start - 1, guess; byte[] longBytes = new byte[8]; while (high - low > 1) { // use >>> for average or we could get an integer overflow. guess = (high + low) >>> 1; long tmp = guess << 3; da.getBytes(tmp, longBytes, 8); long guessedKey = bitUtil.toLong(longBytes); if (guessedKey < key) low = guess; else high = guess; } if (high == start + len) return ~(start + len); long tmp = high << 3; da.getBytes(tmp, longBytes, 8); long highKey = bitUtil.toLong(longBytes); if (highKey == key) return high; else return ~high; }
@Override public synchronized boolean loadExisting() { if (!da.loadExisting()) return false; int len = (int) da.getCapacity(); byte[] bytes = new byte[len]; da.getBytes(0, bytes, len); try { loadProperties(map, new StringReader(new String(bytes, UTF_CS))); return true; } catch (IOException ex) { throw new IllegalStateException(ex); } }
@Override public synchronized boolean loadExisting() { if (!da.loadExisting()) return false; int len = (int) da.getCapacity(); byte[] bytes = new byte[len]; da.getBytes(0, bytes, len); try { Helper.loadProperties(map, new StringReader(new String(bytes, Helper.UTF_CS))); return true; } catch (IOException ex) { throw new IllegalStateException(ex); } }
@Override public boolean loadExisting() { if (!da.loadExisting()) return false; int len = (int) da.getCapacity(); byte[] bytes = new byte[len]; da.getBytes(0, bytes, len); try { Helper.loadProperties(map, new StringReader(new String(bytes, Helper.UTF_CS))); return true; } catch (IOException ex) { throw new IllegalStateException(ex); } }
wayGeometry.getBytes(geoRef, bytes, bytes.length); } else if (mode == 0) return PointList.EMPTY;