public void addValue(T value) { if (value == null) return; byte[] valueBytes = bytesConverter.convertToBytes(value); addValue(valueBytes); }
public void addValue(T value) { addValue(bytesConverter.convertToBytes(value)); }
@Override protected final int getIdFromValueImpl(T value, int roundingFlag) { if (this.valueToIdCache != null && roundingFlag == 0) { Map cache = valueToIdCache.get(); // SoftReference to skip cache gracefully when short of memory if (cache != null) { Integer id; id = (Integer) cache.get(value); if (id != null) return id.intValue(); byte[] valueBytes = bytesConvert.convertToBytes(value); id = getIdFromValueBytesWithoutCache(valueBytes, 0, valueBytes.length, roundingFlag); cache.put(value, id); return id; } } byte[] valueBytes = bytesConvert.convertToBytes(value); return getIdFromValueBytesWithoutCache(valueBytes, 0, valueBytes.length, roundingFlag); }
@Override public int compare(T o1, T o2) { //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2)); byte[] b1 = converter.convertToBytes(o1); byte[] b2 = converter.convertToBytes(o2); ByteArray ba1 = new ByteArray(b1, 0, b1.length); ByteArray ba2 = new ByteArray(b2, 0, b2.length); return ba1.compareTo(ba2); } }
private void initMaxValueForEachTrie() { //init max value this.maxValue = new ArrayList<>(); if (this.trees == null || trees.isEmpty()) { return; } for (int i = 0; i < trees.size(); i++) { T curTreeMax = trees.get(i).getValueFromId(trees.get(i).getMaxId()); byte[] b1 = bytesConvert.convertToBytes(curTreeMax); ByteArray ba1 = new ByteArray(b1, 0, b1.length); this.maxValue.add(ba1); } }
@SuppressWarnings("unchecked") public void addValue(String value) throws IOException { byte[] valueBytes = bytesConverter.convertToBytes(value);
strArray[id] = value; array[id] = converter.convertToBytes(value);
BytesConverter converter = new StringBytesConverter(); for (String str : strList) { byte[] bytes = converter.convertToBytes(str); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); checkMap.put(id, str); byte[] bytes = converter.convertToBytes(str); int id = r.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertNotEquals(String.format(Locale.ROOT, "Value %s not exist", str), -1, id);
for (; checkIndex < firstAppend; checkIndex++) { String str = strList.get(checkIndex); byte[] bytes = converter.convertToBytes(str); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertNotEquals(String.format(Locale.ROOT, "Value %s not exist", str), -1, id); for (; checkIndex < secondAppend; checkIndex++) { String str = strList.get(checkIndex); byte[] bytes = converter.convertToBytes(str); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertNotEquals(String.format(Locale.ROOT, "Value %s not exist", str), -1, id); for (; checkIndex < strList.size(); checkIndex++) { String str = strList.get(checkIndex); byte[] bytes = converter.convertToBytes(str); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertNotEquals(String.format(Locale.ROOT, "Value %s not exist", str), -1, id); byte[] bytes = converter.convertToBytes(s); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertEquals(-1, id); byte[] bytes = converter.convertToBytes(str); int id = dict.getIdFromValueBytesWithoutCache(bytes, 0, bytes.length, 0); assertNotEquals(String.format(Locale.ROOT, "Value %s not exist", str), -1, id);
String str = it.next(); set.add(str); size += converter.convertToBytes(str).length;
public void addValue(T value) { addValue(bytesConverter.convertToBytes(value)); }
@Override final protected int getIdFromValueImpl(T value, int roundingFlag) { if (enableCache && roundingFlag == 0) { HashMap cache = valueToIdCache.get(); // SoftReference to skip cache // gracefully when short of // memory if (cache != null) { Integer id = null; id = (Integer) cache.get(value); if (id != null) return id.intValue(); byte[] valueBytes = bytesConvert.convertToBytes(value); id = getIdFromValueBytes(valueBytes, 0, valueBytes.length, roundingFlag); cache.put(value, id); return id; } } byte[] valueBytes = bytesConvert.convertToBytes(value); return getIdFromValueBytes(valueBytes, 0, valueBytes.length, roundingFlag); }
public void addValue(T value) { if (value == null) return; byte[] valueBytes = bytesConverter.convertToBytes(value); addValue(valueBytes); }
public void addValue(T value) { addValue(bytesConverter.convertToBytes(value)); }
public void addValue(T value) { addValue(bytesConverter.convertToBytes(value)); }
@Override final protected int getIdFromValueImpl(T value, int roundingFlag) { if (enableCache && roundingFlag == 0) { HashMap cache = valueToIdCache.get(); // SoftReference to skip cache gracefully when short of memory if (cache != null) { Integer id = null; id = (Integer) cache.get(value); if (id != null) return id.intValue(); byte[] valueBytes = bytesConvert.convertToBytes(value); id = getIdFromValueBytes(valueBytes, 0, valueBytes.length, roundingFlag); cache.put(value, id); return id; } } byte[] valueBytes = bytesConvert.convertToBytes(value); return getIdFromValueBytes(valueBytes, 0, valueBytes.length, roundingFlag); }
@Override protected final int getIdFromValueImpl(T value, int roundingFlag) { if (this.valueToIdCache != null && roundingFlag == 0) { Map cache = valueToIdCache.get(); // SoftReference to skip cache gracefully when short of memory if (cache != null) { Integer id; id = (Integer) cache.get(value); if (id != null) return id.intValue(); byte[] valueBytes = bytesConvert.convertToBytes(value); id = getIdFromValueBytesWithoutCache(valueBytes, 0, valueBytes.length, roundingFlag); cache.put(value, id); return id; } } byte[] valueBytes = bytesConvert.convertToBytes(value); return getIdFromValueBytesWithoutCache(valueBytes, 0, valueBytes.length, roundingFlag); }
@Override public int compare(T o1, T o2) { //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2)); byte[] b1 = converter.convertToBytes(o1); byte[] b2 = converter.convertToBytes(o2); ByteArray ba1 = new ByteArray(b1, 0, b1.length); ByteArray ba2 = new ByteArray(b2, 0, b2.length); return ba1.compareTo(ba2); } }
private void initMaxValueForEachTrie() { //init max value this.maxValue = new ArrayList<>(); if (this.trees == null || trees.isEmpty()) { return; } for (int i = 0; i < trees.size(); i++) { T curTreeMax = trees.get(i).getValueFromId(trees.get(i).getMaxId()); byte[] b1 = bytesConvert.convertToBytes(curTreeMax); ByteArray ba1 = new ByteArray(b1, 0, b1.length); this.maxValue.add(ba1); } }
@SuppressWarnings("unchecked") public void addValue(String value) throws IOException { byte[] valueBytes = bytesConverter.convertToBytes(value);