本文整理了Java中org.apache.fluo.api.data.Bytes.length()
方法的一些代码示例,展示了Bytes.length()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.length()
方法的具体详情如下:
包路径:org.apache.fluo.api.data.Bytes
类名称:Bytes
方法名:length
[英]Gets the length of bytes
[中]获取字节的长度
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
/**
* @return Returns input with prefix and hash stripped from beginning.
*/
public Bytes removeHash(Bytes row) {
Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5,
"Row is shorter than expected " + row);
Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes),
"Row does not have expected prefix " + row);
Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row);
return row.subSequence(prefixBytes.length() + 5, row.length());
}
代码示例来源:origin: org.apache.fluo/fluo-api
public BytesBuilder append(Bytes b) {
ensureCapacity(len + b.length);
System.arraycopy(b.data, b.offset, ba, len, b.length);
len += b.length();
return this;
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-test
public static void encNonAscii(StringBuilder sb, Bytes bytes) {
for (int i = 0; i < bytes.length(); i++) {
byte b = bytes.byteAt(i);
if (b >= 32 && b <= 126 && b != '\\') {
sb.append((char) b);
} else {
sb.append(String.format("\\x%02x", b & 0xff));
}
}
}
代码示例来源:origin: apache/fluo
public BytesBuilder append(Bytes b) {
ensureCapacity(len + b.length);
System.arraycopy(b.data, b.offset, ba, len, b.length);
len += b.length();
return this;
}
代码示例来源:origin: apache/fluo
private static byte[] serializeInternal(List<Bytes> splits) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzOut = new GZIPOutputStream(baos);
BufferedOutputStream bos = new BufferedOutputStream(gzOut, 1 << 16);
DataOutputStream dos = new DataOutputStream(bos);
dos.writeInt(splits.size());
for (Bytes split : splits) {
dos.writeInt(split.length());
split.writeTo(dos);
}
dos.close();
return baos.toByteArray();
}
代码示例来源:origin: org.apache.fluo/fluo-core
@Override
public int weigh(Bytes key, ColumnVisibility vis) {
return key.length() + vis.getExpression().length + 32;
}
}
代码示例来源:origin: apache/fluo
@Override
public int weigh(Bytes key, ColumnVisibility vis) {
return key.length() + vis.getExpression().length + 32;
}
}
代码示例来源:origin: org.apache.rya/rya.pcj.fluo.app
/**
* Removes the triple prefix and returns the new value as a byte array.
* @param prefixedTriple - serialized RyaStatement with prepended triple prefix, converted to Bytes
* @return - serialized {@link RyaStatement} in byte array form
*/
public static byte[] removeTriplePrefixAndConvertToByteArray(Bytes prefixedTriple) {
checkNotNull(prefixedTriple);
return prefixedTriple.subSequence(TRIPLE_PREFIX_BYTES.length(), prefixedTriple.length()).toArray();
}
}
代码示例来源:origin: apache/fluo
private long size(RowColumn rowCol) {
Column col = rowCol.getColumn();
return (long) rowCol.getRow().length() + col.getFamily().length()
+ col.getQualifier().length() + col.getVisibility().length();
}
代码示例来源:origin: org.apache.fluo/fluo-core
private long size(RowColumn rowCol) {
Column col = rowCol.getColumn();
return (long) rowCol.getRow().length() + col.getFamily().length()
+ col.getQualifier().length() + col.getVisibility().length();
}
代码示例来源:origin: apache/fluo
public ColumnVisibility getCV(final Bytes colvis) {
if (colvis.length() == 0) {
return EMPTY_VIS;
}
try {
return visCache.get(colvis, () -> new ColumnVisibility(ByteUtil.toText(colvis)));
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
public RowHasher(String prefix) {
this.prefix = prefix;
this.prefixBytes = Bytes.of(prefix + ":");
builders = ThreadLocal.withInitial(() -> {
BytesBuilder bb = Bytes.builder(prefixBytes.length() + 5 + 32);
bb.append(prefixBytes);
return bb;
});
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
/**
* Computes the minimial row for a bucket
*/
private Bytes getMinimalRow() {
return Bytes.builder(bucketRow.length() + 1).append(bucketRow).append(':').toBytes();
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
/**
* @return Returns input with prefix and hash of input prepended.
*/
public Bytes addHash(Bytes row) {
BytesBuilder builder = builders.get();
builder.setLength(prefixBytes.length());
builder.append(genHash(row));
builder.append(":");
builder.append(row);
return builder.toBytes();
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
public RowColumnValue convert(K key, V val) {
byte[] k = serializer.serialize(key);
int hash = Hashing.murmur3_32().hashBytes(k).asInt();
String bucketId = CombineQueueImpl.genBucketId(Math.abs(hash % numBuckets), numBuckets);
BytesBuilder bb = Bytes.builder(dataPrefix.length() + bucketId.length() + 1 + k.length);
Bytes row = bb.append(dataPrefix).append(bucketId).append(':').append(k).toBytes();
byte[] v = serializer.serialize(val);
return new RowColumnValue(row, CombineQueueImpl.DATA_COLUMN, Bytes.of(v));
}
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
public void add(long seq, byte[] key, byte[] value) {
BytesBuilder builder = Bytes.builder(bucketRow.length() + 1 + key.length + 8).append(bucketRow)
.append(':').append(key);
encSeq(builder, seq);
ttx.set(builder.toBytes(), EXPORT_COL, Bytes.of(value));
}
代码示例来源:origin: org.apache.fluo/fluo-recipes-core
public void setContinueRow(ExportEntry ee) {
BytesBuilder builder = Bytes.builder(bucketRow.length() + 1 + ee.key.length + 8)
.append(bucketRow).append(':').append(ee.key);
encSeq(builder, ee.seq);
Bytes nextRow = builder.toBytes();
ttx.set(getMinimalRow(), NEXT_COL, nextRow);
}
代码示例来源:origin: apache/fluo
public FluoCondition(Environment env, Column col) {
super(ByteUtil.toByteSequence(col.getFamily()), ByteUtil.toByteSequence(col.getQualifier()));
if (col.getVisibility().length() > 0) {
setVisibility(env.getSharedResources().getVisCache().getCV(col));
}
}
代码示例来源:origin: org.apache.fluo/fluo-core
public FluoCondition(Environment env, Column col) {
super(ByteUtil.toByteSequence(col.getFamily()), ByteUtil.toByteSequence(col.getQualifier()));
if (col.getVisibility().length() > 0) {
setVisibility(env.getSharedResources().getVisCache().getCV(col));
}
}
代码示例来源:origin: org.apache.fluo/fluo-core
public static void put(Environment env, Mutation m, Column col, long ts, byte[] val) {
ColumnVisibility cv;
if (env != null) {
cv = env.getSharedResources().getVisCache().getCV(col.getVisibility());
} else if (col.getVisibility().length() == 0) {
cv = VisibilityCache.EMPTY_VIS;
} else {
cv = new ColumnVisibility(ByteUtil.toText(col.getVisibility()));
}
m.put(col.getFamily().toArray(), col.getQualifier().toArray(), cv, ts, val);
}
}
内容来源于网络,如有侵权,请联系作者删除!