@Override public ByteBuffer getColumn(Column<ByteBuffer> element) { return element.getName(); }
@Override public ByteBuffer getValue(Column<ByteBuffer> element) { return element.getByteBufferValue(); }
@Override public boolean apply(@Nullable Row<ByteBuffer, ByteBuffer> row) { return (row != null) && row.getColumns().size() > 0; } }
/** * Return true if we have < 2 rows with columns, false otherwise */ private boolean containsSingleRowOnly( final Rows<R, C> result ) { int count = 0; for ( R key : result.getKeys() ) { if ( result.getRow( key ).getColumns().size() > 0 ) { count++; //we have more than 1 row with values, return them if ( count > 1 ) { return false; } } } return true; }
private List<MvccLogEntry> parseResults( final ColumnList<UUID> columns, final Id entityId ) { List<MvccLogEntry> results = new ArrayList<MvccLogEntry>( columns.size() ); for ( Column<UUID> col : columns ) { final UUID storedVersion = col.getName(); final StageStatus stage = col.getValue( SER ); results.add( new MvccLogEntryImpl( entityId, storedVersion, stage.stage, stage.state ) ); } return results; }
@Override public Object getMetaData(Column<ByteBuffer> element, EntryMetaData meta) { switch(meta) { case TIMESTAMP: return element.getTimestamp(); case TTL: return element.getTtl(); default: throw new UnsupportedOperationException("Unsupported meta data: " + meta); } } }
@Override public boolean apply(@Nullable Row<ByteBuffer, ByteBuffer> row) { return (row != null) && !row.getKey().equals(skip); } }
@Override public ByteBuffer toByteBuffer(final EntityVersion ev) { final UUID entityVersion = ev.getEntityVersion(); final Id entityId = ev.getEntityId(); final UUID entityUuid = entityId.getUuid(); final String entityType = entityId.getType(); CompositeBuilder builder = Composites.newDynamicCompositeBuilder(); builder.addUUID( entityVersion ); builder.addUUID( entityUuid ); builder.addString(entityType ); return builder.build(); }
/** * Create a scan range that represents the timestamp of the edge * @param timestamp * @return */ public ByteBuffer fromTimeRange( final long timestamp ) { DynamicComposite composite = new DynamicComposite(); composite.addComponent( timestamp, LONG_SERIALIZER ); return composite.serialize(); } }
@SuppressWarnings("unchecked") @Override public <T> T read(Serializer<T> serializer) { Object obj = this.composite.get(position, serializer); position++; return (T) obj; }
@Override public String fromComposite( final CompositeParser composite ) { return composite.readString(); }
@Override public void toComposite( final CompositeBuilder builder, final String string ) { builder.addString( string ); }
public DynamicCompositeParserImpl(ByteBuffer bb) { this.composite = DynamicComposite.fromByteBuffer(bb); }
@Override public String parseColumn( final Column<String> column ) { return column.getName(); }
@Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } };
@Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } };
@Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } };
@Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } };
@Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } };