程序包 gu.sql2java

类 QueueBufferProducerAction<B extends gu.sql2java.BaseBean,T>

java.lang.Object
gu.sql2java.QueueBufferProducerAction<B,T>
类型参数:
B - 从数据库读取的原始记录对象类型
T - 队列中保存的基于B转换的数据库对象类型
所有已实现的接口:
gu.sql2java.TableManager.Action<B>
直接已知子类:
QueueBufferProducerAction.SimpleQueueProducerAction

public class QueueBufferProducerAction<B extends gu.sql2java.BaseBean,T> extends Object implements gu.sql2java.TableManager.Action<B>
实现向阻塞队列输出数据库记录的TableManager.Action接口
为异步输出数据库查询记录提供技术基础, 作为数据库记录的生产者向将从数据库中读取的数据库记录转换为指定的类型添加到阻塞队列,供另一端的消费者使用, 当消费端停止消费时,即停止工作。
从以下版本开始:
3.15.4
作者:
guyadong
  • 构造器详细资料

    • QueueBufferProducerAction

      public QueueBufferProducerAction(BlockingQueue<List<T>> queue, int bufferCapacity, int queueTimeout, AtomicBoolean stopped, com.google.common.base.Function<B,T> transformer, boolean outputProgress, long rowCount)
      构造方法
      参数:
      queue - 阻塞队列
      bufferCapacity - 缓冲区容量
      queueTimeout - 插入队列超时时间(秒), 队列满后超过这个时间不能插入新记录即视消费端中止,并中止插入 小于等于0使用默认值DEFAULT_QUEUE_TIMEOUT
      stopped - 停止标志,为null忽略,为true时不再向队列添加数据,抛出QueueTimeoutException,结束循环
      transformer - B到T的数据类型转换器
      outputProgress - 是否输出进度
      rowCount - 当前查询的记录总数
    • QueueBufferProducerAction

      public QueueBufferProducerAction(int queueCapaticy, int bufferCapacity, int queueTimeout, AtomicBoolean stopped, com.google.common.base.Function<B,T> transformer, boolean outputProgress, long rowCount)
      构造方法
      参数:
      queueCapaticy - 队列容量,小于等于0使用默认值DEFAULT_QUEUE_CAPACITY
      bufferCapacity - 缓冲区容量
      queueTimeout - 插入队列超时时间(秒), 队列满后超过这个时间不能插入新记录即视消费端中止,并中止插入 小于等于0使用默认值DEFAULT_QUEUE_TIMEOUT
      stopped - 停止标志,为null忽略,为true时不再向队列添加数据,抛出QueueTimeoutException,结束循环
      transformer - B到T的数据类型转换器
      outputProgress - 是否输出进度
      rowCount - 当前查询的记录总数
    • QueueBufferProducerAction

      public QueueBufferProducerAction(QueueBufferProducerAction<B,T> action, long rowCount)
      构造方法
      从原对象复制构造新对象,除了rowCount字段都从原对象复制,用于多线程异步查询所需要的action对象构建
      参数:
      action -
      rowCount - 当前查询的记录总数
    • QueueBufferProducerAction

      public QueueBufferProducerAction(AtomicBoolean stopped, com.google.common.base.Function<B,T> transformer, long rowCount)
      简化版本构造方法
      队列容量和插入队列超时时间使用默认值
      参数:
      stopped - 停止标志,为null忽略,为true时不再向队列添加数据,抛出QueueTimeoutException,结束循环
      transformer - B到T的数据类型转换器
      rowCount - 当前查询的记录总数
  • 方法详细资料

    • getQueue

      public BlockingQueue<List<T>> getQueue()
    • getRowCount

      public long getRowCount()
      返回:
      rowCount
    • getBufferCapacity

      public int getBufferCapacity()
    • call

      public void call(B bean)
      将数据库中获取的原始数据库对象通过转换器(transformer)转换为指定类型插入到阻塞队列中。 当阻塞队列满添加元素超时即视为消费端停止,即停止工作,抛出QueueTimeoutException异常, 以中止从数据库中读取记录的过程
      指定者:
      call 在接口中 gu.sql2java.TableManager.Action<B extends gu.sql2java.BaseBean>