use of it.unimi.dsi.fastutil.io.FastByteArrayInputStream in project invesdwin-context by invesdwin.
the class ADelegateDailyDownloadListRequest method call.
@Override
public final List<? extends E> call() throws Exception {
try {
final String content = newDailyDownloadCache().downloadString(getDownloadFileName(), new Callable<String>() {
@Override
public String call() throws Exception {
try (PooledFastByteArrayOutputStream out = PooledFastByteArrayOutputStream.newInstance()) {
try (IBeanTableWriter<E> writer = newWriter(out.asNonClosing())) {
writer.write(download());
}
return new String(out.toByteArray());
}
}
}, getNow());
if (Strings.isBlank(content)) {
throw new RetryLaterRuntimeException("Empty result for request: " + getDownloadFileName());
}
final ICloseableIterator<E> reader = newReader(new FastByteArrayInputStream(content.getBytes()));
final List<E> list = Lists.toListWithoutHasNext(reader);
Assertions.checkNotEmpty(list, "%s", getDownloadFileName());
return list;
} catch (final Throwable t) {
DailyDownloadCache.delete(getDownloadFileName());
throw Throwables.propagate(t);
}
}
use of it.unimi.dsi.fastutil.io.FastByteArrayInputStream in project PowerNukkitX by BlocklyNukkit.
the class PositionTrackingDBServerBroadcastPacket method decode.
@Override
public void decode() {
action = ACTIONS[getByte()];
trackingId = getVarInt();
try (FastByteArrayInputStream inputStream = new FastByteArrayInputStream(get())) {
tag = NBTIO.readNetworkCompressed(inputStream);
} catch (IOException e) {
throw new EncoderException(e);
}
}
use of it.unimi.dsi.fastutil.io.FastByteArrayInputStream in project PowerNukkitX by PowerNukkitX.
the class Binary method readMetadata.
public static EntityMetadata readMetadata(byte[] payload) {
BinaryStream stream = new BinaryStream();
stream.setBuffer(payload);
long count = stream.getUnsignedVarInt();
EntityMetadata m = new EntityMetadata();
for (int i = 0; i < count; i++) {
int key = (int) stream.getUnsignedVarInt();
int type = (int) stream.getUnsignedVarInt();
EntityData value = null;
switch(type) {
case Entity.DATA_TYPE_BYTE:
value = new ByteEntityData(key, stream.getByte());
break;
case Entity.DATA_TYPE_SHORT:
value = new ShortEntityData(key, stream.getLShort());
break;
case Entity.DATA_TYPE_INT:
value = new IntEntityData(key, stream.getVarInt());
break;
case Entity.DATA_TYPE_FLOAT:
value = new FloatEntityData(key, stream.getLFloat());
break;
case Entity.DATA_TYPE_STRING:
value = new StringEntityData(key, stream.getString());
break;
case Entity.DATA_TYPE_NBT:
int offset = stream.getOffset();
FastByteArrayInputStream fbais = new FastByteArrayInputStream(stream.get());
try {
CompoundTag tag = NBTIO.read(fbais, ByteOrder.LITTLE_ENDIAN, true);
value = new NBTEntityData(key, tag);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
stream.setOffset(offset + (int) fbais.position());
break;
case Entity.DATA_TYPE_POS:
BlockVector3 v3 = stream.getSignedBlockPosition();
value = new IntPositionEntityData(key, v3.x, v3.y, v3.z);
break;
case Entity.DATA_TYPE_LONG:
value = new LongEntityData(key, stream.getVarLong());
break;
case Entity.DATA_TYPE_VECTOR3F:
value = new Vector3fEntityData(key, stream.getVector3f());
break;
}
if (value != null)
m.put(value);
}
return m;
}
use of it.unimi.dsi.fastutil.io.FastByteArrayInputStream in project PowerNukkitX by BlocklyNukkit.
the class Binary method readMetadata.
public static EntityMetadata readMetadata(byte[] payload) {
BinaryStream stream = new BinaryStream();
stream.setBuffer(payload);
long count = stream.getUnsignedVarInt();
EntityMetadata m = new EntityMetadata();
for (int i = 0; i < count; i++) {
int key = (int) stream.getUnsignedVarInt();
int type = (int) stream.getUnsignedVarInt();
EntityData value = null;
switch(type) {
case Entity.DATA_TYPE_BYTE:
value = new ByteEntityData(key, stream.getByte());
break;
case Entity.DATA_TYPE_SHORT:
value = new ShortEntityData(key, stream.getLShort());
break;
case Entity.DATA_TYPE_INT:
value = new IntEntityData(key, stream.getVarInt());
break;
case Entity.DATA_TYPE_FLOAT:
value = new FloatEntityData(key, stream.getLFloat());
break;
case Entity.DATA_TYPE_STRING:
value = new StringEntityData(key, stream.getString());
break;
case Entity.DATA_TYPE_NBT:
int offset = stream.getOffset();
FastByteArrayInputStream fbais = new FastByteArrayInputStream(stream.get());
try {
CompoundTag tag = NBTIO.read(fbais, ByteOrder.LITTLE_ENDIAN, true);
value = new NBTEntityData(key, tag);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
stream.setOffset(offset + (int) fbais.position());
break;
case Entity.DATA_TYPE_POS:
BlockVector3 v3 = stream.getSignedBlockPosition();
value = new IntPositionEntityData(key, v3.x, v3.y, v3.z);
break;
case Entity.DATA_TYPE_LONG:
value = new LongEntityData(key, stream.getVarLong());
break;
case Entity.DATA_TYPE_VECTOR3F:
value = new Vector3fEntityData(key, stream.getVector3f());
break;
}
if (value != null)
m.put(value);
}
return m;
}
use of it.unimi.dsi.fastutil.io.FastByteArrayInputStream in project invesdwin-context by invesdwin.
the class ClasspathResourceProcessor method processDirectory.
/**
* we also need to process directories, since if they are missing in newly generated jars, classpath scanning by
* spring does not work!
*/
private boolean processDirectory(final File root, final File file, final IClasspathResourceVisitor visitor) {
final String fullPath = file.getAbsolutePath();
final String resourcePath = createResourcePath(root, file) + "/";
return visitor.visit(fullPath, resourcePath, new FastByteArrayInputStream(Bytes.EMPTY_ARRAY));
}
Aggregations