精华内容
下载资源
问答
  • Please move 'proctime(r_proctime)' to the end of the schema. at org.apache.flink.table.typeutils.FieldInfoUtils$IndexedExprToFieldInfo.validateProcTimeAttributeAppended(FieldInfoUtils.java:512) at ...

    代码:

            List<Tuple3<String,Long,Timestamp>>ratesHistoryData = new ArrayList<>();
            ratesHistoryData.add(Tuple3.of("US Dollar", 102L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 114L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Yen", 1L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 116L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 119L,new Timestamp(1L)));
    
    
    
    //        List转DataStream
            DataStream<Tuple3<String, Long,Timestamp>> ratesHistoryStream = env.fromCollection(ratesHistoryData);
    
    //        Table ratesHistory = tEnv.fromDataStream(ratesHistoryStream, "r_currency, r_rate,r_proctime.proctime");
    //        DataStream转Table
    
            Table ratesHistory = tEnv.fromDataStream(ratesHistoryStream, $("r_currency"), $("r_rate"), $("r_proctime").proctime());

     

    完整报错:

    Exception:
    
    Exception in thread "main" org.apache.flink.table.api.ValidationException: The proctime attribute can only be appended to the table schema and not replace an existing field. Please move 'proctime(r_proctime)' to the end of the schema.
    	at org.apache.flink.table.typeutils.FieldInfoUtils$IndexedExprToFieldInfo.validateProcTimeAttributeAppended(FieldInfoUtils.java:512)
    	at org.apache.flink.table.typeutils.FieldInfoUtils$IndexedExprToFieldInfo.visit(FieldInfoUtils.java:483)
    	at org.apache.flink.table.typeutils.FieldInfoUtils$IndexedExprToFieldInfo.visit(FieldInfoUtils.java:459)
    	at org.apache.flink.table.expressions.ApiExpressionVisitor.visit(ApiExpressionVisitor.java:39)
    	at org.apache.flink.table.expressions.UnresolvedCallExpression.accept(UnresolvedCallExpression.java:132)
    	at org.apache.flink.table.typeutils.FieldInfoUtils.lambda$extractFieldInfosFromTupleType$6(FieldInfoUtils.java:421)
    	at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
    	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
    	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
    	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    	at org.apache.flink.table.typeutils.FieldInfoUtils.extractFieldInfosFromTupleType(FieldInfoUtils.java:422)
    	at org.apache.flink.table.typeutils.FieldInfoUtils.extractFieldInformation(FieldInfoUtils.java:264)
    	at org.apache.flink.table.typeutils.FieldInfoUtils.getFieldsInfo(FieldInfoUtils.java:233)
    	at org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl.lambda$asQueryOperation$0(StreamTableEnvironmentImpl.java:384)
    	at java.util.Optional.map(Optional.java:215)
    	at org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl.asQueryOperation(StreamTableEnvironmentImpl.java:383)
    	at org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl.fromDataStream(StreamTableEnvironmentImpl.java:230)
    	at JoinwithTemporalTable.main(JoinwithTemporalTable.java:51)
    

    先讲下proctime和rowtime,根据文档[1]

    函数 代表的含义 完整案例示范
    proctime() Processing Time 完整案例
    rowtime() Event Time 完整案例

     

     

    注意哈,这个问题的解决方案你不能只看一句代码,需要看下前面你的数据。

    解决方案(rowtime方式):

    如果你想使用rowtime,也就是Event Time

    那么修改方案是:

            List<Tuple3<String,Long,Timestamp>>ratesHistoryData = new ArrayList<>();
            ratesHistoryData.add(Tuple3.of("US Dollar", 102L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 114L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Yen", 1L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 116L,new Timestamp(1L)));
            ratesHistoryData.add(Tuple3.of("Euro", 119L,new Timestamp(1L)));

    Table ratesHistory = tEnv.createTemporaryView("Orders", orderA,$("o_currency"),$("o_ratet"),$("o_proctime").rowtime());

     

    解决方案(proctime方式)

    如果你想使用proctime,也就是Processing Time

    那么修改方案是:

            DataStream<Tuple2<String, Long>> orderA = env.fromCollection(Arrays.asList(
                    Tuple2.of("US Dollar", 102L),
                    Tuple2.of("US Dollar", 102L),
                    Tuple2.of("US Dollar", 102L)));

            tableEnv.createTemporaryView("Orders", orderA, $("o_currency"), $("o_rate"), $("o_proctime").proctime());

     

    注意两点:

    ①这里的解决方案中我特意都提到了原始数据。

    因为这个报错是和原始数据息息相关的,你如果只盯着报错的那一句是不可能解决的。

    proctime的总列数=原始数据列数+1

    因为ProcessingTime是我们新加入的一列数据,你显然不能把数据里包含的原来的时间戳用proctime标记为ProcessingTime对吧?

    rowtime的总列数=原始数据列数

    这是因为,EventTime就来自数据本身,处理时自然不用新增一列。

     

     

    Reference:

    [1]Time Attributes

    [2]Apache Flink 进阶入门(二):Time 深度解析

    展开全文
  • <div><p>该提问来源于开源项目:tangdaohai/vue-happy-scroll</p></div>
  • Move Element to End问题,将数组中特定相同的数移动到最后 样例输入: arr = [2, 1, 2, 2, 2, 3, 4, 2] number_toMove = 2 把所有是2的值移动到数组的末尾,得到的结果为: [4, 1, 3, 2, 2, 2, 2, 2] solution 1: ...

    Move Element to End问题,将数组中特定相同的数移动到最后

    样例输入:

    arr = [2, 1, 2, 2, 2, 3, 4, 2]
    number_toMove = 2

    把所有是2的值移动到数组的末尾,得到的结果为:

    [4, 1, 3, 2, 2, 2, 2, 2]

    solution 1:

    指定两个分别指向头部和尾部的指针 A和B。假设需要换测数字是S

    While(A<B):

    ​ 如果A指向的数字和B指向的数字都=S。A不动,B前移一位

    ​ 如果A指向的数字 = S,B指向的数字!= S。发生交换,A后移一位,B前移一位

    ​ 如果A指向的数字 != S,B指向的数字= S。不交换,A后移一位,B不动

    ​ 如果A指向的数字和B指向的数字都!=S。A后移一位,B不动

    代码:

    #move element to end
    arr = [2, 1, 2, 2, 2, 3, 4, 2]
    number_toMove = 2
    
    def moveElementToEnd(array, number_toMove):
        # Write your code here.
        pointer_end = len(array)-1
        pointer_head = 0
        print(f'原始数组{array}')
        while(pointer_head<=pointer_end):
    
            if (array[pointer_end] != number_toMove) and (array[pointer_head] == number_toMove):
                print(f'指针为:{pointer_head} and {pointer_end}')
                print(f'指向数字:{array[pointer_head]} and {array[pointer_end]}')
                print('首指针指向目标数字,尾指针指向非目标数字需要交换')
                print(f'交换后的数组{array}')
                array[pointer_head],array[pointer_end] = array[pointer_end],array[pointer_head]
                pointer_head += 1
                pointer_end -=1
            elif (array[pointer_head] == number_toMove) and (array[pointer_end] == number_toMove):
                print(f'指针为:{pointer_head} and {pointer_end}')
                print(f'指向数字:{array[pointer_head]} and {array[pointer_end]}')
                print('二者相同,不需要交换')
                pointer_end -= 1
            elif (array[pointer_head] !=number_toMove) and (array[pointer_end]==number_toMove):
                
                print(f'指针为:{pointer_head} and {pointer_end}')
                print(f'指向数字:{array[pointer_head]} and {array[pointer_end]}')
                print(f'head指向非交换数字 不需要交换')
                pointer_head += 1
            else:
                pointer_head += 1
            print(f'本次循环后的数组{array}')
    
    
        return array
    
    print(moveElementToEnd(array = arr,number_toMove= number_toMove))
    

    Solution 2一种更简单的写法

    def moveElementToEnd_2(array, number_toMove):
        # 初始化两个指针
        A = 0
        B = len(array)-1
        while A<B:
            #让B移动到最近的可以和A交换的数字上
            while A<B and array[B] == number_toMove:
                B -= 1
            #此时跳出while循环意味着B指向的数字不是目标数字
            #如果A指向了目标数字
            if array[A] == number_toMove:
                #发生交换
                array[A], array[B] = array[B],array[A]
                #A向后一位
            A += 1
        return array
    
    

    solution 1: moveElementToEnd()输出:

    原始数组[2, 1, 2, 2, 2, 3, 4, 2]
    指针为:0 and 7
    指向数字:2 and 2
    二者相同,不需要交换
    本次循环后的数组[2, 1, 2, 2, 2, 3, 4, 2]
    指针为:0 and 6
    指向数字:2 and 4
    首指针指向目标数字,尾指针指向非目标数字需要交换
    交换后的数组[2, 1, 2, 2, 2, 3, 4, 2]
    本次循环后的数组[4, 1, 2, 2, 2, 3, 2, 2]
    本次循环后的数组[4, 1, 2, 2, 2, 3, 2, 2]
    指针为:2 and 5
    指向数字:2 and 3
    首指针指向目标数字,尾指针指向非目标数字需要交换
    交换后的数组[4, 1, 2, 2, 2, 3, 2, 2]
    本次循环后的数组[4, 1, 3, 2, 2, 2, 2, 2]
    指针为:3 and 4
    指向数字:2 and 2
    二者相同,不需要交换
    本次循环后的数组[4, 1, 3, 2, 2, 2, 2, 2]
    指针为:3 and 3
    指向数字:2 and 2
    二者相同,不需要交换
    本次循环后的数组[4, 1, 3, 2, 2, 2, 2, 2]
    [4, 1, 3, 2, 2, 2, 2, 2]
    [Finished in 0.4s]
    

    solution 2 输出:

    [4, 1, 3, 2, 2, 2, 2, 2]
    

    复杂度分析:

    两种算法:

    时间复杂度为O(n)

    空间复杂度为O(1)

    展开全文
  • Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after ca...

    Move Zeroes

    Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.

    For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].

    Note:
    You must do this in-place without making a copy of the array.
    Minimize the total number of operations.

    Remove Element

    Given an array nums and a value val, remove all instances of that value in-place and return the new length.

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    The order of elements can be changed. It doesn’t matter what you leave beyond the new length.

    Example 1:

    Given nums = [3,2,2,3], val = 3,

    Your function should return length = 2, with the first two elements of nums being 2.

    It doesn’t matter what you leave beyond the returned length.
    Example 2:

    Given nums = [0,1,2,2,3,0,4,2], val = 2,

    Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.

    Note that the order of those five elements can be arbitrary.

    It doesn’t matter what values are set beyond the returned length.
    Clarification:

    Confused why the returned value is an integer but your answer is an array?

    Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.

    Internally you can think of this:

    // nums is passed in by reference. (i.e., without making a copy)
    int len = removeElement(nums, val);

    // any modification to nums in your function would be known by the caller.
    // using the length returned by your function, it prints the first len elements.
    for (int i = 0; i < len; i++) {
    print(nums[i]);
    }

    思路:
    1、一开始想用一个指针来解决这个问题,发现有点困难,后来采用两个指针的方式,一个指针指向每个元素,另一个指向移动后的新元素。

    class Solution {
    public:
        int removeElement(vector<int>& nums, int val) {
            int count = 0;
            int j = 0;
            for (int i = 0; i < nums.size(); i++)
            {
                if (nums[i ] == val  )
                {
                    count++;
                }
                else
                {
                    nums[j] = nums[i];
                    j++;
                }
            }
            cout << endl << count;
            nums.erase(nums.end()-count, nums.end());
    
            for(int i = 0; i < nums.size() ; i++)
                cout << nums[i] << "-";
            return  nums.size();
        }
    };
    展开全文
  • 最近做了一个数据采集服务器, 根据程序的框架,使用了大量的指针结构体(内存块) 操作。 例子: PArrayByte = ^TArrayByte; TArrayByte = packed record ABinding: Pointer; data: TBytes;... end...

    最近做了一个数据采集服务器, 根据程序的框架,使用了大量的指针结构体(内存块) 操作。

    例子:

      PArrayByte = ^TArrayByte;
      TArrayByte = packed record
        ABinding: Pointer;
        data: TBytes;
        len: integer;
        IP: string[15];
        Port: UINT;
      end;

    //数据解析函数

    function GetGuiyue(ABuffer: PArrayByte): Boolean; stdcall; external 'Guiyue.dll';

     //数据采集函数:

    function GetCommand(ABuffer: PArrayByte): Boolean;

    var

        P: PArrayByte;

    begin

      try

        new(P);

        //指针传递

        Move(ABuffer,P, Sizeof(ABuffer));  //可以将数据复制到P, ABuffer 和 P 指向同一个内存区 , ABuffer = $29580D0 ,ip= '192.168.1.132',P = $29580D0

        CopyMemory(P,ABuffer, Sizeof(ABuffer));  //可以将数据复制到P, ABuffer 和 P 指向同一个内存区 , ABuffer = $29580D0 ,ip= '192.16'######,P = $29580D0 数据复制不全,数据块长度不够

        执行出错,应该是 CopyMemory(@P,@ABuffer, Sizeof(ABuffer)); 

       //复制内存块

        Move(ABuffer,P, Sizeof(TArrayByte); //可以将数据复制到P, ABuffer 和 P 指向不同的内存区 , ABuffer = $5FFFFFF, ip= Inaccessible value, P = $29580D0

        执行出错,应该是:Move(ABuffer^,P^, Sizeof(TArrayByte);

        CopyMemory(P,ABuffer, Sizeof(TArrayByte));  //可以将数据复制到P, ABuffer 和 P 指向不同的内存区 , ABuffer = $29580D0 ,ip= '192.168.1.132',P = $24680D0  

       PArrayByte(P)^.ip := '113.140.88.*';  //数据处理

       GetGuiyue(P);  //数据解析

       所以使用指针传递 复制数据 要在数据处理函数进行指针释放 Dispose(P);

        finally

           Dispose(P);  //使用内存块复制数据,释放数据源指针  $24680D0  

        end; 

    end;

    //数据解析

    function GetGuiyue(ABuffer: PArrayByte): Boolean; stdcall;

    var

        myBuffer: TBytes;

    begin

       try

          CopyMemory(@myBuffer[0],@ABuffer^.data[0], ABuffer^.len)        

           .............//数据处理

       except

      end;

    end;        

    转载于:https://www.cnblogs.com/wxy8/archive/2011/06/22/2086703.html

    展开全文
  • 我使用的是mac mini,用的普通windows键盘,习惯了Home键是跳到行首,End键是跳到行尾。但sublime是默认是跟的系统设置,也是就用command+left command+right修改方法:Preferences-&gt;Key Bindings在右侧User...
  • scott@PRIMARY> begin 2 dbms_stats.gather_table_stats('SCOTT','HEAP_ADDRESSES',cascade=>true); 3 end; 4...
  • 题目:https://leetcode.com/problems/move-zeroes/ 题目很简单,代码如下: class Solution { public: void moveZeroes(vector& nums) { int counts=0; for (vector::iterator i=nums.begin();...=nums.end
  • LeetCode_19:Move Zeroes

    2019-11-04 15:52:04
    1、总结 (1)由方法二方法四就可以看出来,处理问题的时候并不强求用一个节点解决...Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the n...
  • 视频原链接: CppCon 2019: Klaus Iglberger “Back to Basics: ...假设现在有两个vector变量,他们的start、finish、end_of_storage指向地址储存值如下图所示。 现在我们想将V1赋值给V2,并且期望赋值后的V2结构如
  • KSS_85_END_zh.pdf

    2020-07-09 16:08:03
    输入端无 $MOVE_ENABLE 停止 2 通过主开关关断电源或断 电 停止 0 机器人控制系统内与安全 无关的部件出现内部故障 停止 0 或停止 1 (取决于故障原因) 运行期间运行方式切换 安全停止 2 打开防护门 (操作人员防 ...
  • 经典贪吃蛇游戏的一个版本,用 Arduino、PS/2 键盘 Adafruits NeoPixel Sheild 制作 ============ 说明 完整的文章可以在找到 规则: 1. If the Snake goes off the screen, the game will end 2. If the Snake ...
  • C++ 11C++98相比有哪些新特性 ... 非成员begin和end 6. Lambda函数算法 7. Move/&& 8. 统一的初始化初始化列表 正文 此文是如下博文的翻译: https://herbsutter.com/eleme...
  • 写一函数实现以上功能,在主函数中输人n个整数输出调整后的n个数。 解题思路: 找出倒数第m个数据,从这里开始保存倒数第m位置的数据,因为倒数第m位置的数据要放到数组最前方,将m之前的数据向后偏移一位,然后...
  • Littlewolf的目标是成为一个非常简约的软件图形引擎,让人回想起id上Carmack的一些早期作品。 make; ./littlewolf 依存关系: SDL2-devel 控制项: move: W,A,S,D turn: H,L exit: END, ESCAPE
  • 1、tkinter文本实时更新滚动显示 主要加上这句e4.yview_moveto(1)就行 e4.insert("end", response.status_code) e4.insert("end", "++++++++++++++++") e4.insert("end", "\n\n") # 换行骚操作 ...
  • 分享系统 蓝色红色

    2014-05-04 17:04:39
    <!-- JiaThis Button BEGIN --> <script type="text/javascript" src="http://v2.jiathis.com/code/jiathis_r.js?type=left&move=0" charset="utf-8"> <!-- JiaThis Button END --> //蓝色
  • 它就像核心命令editor:move-to-end-of-word ,但一次只遍历一个非单词字符。 非单词字符 默认值是:/()"':,.;<>~!@#$%^&*|+=[]{}`?-,但它们可以在您的设置中更改,全局或每个语法。 指示 没有默认的键盘映射,...
  • Vim and its predecessor Vi are popular command-line based text editors. There is a lot of functionality that the text editor ... In this post, we will look at how to move cursor end of line and ...
  • 添加了逐步调试堆栈导航功能,以使用。 要使用,请正常调用撬。 无需以其他方式启动脚本或应用。 在binding.pry之后,执行将在第一条语句中停止。 def some_method puts 'Hello World' # Run 'step' in the ...
  • <template> <div> <... @touchmove="move" @touchend="end" >测试按钮 </button> </div> </template> <script> export default { name:"Bubble
  • 用C ++ 14现代OpenGL编写的具有SDL2的业余2D游戏引擎,并使用lua编写脚本 Lua脚本示例 Cerium支持的简单移动脚本 local speed = 100 -- Function running once, at start of game function init () end -- ...
  • @interface ViewController () @property (weak, nonatomic) IBOutlet UIButton *moveorigin;...- (IBAction)move:(UIButton *)sender; - (IBAction)change:(UIButton *)sender; @end @implementation ViewContro
  • 用javascript实现控制打开网页窗口的大小 HTML如何关闭窗口的技巧大全 打开窗口即最大化<...-- Beginself.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)// End --><...
  • Vue.directive('movable',{... let agent=window.navigator.userAgent.toLowerCase(),start,move,end //判断当前是移动端还是PC,移动端监听touch,PC监听mouse if(["android","iphone","symbianos","windows phon...
  • 在类中的声明: string(string&&) noexcept; string& operator=(string&&) noexcept; ...string::string(string &...s) noexcept : elements(s.elements), end(s.end) ... "move constructor" <
  • 快捷键 Editing KeypressCommand   Ctrl + ↩ Insert line after ...Ctrl + ⇧ + ↩ Insert ...Ctrl + J Join line below to the end of the current line    Ctrl + ⇧ + ↑ Move line/selection up Ctrl ...
  • cocos creator移动事件 opacity

    千次阅读 2017-04-06 16:43:40
    如果节点node在touch_move中有opacity的改变。在touch_end或者touch_cancel事件中,在还原的时候会出现一些问题。 出现问题的假设是该node有多个子节点,而子节点会随着父节点node的改变也会发生改变,这点很神奇,...
  • #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIButton *moving; - (IBAction)move; - (IBAction)rotate; - (IBAction)scale; - (IBAction)goback;...@end
  • 关于swallowsTouches [[CC sharedDispatcher] addTargetedDelegate:self priority:kCCMenuTouchPriority swallowsTouches:YES]; 如果 swallowsTouches:YES && touch begin return... 那么他的move 和end就接受,,别的

空空如也

空空如也

1 2 3 4 5 ... 16
收藏数 317
精华内容 126
关键字:

end和move