public static Row createSingleStringRow(String value, int protocolVersion) { ColumnDefinitions definitions = new ColumnDefinitions(new Definition[] {new Definition("keyspace", "table", "column", DataType.ascii())}, CodecRegistry.DEFAULT_INSTANCE); ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8)); return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion), ImmutableList.of(data)); } }
static Row fromData( ColumnDefinitions metadata, Token.Factory tokenFactory, ProtocolVersion protocolVersion, List<ByteBuffer> data) { if (data == null) return null; return new ArrayBackedRow(metadata, tokenFactory, protocolVersion, data); }
@Override public Token getToken(int i) { if (tokenFactory == null) throw new DriverInternalError( "Token factory not set. This should only happen at initialization time"); checkType(i, tokenFactory.getTokenType().getName()); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return null; return tokenFactory.deserialize(value, protocolVersion); }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException( "Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Row["); for (int i = 0; i < metadata.size(); i++) { if (i != 0) sb.append(", "); ByteBuffer bb = data.get(i); if (bb == null) sb.append("NULL"); else sb.append( getCodecRegistry() .codecFor(metadata.getType(i)) .deserialize(bb, protocolVersion) .toString()); } sb.append(']'); return sb.toString(); } }
@Override public Token getToken(String name) { return getToken(metadata.getFirstIdx(name)); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Row["); for (int i = 0; i < metadata.size(); i++) { if (i != 0) sb.append(", "); ByteBuffer bb = data.get(i); if (bb == null) sb.append("NULL"); else sb.append(getCodecRegistry().codecFor(metadata.getType(i)).deserialize(bb, protocolVersion).toString()); } sb.append(']'); return sb.toString(); } }
@Override public Row one() { return ArrayBackedRow.fromData(metadata, tokenFactory, protocolVersion, rows.poll()); }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
static Row fromData(ColumnDefinitions metadata, Token.Factory tokenFactory, ProtocolVersion protocolVersion, List<ByteBuffer> data) { if (data == null) return null; return new ArrayBackedRow(metadata, tokenFactory, protocolVersion, data); }
@Override public Token getToken(int i) { if (tokenFactory == null) throw new DriverInternalError("Token factory not set. This should only happen at initialization time"); checkType(i, tokenFactory.getTokenType().getName()); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return null; return tokenFactory.deserialize(value, protocolVersion); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Row["); for (int i = 0; i < metadata.size(); i++) { if (i != 0) sb.append(", "); ByteBuffer bb = data.get(i); if (bb == null) sb.append("NULL"); else sb.append(getCodecRegistry().codecFor(metadata.getType(i)).deserialize(bb, protocolVersion).toString()); } sb.append(']'); return sb.toString(); } }
@Override public Row one() { prepareNextRow(); return ArrayBackedRow.fromData(metadata, tokenFactory, protocolVersion, currentPage.poll()); }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
static Row fromData(ColumnDefinitions metadata, Token.Factory tokenFactory, ProtocolVersion protocolVersion, List<ByteBuffer> data) { if (data == null) return null; return new ArrayBackedRow(metadata, tokenFactory, protocolVersion, data); }
@Override public Token getToken(int i) { if (tokenFactory == null) throw new DriverInternalError("Token factory not set. This should only happen at initialization time"); checkType(i, tokenFactory.getTokenType().getName()); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return null; return tokenFactory.deserialize(value, protocolVersion); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Row["); for (int i = 0; i < metadata.size(); i++) { if (i != 0) sb.append(", "); ByteBuffer bb = data.get(i); if (bb == null) sb.append("NULL"); else sb.append(getCodecRegistry().codecFor(metadata.getType(i)).deserialize(bb, protocolVersion).toString()); } sb.append(']'); return sb.toString(); } }
@Override public Row one() { return ArrayBackedRow.fromData(metadata, tokenFactory, protocolVersion, rows.poll()); }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
static Row fromData(ColumnDefinitions metadata, Token.Factory tokenFactory, ProtocolVersion protocolVersion, List<ByteBuffer> data) { if (data == null) return null; return new ArrayBackedRow(metadata, tokenFactory, protocolVersion, data); }