Code Search for Developers
 
 
  

BatchUUIDGenerator.java from Texai at Krugle


Show BatchUUIDGenerator.java syntax highlighted

/*
 * BatchUUIDGenerator.java
 *
 * Created on April 26, 2007, 9:08 AM
 *
 * Description: Provides for batch generation of UUID's.
 *
 * Copyright (C) April 26, 2007 Stephen L. Reed.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.texai.kb;

import java.util.UUID;
import org.apache.log4j.Logger;
import org.texai.util.ByteUtils;

/**
 *
 * @author reed
 */
public class BatchUUIDGenerator {
  
  /** the logger */
  private static final Logger LOGGER = Logger.getLogger(BatchUUIDGenerator.class);
  
  /** the array of UUID counts that fall into the corresponding partition */
  final int[] uuidPartitionCount = new int[512];
  
  /** Creates a new instance of BatchUUIDGenerator. */
  public BatchUUIDGenerator() {
  }
  
  /** Runs this application instance. */
  private void run() {
    for (int i = 0; i < 21553016; i++) {
      final UUID uuid = UUID.randomUUID();
      // use the first nine bits of the UUID to partition it
      final int index = (int) uuid.getMostSignificantBits() >>> 55;
      uuidPartitionCount[index]++;
      if (i % 1000000 == 0) {
        LOGGER.info(i);
      }
    }
    for (int i = 0; i < uuidPartitionCount.length; i++) {
      LOGGER.info("partition " + i + " count " + uuidPartitionCount[i]);
    }
  }
  
  
  /** Executes this application.
   *
   * @param args the array of command line arguments (unused)
   */
  public static void main(final String[] args) {
    final BatchUUIDGenerator batchUUIDGenerator = new BatchUUIDGenerator();
    batchUUIDGenerator.run();
  }
}




See more files for this project here

Texai

Texai is an chatbot that intelligently seeks to acquire knowledge and friendly behaviors.

Project homepage: http://sourceforge.net/projects/texai
Programming language(s): Java,Shell Script,XML
License: other

  ejb/
    jmsrmi/
      RemoteInvocation.java
      RemoteInvocationArgument.java
      RemoteInvocationResult.java
      RemoteServiceConsumer.java
      RemoteServiceProvider.java
      RemoteTransferObject.java
    mdb/
      domainEntity/
        KBPartition.java
        KBShard.java
      KBPartitionPeer.java
      KBShardPeer.java
  BatchUUIDGenerator.java
  KBPeerLauncher.java
  shard.properties