@Override public boolean apply(@Nullable KeySlice row) { return (row != null) && row.getColumns().size() > 0; } }
@Override public RecordIterator<Entry> getEntries() { ensureOpen(); return new RecordIterator<Entry>() { final Iterator<Entry> columns = CassandraHelper.makeEntryIterator(mostRecentRow.getColumns(), entryGetter, columnSlice.getSliceEnd(), columnSlice.getLimit()); @Override public boolean hasNext() { ensureOpen(); return columns.hasNext(); } @Override public Entry next() { ensureOpen(); return columns.next(); } @Override public void close() { closeIterator(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
static Map<ByteBuffer, List<ColumnOrSuperColumn>> getColsByKey(List<KeySlice> firstPage) { Map<ByteBuffer, List<ColumnOrSuperColumn>> ret = Maps.newHashMapWithExpectedSize(firstPage.size()); for (KeySlice e : firstPage) { ret.put(ByteBuffer.wrap(e.getKey()), e.getColumns()); } return ret; } }
/** * Transform thrift result. * * @param <T> the generic type * @param columnFamilyType the column family type * @param keySlices the key slices * @param row the row * @return the map */ public static <T> Map<ByteBuffer, List<T>> transformThriftResult(ColumnFamilyType columnFamilyType, List<KeySlice> keySlices, ThriftRow row) { Map<ByteBuffer, List<T>> output = new HashMap<ByteBuffer, List<T>>(); for (KeySlice keySlice : keySlices) { output.put(ByteBuffer.wrap(keySlice.getKey()), (List<T>) transformThriftResult(keySlice.getColumns(), columnFamilyType, row)); } return output; }
@Override public Map<ByteBuffer, List<CounterColumn>> execute(Cassandra.Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_range_slices(columnParent, predicate, keyRange, getThriftCl(OperationType.READ)); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<CounterColumn>>(0); } LinkedHashMap<ByteBuffer, List<CounterColumn>> ret = new LinkedHashMap<ByteBuffer, List<CounterColumn>>( keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), getCounterColumnList(keySlice.getColumns())); } return ret; } catch (Exception e) { throw xtrans.translate(e); } }; };
@Override public Map<ByteBuffer, List<CounterSuperColumn>> execute(Cassandra.Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_range_slices(columnParent, predicate, keyRange, getThriftCl(OperationType.READ)); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<CounterSuperColumn>>(); } LinkedHashMap<ByteBuffer, List<CounterSuperColumn>> ret = new LinkedHashMap<ByteBuffer, List<CounterSuperColumn>>( keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), getCounterSuperColumnList(keySlice.getColumns())); } return ret; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Map<ByteBuffer, List<Column>> execute(Cassandra.Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_range_slices(columnParent, predicate, keyRange, getThriftCl(OperationType.READ)); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<Column>>(0); } LinkedHashMap<ByteBuffer, List<Column>> ret = new LinkedHashMap<ByteBuffer, List<Column>>( keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), getColumnList(keySlice.getColumns())); } return ret; } catch (Exception e) { throw xtrans.translate(e); } }; };
@Override public Map<ByteBuffer, List<SuperColumn>> execute(Cassandra.Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_range_slices(columnParent, predicate, keyRange, getThriftCl(OperationType.READ)); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<SuperColumn>>(); } LinkedHashMap<ByteBuffer, List<SuperColumn>> ret = new LinkedHashMap<ByteBuffer, List<SuperColumn>>( keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), getSuperColumnList(keySlice.getColumns())); } return ret; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Map<ByteBuffer, List<Column>> execute(Cassandra.Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_indexed_slices(columnParent, indexClause, predicate, getThriftCl(OperationType.READ)); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<Column>>(0); } LinkedHashMap<ByteBuffer, List<Column>> ret = new LinkedHashMap<ByteBuffer, List<Column>>( keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), getColumnList(keySlice.getColumns())); } return ret; } catch (Exception e) { throw xtrans.translate(e); } }; };
@Override public Map<ByteBuffer, List<ColumnOrSuperColumn>> execute(Client cassandra) throws HectorException { try { List<KeySlice> keySlices = cassandra.get_indexed_slices( columnParent, predicate.toThrift(), workingSlicePredicate.toThrift(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType, columnFamily))); if (keySlices == null || keySlices.isEmpty()) { return new LinkedHashMap<ByteBuffer, List<ColumnOrSuperColumn>>(0); } LinkedHashMap<ByteBuffer, List<ColumnOrSuperColumn>> ret = new LinkedHashMap<ByteBuffer, List<ColumnOrSuperColumn>>(keySlices.size()); for (KeySlice keySlice : keySlices) { ret.put(ByteBuffer.wrap(keySlice.getKey()), keySlice.getColumns()); } return ret; } catch (Exception e) { throw exceptionsTranslator.translate(e); } } });
public static long getKeySliceSize(KeySlice keySlice) { if (keySlice == null) { return getNullSize(); } return getByteArraySize(keySlice.getKey()) + getCollectionSize(keySlice.getColumns(), ThriftObjectSizeUtils::getColumnOrSuperColumnSize); }
List<ColumnOrSuperColumn> coscList = keySlice.getColumns();
List<ColumnOrSuperColumn> columns = key.getColumns();
@Override public boolean apply(@Nullable KeySlice row) { return (row != null) && row.getColumns().size() > 0; } }
@Override public boolean apply(@Nullable KeySlice row) { return (row != null) && row.getColumns().size() > 0; } }
public Object getFieldValue(_Fields field) { switch (field) { case KEY: return getKey(); case COLUMNS: return getColumns(); } throw new IllegalStateException(); }
static Map<ByteBuffer, List<ColumnOrSuperColumn>> getColsByKey(List<KeySlice> firstPage) { Map<ByteBuffer, List<ColumnOrSuperColumn>> ret = Maps.newHashMapWithExpectedSize(firstPage.size()); for (KeySlice e : firstPage) { ret.put(ByteBuffer.wrap(e.getKey()), e.getColumns()); } return ret; } }
public Object getFieldValue(_Fields field) { switch (field) { case KEY: return getKey(); case COLUMNS: return getColumns(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case KEY: return getKey(); case COLUMNS: return getColumns(); } throw new IllegalStateException(); }
public static <T> Map<Bytes, List<T>> transformThriftResult(ColumnFamilyType columnFamilyType, List<KeySlice> keySlices, ThriftRow row) { Map<Bytes, List<T>> output = new HashMap<Bytes, List<T>>(); for (KeySlice keySlice : keySlices) { output.put(Bytes.fromByteArray(keySlice.getKey()), (List<T>) transformThriftResult(keySlice.getColumns(), columnFamilyType, row)); } return output; }