@Override public Map<ByteBuffer, SuperColumn> multigetSuperColumn(List<ByteBuffer> keys, ColumnPath columnPath, boolean reversed, int size) throws HectorException { //valideSuperColumnPath(columnPath); // only can get supercolumn by multigetSuperSlice ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), reversed, size); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); Map<ByteBuffer, List<SuperColumn>> sclist = multigetSuperSlice(keys, clp, sp); if (sclist == null || sclist.isEmpty()) { return Collections.emptyMap(); } Map<ByteBuffer, SuperColumn> result = new HashMap<ByteBuffer, SuperColumn>(keys.size() * 2); for (Map.Entry<ByteBuffer, List<SuperColumn>> entry : sclist.entrySet()) { List<SuperColumn> sclistByKey = entry.getValue(); if (sclistByKey.size() > 0) { result.put(entry.getKey(), sclistByKey.get(0)); } } return result; }
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { List<ColumnOrSuperColumn> cosc = cassandra.get_slice(key, clp, sp, getThriftCl(OperationType.READ)); if (cosc == null || cosc.isEmpty()) { return null; } return new SuperColumn(ByteBuffer.wrap(columnPath.getSuper_column()), getColumnList(cosc)); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value, long timestamp) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(timestamp); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(connectionManager.createClock()); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }
private static String toString(ColumnPath colPath) { return "CF '" + colPath.getColumn_family() + "'"; } // toString(KeyRange)
private static String toString(ColumnPath colPath) { return "CF '" + colPath.getColumn_family() + "'"; } // toString(KeyRange)
public Object getFieldValue(_Fields field) { switch (field) { case COLUMN_FAMILY: return getColumn_family(); case SUPER_COLUMN: return getSuper_column(); case COLUMN: return getColumn(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case COLUMN_FAMILY: return getColumn_family(); case SUPER_COLUMN: return getSuper_column(); case COLUMN: return getColumn(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case COLUMN_FAMILY: return getColumn_family(); case SUPER_COLUMN: return getSuper_column(); case COLUMN: return getColumn(); } throw new IllegalStateException(); }
@Override public Map<ByteBuffer, SuperColumn> multigetSuperColumn(List<ByteBuffer> keys, ColumnPath columnPath, boolean reversed, int size) throws HectorException { //valideSuperColumnPath(columnPath); // only can get supercolumn by multigetSuperSlice ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), reversed, size); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); Map<ByteBuffer, List<SuperColumn>> sclist = multigetSuperSlice(keys, clp, sp); if (sclist == null || sclist.isEmpty()) { return Collections.emptyMap(); } Map<ByteBuffer, SuperColumn> result = new HashMap<ByteBuffer, SuperColumn>(keys.size() * 2); for (Map.Entry<ByteBuffer, List<SuperColumn>> entry : sclist.entrySet()) { List<SuperColumn> sclistByKey = entry.getValue(); if (sclistByKey.size() > 0) { result.put(entry.getKey(), sclistByKey.get(0)); } } return result; }
@Override public Map<ByteBuffer, SuperColumn> multigetSuperColumn(List<ByteBuffer> keys, ColumnPath columnPath, boolean reversed, int size) throws HectorException { //valideSuperColumnPath(columnPath); // only can get supercolumn by multigetSuperSlice ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), reversed, size); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); Map<ByteBuffer, List<SuperColumn>> sclist = multigetSuperSlice(keys, clp, sp); if (sclist == null || sclist.isEmpty()) { return Collections.emptyMap(); } Map<ByteBuffer, SuperColumn> result = new HashMap<ByteBuffer, SuperColumn>(keys.size() * 2); for (Map.Entry<ByteBuffer, List<SuperColumn>> entry : sclist.entrySet()) { List<SuperColumn> sclistByKey = entry.getValue(); if (sclistByKey.size() > 0) { result.put(entry.getKey(), sclistByKey.get(0)); } } return result; }
} catch (InvalidRequestException ex) { String errMsg = "get() failed for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex);
} catch (InvalidRequestException ex) { String errMsg = "remove() failed for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); m_bFailed = true; String errMsg = "All retries exceeded; abandoning remove() for table: " + colPath.getColumn_family(); m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex);
} catch (InvalidRequestException ex) { String errMsg = "remove() failed for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); m_bFailed = true; String errMsg = "All retries exceeded; abandoning remove() for table: " + colPath.getColumn_family(); m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex);
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { List<ColumnOrSuperColumn> cosc = cassandra.get_slice(key, clp, sp, getThriftCl(OperationType.READ)); if (cosc == null || cosc.isEmpty()) { return null; } return new SuperColumn(ByteBuffer.wrap(columnPath.getSuper_column()), getColumnList(cosc)); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { List<ColumnOrSuperColumn> cosc = cassandra.get_slice(key, clp, sp, getThriftCl(OperationType.READ)); if (cosc == null || cosc.isEmpty()) { return null; } return new SuperColumn(ByteBuffer.wrap(columnPath.getSuper_column()), getColumnList(cosc)); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value, long timestamp) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(timestamp); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value, long timestamp) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(timestamp); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(connectionManager.createClock()); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(connectionManager.createClock()); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }