private static ByteBuffer maybeMinimize(ByteBuffer buffer) { // ByteBuffer.minimalBufferFor doesn't handle null, but we can get it in this case since it's possible // for some clustering values to be null return buffer == null ? null : ByteBufferUtil.minimalBufferFor(buffer); }
private static ByteBuffer maybeMinimize(ByteBuffer buffer) { // ByteBuffer.minimalBufferFor doesn't handle null, but we can get it in this case since it's possible // for some clustering values to be null return buffer == null ? null : ByteBufferUtil.minimalBufferFor(buffer); }
private static ByteBuffer maybeMinimize(ByteBuffer buffer) { // ByteBuffer.minimalBufferFor doesn't handle null, but we can get it in this case since it's possible // for some clustering values to be null return buffer == null ? null : ByteBufferUtil.minimalBufferFor(buffer); }
private static ByteBuffer maybeMinimize(ByteBuffer buffer) { // ByteBuffer.minimalBufferFor doesn't handle null, but we can get it in this case since it's possible // for some clustering values to be null return buffer == null ? null : ByteBufferUtil.minimalBufferFor(buffer); }
private static List<ByteBuffer> minimalBuffersFor(List<ByteBuffer> candidates) { List<ByteBuffer> minimalBuffers = new ArrayList<ByteBuffer>(candidates.size()); for (ByteBuffer byteBuffer : candidates) minimalBuffers.add(minimalBufferFor(byteBuffer)); return minimalBuffers; }
public static ColumnIdentifier getInterned(AbstractType<?> type, ByteBuffer bytes, String text) { bytes = ByteBufferUtil.minimalBufferFor(bytes); InternedKey key = new InternedKey(type, bytes); ColumnIdentifier id = internedInstances.get(key); if (id != null) return id; ColumnIdentifier created = new ColumnIdentifier(bytes, text, true); ColumnIdentifier previous = internedInstances.putIfAbsent(key, created); return previous == null ? created : previous; }
public static ColumnIdentifier getInterned(AbstractType<?> type, ByteBuffer bytes, String text) { bytes = ByteBufferUtil.minimalBufferFor(bytes); InternedKey key = new InternedKey(type, bytes); ColumnIdentifier id = internedInstances.get(key); if (id != null) return id; ColumnIdentifier created = new ColumnIdentifier(bytes, text, true); ColumnIdentifier previous = internedInstances.putIfAbsent(key, created); return previous == null ? created : previous; }
public static ColumnIdentifier getInterned(AbstractType<?> type, ByteBuffer bytes, String text) { bytes = ByteBufferUtil.minimalBufferFor(bytes); InternedKey key = new InternedKey(type, bytes); ColumnIdentifier id = internedInstances.get(key); if (id != null) return id; ColumnIdentifier created = new ColumnIdentifier(bytes, text, true); ColumnIdentifier previous = internedInstances.putIfAbsent(key, created); return previous == null ? created : previous; }
/** * Merge 2 lists of min cell name components. * * @param minColumnNames lhs * @param candidates rhs * @param comparator comparator to use * @return a list with smallest column names according to (sub)comparator */ public static List<ByteBuffer> mergeMin(List<ByteBuffer> minColumnNames, List<ByteBuffer> candidates, CellNameType comparator) { if (minColumnNames.isEmpty()) return minimalBuffersFor(candidates); if (candidates.isEmpty()) return minColumnNames; List<ByteBuffer> biggest = minColumnNames.size() > candidates.size() ? minColumnNames : candidates; List<ByteBuffer> smallest = minColumnNames.size() > candidates.size() ? candidates : minColumnNames; // We want to always copy the smallest list, and maybeGrow does it only if it's actually smaller List<ByteBuffer> retList = smallest.size() == biggest.size() ? new ArrayList<>(smallest) : maybeGrow(smallest, biggest.size()); for (int i = 0; i < biggest.size(); i++) retList.set(i, minimalBufferFor(min(retList.get(i), biggest.get(i), comparator.subtype(i)))); return retList; }
/** * Merge 2 lists of max cell name components. * * @param maxColumnNames lhs * @param candidates rhs * @param comparator comparator to use * @return a list with biggest column names according to (sub)comparator */ public static List<ByteBuffer> mergeMax(List<ByteBuffer> maxColumnNames, List<ByteBuffer> candidates, CellNameType comparator) { if (maxColumnNames.isEmpty()) return minimalBuffersFor(candidates); if (candidates.isEmpty()) return maxColumnNames; List<ByteBuffer> biggest = maxColumnNames.size() > candidates.size() ? maxColumnNames : candidates; List<ByteBuffer> smallest = maxColumnNames.size() > candidates.size() ? candidates : maxColumnNames; // We want to always copy the smallest list, and maybeGrow does it only if it's actually smaller List<ByteBuffer> retList = smallest.size() == biggest.size() ? new ArrayList<>(smallest) : maybeGrow(smallest, biggest.size()); for (int i = 0; i < biggest.size(); i++) retList.set(i, minimalBufferFor(max(retList.get(i), biggest.get(i), comparator.subtype(i)))); return retList; }