当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayList类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.bytes.ByteArrayList的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayList类的具体用法?Java ByteArrayList怎么用?Java ByteArrayList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ByteArrayList类属于it.unimi.dsi.fastutil.bytes包,在下文中一共展示了ByteArrayList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
@Override
public void run() {
	try {
		final ByteArrayDiskQueue receivedURLs = frontier.receivedURLs;
		final ArrayBlockingQueue<ByteArrayList> quickReceivedURLs = frontier.quickReceivedURLs;
		while(! stop) {
			final ByteArrayList list = quickReceivedURLs.poll(1, TimeUnit.SECONDS);
			if (list != null) receivedURLs.enqueue(list.elements(), 0, list.size());
		}
	}
	catch (Throwable t) {
		LOGGER.error("Unexpected exception ", t);
	}

	LOGGER.info("Completed");
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:17,代码来源:QuickMessageThread.java

示例2: deflateString

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/**
 * ZLIB compress a {@code String}.
 * <p>
 * This only produces ZLIB format using {@code Deflater}.
 * 
 * @param input  the string to compress, not null
 * @return the compressed bytes, not null
 */
public static byte[] deflateString(final String input) {
  ArgumentChecker.notNull(input, "input");
  byte[] bytes = input.getBytes(StandardCharsets.UTF_8);
  Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
  deflater.setInput(bytes);
  ByteArrayList collector = new ByteArrayList(bytes.length + 32);
  byte[] buf = new byte[1024];
  deflater.finish();
  while (deflater.finished() == false) {
    int size = deflater.deflate(buf);
    collector.addElements(collector.size(), buf, 0, size);
  }
  deflater.end();
  return collector.toByteArray();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:ZipUtils.java

示例3: inflateString

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/**
 * ZLIB uncompress to a {@code String}.
 * <p>
 * This only handles ZLIB format using {@code Inflater}.
 * 
 * @param input  the bytes to compress, not null
 * @return the compressed string, not null
 */
public static String inflateString(final byte[] input) {
  ArgumentChecker.notNull(input, "input");
  try {
    Inflater inflater = new Inflater();
    inflater.setInput(input);
    ByteArrayList collector = new ByteArrayList(input.length * 4);
    byte[] buf = new byte[1024];
    while (inflater.finished() == false) {
      int size = inflater.inflate(buf);
      collector.addElements(collector.size(), buf, 0, size);
    }
    inflater.end();
    byte[] bytes = collector.toByteArray();
    return new String(bytes, StandardCharsets.UTF_8);
  } catch (DataFormatException ex) {
    throw new OpenGammaRuntimeException(ex.getMessage(), ex);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:ZipUtils.java

示例4: end

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
@Override
public void end() {
  if (elementClass == boolean.class) {
    parent.add(((BooleanArrayList) container).toBooleanArray());
  } else if (elementClass == byte.class) {
    parent.add(((ByteArrayList) container).toByteArray());
  } else if (elementClass == char.class) {
    parent.add(((CharArrayList) container).toCharArray());
  } else if (elementClass == short.class) {
    parent.add(((ShortArrayList) container).toShortArray());
  } else if (elementClass == int.class) {
    parent.add(((IntArrayList) container).toIntArray());
  } else if (elementClass == long.class) {
    parent.add(((LongArrayList) container).toLongArray());
  } else if (elementClass == float.class) {
    parent.add(((FloatArrayList) container).toFloatArray());
  } else if (elementClass == double.class) {
    parent.add(((DoubleArrayList) container).toDoubleArray());
  } else {
    parent.add(((ArrayList) container).toArray());
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:23,代码来源:AvroRecordConverter.java

示例5: toByteArrayList

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/** Writes an ASCII string in a {@link ByteArrayList}.
 *
 * @param s an ASCII string.
 * @param list a byte list that will contain the byte representation of {@code s}.
 * @return {@code list}.
 * @throws AssertionError if assertions are enabled and some character of {@code s} is not ASCII.
 */
public static ByteArrayList toByteArrayList(final String s, final ByteArrayList list) {
	list.clear();
	list.size(s.length());
	final byte[] array = list.elements();
	for (int i = list.size(); i-- != 0;) {
		assert s.charAt(i) < (char)0x80 : s.charAt(i);
		array[i] = (byte)(s.charAt(i) & 0x7F);
	}
	return list;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:18,代码来源:Util.java

示例6: toString

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/** Returns a string representation of an ASCII byte array.
 *
 * <p>This method is significantly faster than those relying on character encoders, and it allocates just
 * one object&mdash;the resulting string.
 *
 * @param byteArrayList an ASCII byte-array list.
 * @return a string representation of {@code byteArrayList}.
 * @throws AssertionError if assertions are enabled and some character of {@code byteArrayList} is not ASCII.
 */
public static String toString(final ByteArrayList byteArrayList) {
	final char[] charArray = new char[byteArrayList.size()];
	final byte[] byteArray = byteArrayList.elements();
	// This needs to be fast.
	for(int i = byteArrayList.size(); i-- != 0;) {
		assert byteArray[i] < (char)0x80 : byteArray[i];
		charArray[i] = (char)byteArray[i];
	}
	return new String(charArray);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:20,代码来源:Util.java

示例7: pathAndQueryAsByteArray

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/** Extracts the path and query of an absolute BUbiNG URL in its byte-array representation.
 *
 * @param url BUbiNG URL.
 * @return the path and query in byte-array representation.
 */
public static byte[] pathAndQueryAsByteArray(ByteArrayList url){
	final byte[] array = url.elements();
	final int startOfAuthority = Bytes.indexOf(array, (byte)':') + 3;
	assert array[startOfAuthority - 1] == '/' : array[startOfAuthority - 1];
	assert array[startOfAuthority - 2] == '/' : array[startOfAuthority - 2];
	return Arrays.copyOfRange(array, ArrayUtils.indexOf(array, (byte)'/', startOfAuthority), url.size());
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:13,代码来源:BURL.java

示例8: fromStream

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/** A serializer-deserializer for byte arrays that write the array length using variable-length byte encoding,
 * and the writes the content of the array. */
@Override
public ByteArrayList fromStream(final InputStream is) throws IOException {
	final int length = Util.readVByte(is);
	buffer.size(length);
	final int actual = is.read(buffer.elements(), 0, length);
	if (actual != length) throw new IOException("Asked for " + length + " but got " + actual);
	return buffer;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:ByteArrayListByteSerializerDeserializer.java

示例9: toStream

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
@Override

	public void toStream(final ByteArrayList list, final OutputStream os) throws IOException {
		final int length = list.size();
		Util.writeVByte(length, os);
		os.write(list.elements(), 0, length);
	}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:8,代码来源:ByteArrayListByteSerializerDeserializer.java

示例10: BooleanColumn

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
public BooleanColumn(String name, boolean[] array) {
    super(name);
    this.data = new ByteArrayList(array.length);
    for (boolean b : array) {
        append(b);
    }
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:8,代码来源:BooleanColumn.java

示例11: unique

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
@Override
public BooleanColumn unique() {
    ByteSet count = new ByteOpenHashSet(3);
    for (byte next : data) {
        count.add(next);
    }
    ByteArrayList list = new ByteArrayList(count);
    return new BooleanColumn(name() + " Unique values", list);
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:10,代码来源:BooleanColumn.java

示例12: toIntColumn

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
public IntColumn toIntColumn() {
    IntColumn intColumn = new IntColumn(this.name() + ": ints", size());
    ByteArrayList data = data();
    for (int i = 0; i < size(); i++) {
        intColumn.append(data.getByte(i));
    }
    return intColumn;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:9,代码来源:BooleanColumn.java

示例13: addBlock

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
private int addBlock(ObjectArrayList<AlignmentBlock> blocks, int start, ByteArrayList bases,
                     ByteArrayList scores) {

    blocks.add(
            new AlignmentBlockImpl(getChr(), start,
                    bases.toByteArray(new byte[bases.size()]),
                    scores.toByteArray(new byte[scores.size()])));
    start += bases.size();
    bases.clear();
    scores.clear();
    return start;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:13,代码来源:GobyAlignment.java

示例14: addCompressed

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
/** Appends compressed value v to the given posting list. Set v=0 for a separator, 
 * v=transactionId+1 for a transaction id, and v=position+1 for a position. */
public static final void addCompressed(int v, ByteArrayList postingList) {
  assert v >= 0;
  do {
    byte b = (byte) (v & 127);
    v >>= 7;
    if (v == 0) {
      postingList.add(b);
      break;
    } else {
      b += 128;
      postingList.add(b);
    }
  } while (true);
}
 
开发者ID:uma-pi1,项目名称:lash,代码行数:17,代码来源:PostingList.java

示例15: Agent

import it.unimi.dsi.fastutil.bytes.ByteArrayList; //导入依赖的package包/类
public Agent(final String hostname, final int jmxPort, final RuntimeConfiguration rc) throws Exception {
	// TODO: configure strategies

	super(rc.name, rc.weight, new InetSocketAddress(hostname,  jmxPort),
			new JChannel(System.getProperty(JGROUPS_CONFIGURATION_PROPERTY_NAME) != null ? (InputStream)new FileInputStream(System.getProperty(JGROUPS_CONFIGURATION_PROPERTY_NAME)) : JGroupsJobManager.class.getResourceAsStream('/' + JGroupsJobManager.class.getPackage().getName().replace('.',  '/') + "/jgroups.xml")),
			 rc.group, new ConsistentHashAssignmentStrategy<BubingJob>(), new LinkedBlockingQueue<BubingJob>(),
			 new TimedDroppingThreadFactory<BubingJob>(1800000), new DiscardMessagesStrategy<BubingJob>());

	LOGGER.info("Creating Agent instance with properties {}", rc);

	// TODO: check crawlIsNew for all components.
	this.rc = rc;

	store = rc.storeClass.getConstructor(RuntimeConfiguration.class).newInstance(rc);

	register();

	frontier = new Frontier(rc, store, this);
	setListener(frontier);

	(messageThread = new MessageThread(frontier)).start();
	(quickMessageThread = new QuickMessageThread(frontier)).start();

	connect();

	// It is important that threads are allocated here, that is, after the agent has been connected.
	frontier.dnsThreads(rc.dnsThreads);
	frontier.parsingThreads(rc.parsingThreads);
	frontier.fetchingThreads(rc.fetchingThreads);

	frontier.rc.ensureNotPaused();
	final ByteArrayList list = new ByteArrayList();
	while(rc.seed.hasNext()) {
		final URI nextSeed = rc.seed.next();
		if (nextSeed != null) frontier.enqueue(BURL.toByteArrayList(nextSeed, list));
	}

	// We wait for the notification of a stop event, usually caused by a call to stop().
	synchronized(this) {
		if (! rc.stopping) wait();
	}

	// Stuff to be done at stopping time

	// The message thread uses the sieve, which will be closed by the frontier.
	messageThread.stop = true;
	messageThread.join();
	LOGGER.info("Joined message thread");

	frontier.close();

	LOGGER.info("Going to close job manager " + this);
	close();
	LOGGER.info("Job manager closed");

	// We stop here the quick message thread. Messages in the receivedURLs queue will be snapped.
	quickMessageThread.stop = true;
	quickMessageThread.join();
	LOGGER.info("Joined quick message thread");

	frontier.snap();

	LOGGER.info("Agent " + this + " exits");
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:65,代码来源:Agent.java


注:本文中的it.unimi.dsi.fastutil.bytes.ByteArrayList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。