About sliding window

Does anyone knows where to find sample code about implementing sliding window in java?
thz

You mean a splitter? Check out the turorial.

Similar Messages

  • Sliding Window Table Partitioning Problems with RANGE RIGHT, SPLIT, MERGE using Multiple File Groups

    There is misleading information in two system views (sys.data_spaces & sys.destination_data_spaces) about the physical location of data after a partitioning MERGE and before an INDEX REBUILD operation on a partitioned table. In SQL Server 2012 SP1 CU6,
    the script below (SQLCMD mode, set DataDrive  & LogDrive variables  for the runtime environment) will create a test database with file groups and files to support a partitioned table. The partition function and scheme spread the test data across
    4 files groups, an empty partition, file group and file are maintained at the start and end of the range. A problem occurs after the SWITCH and MERGE RANGE operations, the views sys.data_spaces & sys.destination_data_spaces show the logical, not the physical,
    location of data.
    --=================================================================================
    -- PartitionLabSetup_RangeRight.sql
    -- 001. Create test database
    -- 002. Add file groups and files
    -- 003. Create partition function and schema
    -- 004. Create and populate a test table
    --=================================================================================
    USE [master]
    GO
    -- 001 - Create Test Database
    :SETVAR DataDrive "D:\SQL\Data\"
    :SETVAR LogDrive "D:\SQL\Logs\"
    :SETVAR DatabaseName "workspace"
    :SETVAR TableName "TestTable"
    -- Drop if exists and create Database
    IF DATABASEPROPERTYEX(N'$(databasename)','Status') IS NOT NULL
    BEGIN
    ALTER DATABASE $(DatabaseName) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    DROP DATABASE $(DatabaseName)
    END
    CREATE DATABASE $(DatabaseName)
    ON
    ( NAME = $(DatabaseName)_data,
    FILENAME = N'$(DataDrive)$(DatabaseName)_data.mdf',
    SIZE = 10,
    MAXSIZE = 500,
    FILEGROWTH = 5 )
    LOG ON
    ( NAME = $(DatabaseName)_log,
    FILENAME = N'$(LogDrive)$(DatabaseName).ldf',
    SIZE = 5MB,
    MAXSIZE = 5000MB,
    FILEGROWTH = 5MB ) ;
    GO
    -- 002. Add file groups and files
    --:SETVAR DatabaseName "workspace"
    --:SETVAR TableName "TestTable"
    --:SETVAR DataDrive "D:\SQL\Data\"
    --:SETVAR LogDrive "D:\SQL\Logs\"
    DECLARE @nSQL NVARCHAR(2000) ;
    DECLARE @x INT = 1;
    WHILE @x <= 6
    BEGIN
    SELECT @nSQL =
    'ALTER DATABASE $(DatabaseName)
    ADD FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';
    ALTER DATABASE $(DatabaseName)
    ADD FILE
    NAME= ''$(TableName)_f' + CAST(@x AS CHAR(5)) + ''',
    FILENAME = ''$(DataDrive)\$(TableName)_f' + RTRIM(CAST(@x AS CHAR(5))) + '.ndf''
    TO FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';'
    EXEC sp_executeSQL @nSQL;
    SET @x = @x + 1;
    END
    -- 003. Create partition function and schema
    --:SETVAR TableName "TestTable"
    --:SETVAR DatabaseName "workspace"
    USE $(DatabaseName);
    CREATE PARTITION FUNCTION $(TableName)_func (int)
    AS RANGE RIGHT FOR VALUES
    0,
    15,
    30,
    45,
    60
    CREATE PARTITION SCHEME $(TableName)_scheme
    AS
    PARTITION $(TableName)_func
    TO
    $(TableName)_fg1,
    $(TableName)_fg2,
    $(TableName)_fg3,
    $(TableName)_fg4,
    $(TableName)_fg5,
    $(TableName)_fg6
    -- Create TestTable
    --:SETVAR TableName "TestTable"
    --:SETVAR BackupDrive "D:\SQL\Backups\"
    --:SETVAR DatabaseName "workspace"
    CREATE TABLE [dbo].$(TableName)(
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_scheme(Partition_PK)
    ) ON $(TableName)_scheme(Partition_PK)
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_GUID_PK] DEFAULT (newid()) FOR [GUID_PK]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateServer] DEFAULT (@@servername) FOR [CreateServer]
    -- 004. Create and populate a test table
    -- Load TestTable Data - Seconds 0-59 are used as the Partitoning Key
    --:SETVAR TableName "TestTable"
    SET NOCOUNT ON;
    DECLARE @Now DATETIME = GETDATE()
    WHILE @Now > DATEADD(minute,-1,GETDATE())
    BEGIN
    INSERT INTO [dbo].$(TableName)
    ([Partition_PK]
    ,[RandomNbr])
    VALUES
    DATEPART(second,GETDATE())
    ,ROUND((RAND() * 100),0)
    END
    -- Confirm table partitioning - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    --=================================================================================
    -- SECTION 2 - SWITCH OUT
    -- 001 - Create TestTableOut
    -- 002 - Switch out partition in range 0-14
    -- 003 - Merge range 0 -29
    -- 001. TestTableOut
    :SETVAR TableName "TestTable"
    IF OBJECT_ID('dbo.$(TableName)Out') IS NOT NULL
    DROP TABLE [dbo].[$(TableName)Out]
    CREATE TABLE [dbo].[$(TableName)Out](
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)Out] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_fg2;
    GO
    -- 002 - Switch out partition in range 0-14
    --:SETVAR TableName "TestTable"
    ALTER TABLE dbo.$(TableName)
    SWITCH PARTITION 2 TO dbo.$(TableName)Out;
    -- 003 - Merge range 0 - 29
    --:SETVAR TableName "TestTable"
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (15);
    -- Confirm table partitioning
    -- Original source of this query - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber  
    The table below shows the results of the ‘Confirm Table Partitioning’ query, before and after the MERGE.
    The T-SQL code below illustrates the problem.
    -- PartitionLab_RangeRight
    USE workspace;
    DROP TABLE dbo.TestTableOut;
    USE master;
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f3 ;
    -- ERROR
    --Msg 5042, Level 16, State 1, Line 1
    --The file 'TestTable_f3 ' cannot be removed because it is not empty.
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f2 ;
    -- Works surprisingly!!
    use workspace;
    ALTER INDEX [PK_TestTable] ON [dbo].[TestTable] REBUILD PARTITION = 2;
    --Msg 622, Level 16, State 3, Line 2
    --The filegroup "TestTable_fg2" has no files assigned to it. Tables, indexes, text columns, ntext columns, and image columns cannot be populated on this filegroup until a file is added.
    --The statement has been terminated.
    If you run ALTER INDEX REBUILD before trying to remove files from File Group 3, it works. Rerun the database setup script then the code below.
    -- RANGE RIGHT
    -- Rerun PartitionLabSetup_RangeRight.sql before the code below
    USE workspace;
    DROP TABLE dbo.TestTableOut;
    ALTER INDEX [PK_TestTable] ON [dbo].[TestTable] REBUILD PARTITION = 2;
    USE master;
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f3;
    -- Works as expected!!
    The file in File Group 2 appears to contain data but it can be dropped. Although the system views are reporting the data in File Group 2, it still physically resides in File Group 3 and isn’t moved until the index is rebuilt. The RANGE RIGHT function means
    the left file group (File Group 2) is retained when splitting ranges.
    RANGE LEFT would have retained the data in File Group 3 where it already resided, no INDEX REBUILD is necessary to effectively complete the MERGE operation. The script below implements the same partitioning strategy (data distribution between partitions)
    on the test table but uses different boundary definitions and RANGE LEFT.
    --=================================================================================
    -- PartitionLabSetup_RangeLeft.sql
    -- 001. Create test database
    -- 002. Add file groups and files
    -- 003. Create partition function and schema
    -- 004. Create and populate a test table
    --=================================================================================
    USE [master]
    GO
    -- 001 - Create Test Database
    :SETVAR DataDrive "D:\SQL\Data\"
    :SETVAR LogDrive "D:\SQL\Logs\"
    :SETVAR DatabaseName "workspace"
    :SETVAR TableName "TestTable"
    -- Drop if exists and create Database
    IF DATABASEPROPERTYEX(N'$(databasename)','Status') IS NOT NULL
    BEGIN
    ALTER DATABASE $(DatabaseName) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    DROP DATABASE $(DatabaseName)
    END
    CREATE DATABASE $(DatabaseName)
    ON
    ( NAME = $(DatabaseName)_data,
    FILENAME = N'$(DataDrive)$(DatabaseName)_data.mdf',
    SIZE = 10,
    MAXSIZE = 500,
    FILEGROWTH = 5 )
    LOG ON
    ( NAME = $(DatabaseName)_log,
    FILENAME = N'$(LogDrive)$(DatabaseName).ldf',
    SIZE = 5MB,
    MAXSIZE = 5000MB,
    FILEGROWTH = 5MB ) ;
    GO
    -- 002. Add file groups and files
    --:SETVAR DatabaseName "workspace"
    --:SETVAR TableName "TestTable"
    --:SETVAR DataDrive "D:\SQL\Data\"
    --:SETVAR LogDrive "D:\SQL\Logs\"
    DECLARE @nSQL NVARCHAR(2000) ;
    DECLARE @x INT = 1;
    WHILE @x <= 6
    BEGIN
    SELECT @nSQL =
    'ALTER DATABASE $(DatabaseName)
    ADD FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';
    ALTER DATABASE $(DatabaseName)
    ADD FILE
    NAME= ''$(TableName)_f' + CAST(@x AS CHAR(5)) + ''',
    FILENAME = ''$(DataDrive)\$(TableName)_f' + RTRIM(CAST(@x AS CHAR(5))) + '.ndf''
    TO FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';'
    EXEC sp_executeSQL @nSQL;
    SET @x = @x + 1;
    END
    -- 003. Create partition function and schema
    --:SETVAR TableName "TestTable"
    --:SETVAR DatabaseName "workspace"
    USE $(DatabaseName);
    CREATE PARTITION FUNCTION $(TableName)_func (int)
    AS RANGE LEFT FOR VALUES
    -1,
    14,
    29,
    44,
    59
    CREATE PARTITION SCHEME $(TableName)_scheme
    AS
    PARTITION $(TableName)_func
    TO
    $(TableName)_fg1,
    $(TableName)_fg2,
    $(TableName)_fg3,
    $(TableName)_fg4,
    $(TableName)_fg5,
    $(TableName)_fg6
    -- Create TestTable
    --:SETVAR TableName "TestTable"
    --:SETVAR BackupDrive "D:\SQL\Backups\"
    --:SETVAR DatabaseName "workspace"
    CREATE TABLE [dbo].$(TableName)(
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_scheme(Partition_PK)
    ) ON $(TableName)_scheme(Partition_PK)
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_GUID_PK] DEFAULT (newid()) FOR [GUID_PK]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateServer] DEFAULT (@@servername) FOR [CreateServer]
    -- 004. Create and populate a test table
    -- Load TestTable Data - Seconds 0-59 are used as the Partitoning Key
    --:SETVAR TableName "TestTable"
    SET NOCOUNT ON;
    DECLARE @Now DATETIME = GETDATE()
    WHILE @Now > DATEADD(minute,-1,GETDATE())
    BEGIN
    INSERT INTO [dbo].$(TableName)
    ([Partition_PK]
    ,[RandomNbr])
    VALUES
    DATEPART(second,GETDATE())
    ,ROUND((RAND() * 100),0)
    END
    -- Confirm table partitioning - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    --=================================================================================
    -- SECTION 2 - SWITCH OUT
    -- 001 - Create TestTableOut
    -- 002 - Switch out partition in range 0-14
    -- 003 - Merge range 0 -29
    -- 001. TestTableOut
    :SETVAR TableName "TestTable"
    IF OBJECT_ID('dbo.$(TableName)Out') IS NOT NULL
    DROP TABLE [dbo].[$(TableName)Out]
    CREATE TABLE [dbo].[$(TableName)Out](
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)Out] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_fg2;
    GO
    -- 002 - Switch out partition in range 0-14
    --:SETVAR TableName "TestTable"
    ALTER TABLE dbo.$(TableName)
    SWITCH PARTITION 2 TO dbo.$(TableName)Out;
    -- 003 - Merge range 0 - 29
    :SETVAR TableName "TestTable"
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (14);
    -- Confirm table partitioning
    -- Original source of this query - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    The table below shows the results of the ‘Confirm Table Partitioning’ query, before and after the MERGE.
    The data in the File and File Group to be dropped (File Group 2) has already been switched out; File Group 3 contains the data so no index rebuild is needed to move data and complete the MERGE.
    RANGE RIGHT would not be a problem in a ‘Sliding Window’ if the same file group is used for all partitions, when they are created and dropped it introduces a dependency on full index rebuilds. Larger tables are typically partitioned and a full index rebuild
    might be an expensive operation. I’m not sure how a RANGE RIGHT partitioning strategy could be implemented, with an ascending partitioning key, using multiple file groups without having to move data. Using a single file group (multiple files) for all partitions
    within a table would avoid physically moving data between file groups; no index rebuild would be necessary to complete a MERGE and system views would accurately reflect the physical location of data. 
    If a RANGE RIGHT partition function is used, the data is physically in the wrong file group after the MERGE assuming a typical ascending partitioning key, and the 'Data Spaces' system views might be misleading. Thanks to Manuj and Chris for a lot of help
    investigating this.
    NOTE 10/03/2014 - The solution
    The solution is so easy it's embarrassing, I was using the wrong boundary points for the MERGE (both RANGE LEFT & RANGE RIGHT) to get rid of historic data.
    -- Wrong Boundary Point Range Right
    --ALTER PARTITION FUNCTION $(TableName)_func()
    --MERGE RANGE (15);
    -- Wrong Boundary Point Range Left
    --ALTER PARTITION FUNCTION $(TableName)_func()
    --MERGE RANGE (14);
    -- Correct Boundary Pounts for MERGE
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (0); -- or -1 for RANGE LEFT
    The empty, switched out partition (on File Group 2) is then MERGED with the empty partition maintained at the start of the range and no data movement is necessary. I retract the suggestion that a problem exists with RANGE RIGHT Sliding Windows using multiple
    file groups and apologize :-)

    Hi Paul Brewer,
    Thanks for your post and glad to hear that the issue is resolved. It is kind of you post a reply to share your solution. That way, other community members could benefit from your sharing.
    Regards.
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Sliding window

    I have an interesting problem that I'd welcome some thoughts on.
    I need to track a proportion of success/failures in a sliding window of discrete events.
    In English :-) the user says "If at any time 7 out of the last 10 events were failures, let me know."
    Now this is easy enough to do with a circular buffer of booleans (for example). But I will potentially need to keep very many (x1000s) of these counters and the user parameters could get very big (like 900 out of 1000).
    Can anyone think of a more efficient way of doing this? My best idea so far involves the circular buffer - of bits, wrapped in an array of ints. This is workable but there must be a better way.
    Any and all replies welcome. Duke $$ for good or interesting suggestions ;-)

    Bugger
    Forgot to say a number of things about the algorithm I just posted. First - it is not linear therefore it only keeps an approximate track of failures.
    Second the normalised threshold weight should not be used as the trigger
    criteria as it assumes linear response (It tends to be too large as
    this algorithm produces an exponential decay). A better threshold value can be calculated by using the normalisedThreshold as a starting point and
    deriving a more appropriate value by multiplying it by approximatley 0.7. (Sorry can't remember why its 0.7 ish somthing to do with gaussians which this filter approximates quite accuratley.
    Third - I hadn't tried it so there were a few errors in it. Corrected code follows
    * ConditionCheck.java
    * Created on 02 July 2003, 23:34
    package org.fudge.TestCondition;
    * @author  Matthew Fudge copyright 2003
    public class ConditionCheck
        /** Creates a new instance of ConditionCheck */
        public ConditionCheck()
        private int numFailures = 0;
        private int windowSize = 0;
        private double oldCoeff = 0.0;
        private double newCoeff = 0.0;
        private double oldValue = 0.0;
        private double normalisedThreshold = 0.0;
    * set up the thing such that numFailures out of windowSize causes
    * notification
    public void setConditions(int numFailures, int windowSize)
      // do some sanity checks on parameters here
      this.numFailures = numFailures;
      this.windowSize = windowSize;
      // set up the multiplicative coefficients
      // for an argument of windowSize = 100 this creates
      // coefficients of 0.99 and 0.01 for old and new respectively
      this.oldCoeff = (1.0/(double)windowSize)*(windowSize-1);
      this.newCoeff = 1.0/(double)windowSize;
      // set up a new threshold such that if 80 out of 100 errors are
      // to be the threshold the value of normalisedThreshold is 0.8
      this.normalisedThreshold = (1.0/(double)windowSize)*numFailures;
      // see multiply by the mystic 0.7
      this.normalisedThreshold*=0.7;
    * tests if the condition has been met and returns true if so.
    * EventStatus should be passed as true if a failure has not occured
    * false if one has.
    * @return true if the condition is met (ie if 80 out of 100 errors
    * are found) false otherwise
    public boolean conditionTriggered(boolean eventStatus)
       double newValue = 1.0;
       if(eventStatus == true) newValue = 0.0;
       // do the funcky math basicly for 80 out of 100 errors
       // we multiply the oldValue by 0.99 and the new value by 0.01
       this.oldValue = (this.oldValue*this.oldCoeff)+(newValue*this.newCoeff);
        // now check if value is equal to or greater then 0.8 (for the
        // example arguments)
       System.out.println(oldValue);
       if(this.oldValue>=this.normalisedThreshold)
          return true;
       return false;
    }matfud

  • Sliding window compression, need some help

    hey, i'm doing a sliding window (LZ77) compression project in java and am trying to figure out if there is already an object in java i can use for the sliding window itself, basically a queue, any help would be greally appreciated, thanks in advance, also any comments on this algorithm would be welcome

    How about an ArrayList (or Vector)? Queue with add(Object), dequeue with remove(0)

  • Advice on which Mac laptop to buy / Advice about using WIndows on it.

    I'd appreciate some advice on which replacement laptop to get for someone in my family who just needs e-mail, the Internet, and iPhoto--something simple, small, and portable, like the iBook or the MacBook Combo. However, he has just complicated matters by saying that he'd like to be able to use Windows on his new computer (yech).
    I don't know anything about using Windows on a Mac, not even whether this feature is now built into all Macs or not. A recent post I found on virtualization (February, 2006) quotes Microsoft as saying that Virtual PC won't run on an Intel-based Mac (MacBook), though it will on the iBook and the Powerbook.
    Here are the questions I'm trying to answer: (a) Is running Windows on the MacBook Combo an issue? If Microsoft doesn't make virtualization for the MacBook, are there other companies who do? (b) Are there features/lack of features on a MacBook that mean it makes more sense to get the least-expensive iBook instead or vice-versa? Again, simplicity and ease of use are the goal here, not state-of-the-art technology. (c) Can you even buy a new iBook or Powerbook any more, since the Apple website seems to feature only the MacBook?
    Thanks in advance for suggestions about any of this!
    Powerbook G4   Mac OS X (10.3.9)   15"

    For what your
    family member want to do the 1.83GHz MacBook will be
    just fine. Just be aware that if they want to write
    DVDs at any time they will have to purchase an
    external DVD writer.
    As for Windows, there are two options for running
    Windows on a …
    1) Use Apple's software, Boot Camp…
    http://www.apple.com/macosx/bootcamp/
    … which provides the ability to use you MacBook as a
    Windows computer. Please note that a restart will be
    required and only one OS will be available at any one
    time. Additionally it is suggested that at least a
    20GB larger drive be purchased to accomodate the
    Windows partition.
    2) Use Parallels…
    http://www.parallels.com/
    … which uses Virtualisation Technology. This allows
    Windows to be used under Mac OS X just like Virtual
    PC did with the PowerPC Macs. While this is far more
    convenient it's performance does not match that of
    Boot Camp although it is still rather snappy for more
    requirements. It does vost money where Boot Camp is
    free. Again, a larger drive is recommended.
    For both Parallels and Boot Camp Windows will operate
    at native PC speeds so do not consider an iBook or
    PowerBook.
    Thanks, that's helpful. One more question, now that I've looked at the MacBook more carefully: We use dial-up for e-mail and the Internet; this works very well for us and we have no immediate plans to change. Since the MacBook has no internal modem, would you or anyone else reading this say the Apple USB external modem works as advertised?
    I see that the Apple USB modem gets very mixed reviews--some people say it's fine, others seem to find it slower than the internal version, and several think it's a piece of junk.
    Would you (or anyone else reading this) have any experience using the Apple USB modem for dial-up connection? [That's not meant to be an insult. :-)] Would we now have to expect our dial-up connections to be slower than before? Or do we just have to be sure we have the right settings, compatible server, etc.? Or is the problem Apple's product, and would a 3rd-party product work better?
    Powerbook G4   Mac OS X (10.3.9)   15"

  • I dont know where to begin, what is a sliding window?

    The problem is to create a "smooth" image/"oil painting" image for a given image. You must create a GUI interface that include a menu which uses a JFileChooser to load/save an image file (a plain PGM file). The menu also include an exit menu item. The GUI should also include two radio buttons for smoothing/oil painting, and another group of radio buttons for choosing a sorting method. This group of buttons should have no effect if the smooth button is chosen. A text field should be included to enter the size of the sliding window. The GUI should also include a JScrollPane to display the log of processing time. My GUI looks like the following:
    In addition to your source code, you should also turn in a short report listing the experiments you perform and the processing times. You should run your code with different methods (4 methods) and window sizes ranging from (1 x 1) to (50 x 50). In your report, answer the following questions: Which one of the four methods gives the best running time for the (3 x 3) window? Which is the best for the (5 x 5) window? Which is the best for the (10 x 10) window? Which is the best for the (20 x 20) window? Which is the best for the (50 x 50) window? What is the maximal window size for which the processed image is still recognizable for the human eye?
    Here is how to proceed. Begin with the underlying classes. Develop each one with a main method for testing. As you finish one, move on to the next.
    1. Create a ImageProcess class that extends JFrame and includes all necessary GUI components.
    2. Create a SlidingWindow class that takes an image Array and an strategy object that implements Measurer :
    interface Measurer{
    int measure(Object m); //returns the measure of the object
    The class include a getNewGrayScale method that takes a pixel position of the new image and returns an integer value of the gray scale for that pixel, a setWindowSize method, and a setSortingMethod method.
    3. Two strategy classes ByAvg and ByMedian implements Measurer, one for calculating the average and one for finding the median of an array of integers. ByMedian class should include three sorting methods that implement sorting algorithms: quicksort, counting sort and insertion sort. Note: You may use the implementations of quicksort and insertion sort from your text book, but you must implement your own counting sort!
    4. The pgm (portable gray map) image format requires 4 entries followed by the greyscale values (some files include comments lines starting with the character #). The four entries are: the literal "P2", an integer representing the x dimension, an integer representing the y dimension, and an integer representing the maximum greyscale value. There should be x times y number of grey-level values after these 4 numbers. Part of a sample plain pgm image bug1.pgm is shown below. You may download a Java file to view the image. Caution: my code works very slowly for displaying large image files b/c it paints every pixel as a square. You get bonus points if you can solve the problem.
    P2
    # Created by IrfanView
    40 42
    255
    192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
    192 192 192 192 192 192 192 192 192 192 197 197 197 191 192 192
    5. The processing procedure works as follows. For each pixel of an image, the procedure considers an (n x n) window centered on that pixel, computes the mean/median of gray-level values in the window, and the mean/median becomes the new gray-level value of the new image. The median is defined as the middle value in a sorted sequence. For example, consider the following (3 x 3) window of pixels: 11 90 74 71 14 92 20 87 68. The sorted sequence of these pixels is <11, 14, 20, 68, 71, 74, 87, 90, 92>, and the middle of the sequence is 71, which is the median of the window. The median of the sequence <1,4,7,9> is (4+7)/2=5. The result of replacing all pixels with average values is a smoothed image. Using median values producing the oil painting effect. On the negative side, the new image is blurrier than the original. Corners and edges of the image need to be handled differently. For this project, for the boundary cases, the sliding window will be resized and include only the image pixels within the window.
    6. Display the image. Your image should be resizable, but the height and width ratio should remain fixed, i.e draw each pixel as a square. Extra credit: if you figure out how to directly display image of pgm format in Java.
    7. Programs to convert a file to pgm format: IrfanView, ImageMagick.
    Be sure to document every class and method (including the class supplied for you). Include a printed UML diagram for this project. Don't forget to check the documentation standards and include the signed cover sheet with your printed submission.

    i need code for connection b/n jsp and mysqlWTF has this got to do with this thread?

  • Does Verizon really care about the windows phones??

    I recently bought the Nokia 928 and as a "tech-impaired" person I am really happy with it. This is my second smart phone and I find it much easier to navigate than my Motorola Droid 3.   My co-worker (who is similarly impaired!) wanted to update to her first smart phone and had visited her local Verizon store to browse the various phones.  All that was EVER mentioned to her or shown were various Razrs, the Samsung Galaxies, and of course I-phones.  She saw the 928 demo phone there but it was never even offered as a choice so she didn't ask about it.  When she saw my phone she asked my thoughts, and asked to "play" with it.  I showed her some of the things she could do that I have found to be not difficult.  Bottom line she decided she liked the ease of operation, knew she did NOT need Suri and thought the Samsung Galaxy S 4 had way too many features for what she would ever need. She went back to the store and they did not even have a 928 in stock.  They did order her one, but she said that I knew way more about what the phone could do than anyone there.  I told her to ask about the 25 dollar gift certificate available through the end of June that could be used for Microsoft apps, they knew NOTHING about that either.  When I bought my phone I asked the store rep who was helping me (in a different town) and she was also unaware of it; but at least she found out and helped me set up a Microsoft account and got the certificate onto my phone.  She laughed and admitted she really knew very little about the Windows phone set up.  It really does seem that Verizon just doesn't care much about this platform and does not give their customers this choice since they virtually ignore that it even exists.

    Thats why I normally do not get involved with writing on message boards, especially corporate boards, too many company employees write comments like that on behalf of their office…and yes, cellular service and home communications services are a little more that a “soda” and yes, I do expect loyalty to be a two way street….end of thread, unsubscribed from this farce….

  • Sliding window sanario in PTF vs Availability of recently loaded data in the staging table for reporting purpose

    Hello everybody, I am a SQL server DBA and I am planning to implement table partitioning on some of our large tables in our data warehouse. I
    am thinking to design it using the sliding window scenario. I do have one concern though; I think the staging tables we use for new data loading and for switching out the old partition are going to be non-partitioned, right?? Well, I don't have an issue with
    the second staging table that is used for switching out the old partition. My concern is on the first staging table that we use it for switch in purpose, since this table is non-partitioned and holding the new data, HOW ARE WE GOING TO USE/access THIS DATA
    FOR REPORTING PURPOSE before we switch in to our target partitioned table????? say, this staging table is holding a one month worth of data and we will be switching it at the end of the month. Correct me if I am wrong okay, one way I can think of accessing
    this non-portioned staging table is by creating views, which we don’t want to change our codes.
    Do you guys share us your thoughts, experiences???
    We really appreciate your help.

    Hi BG516,
    According to your description, you need to implement table partitioning on some of our large tables in our data warehouse, the problem is that you need the partition table only hold a month data, please correct me if I have anything misunderstanding.
    In this case, you can create non-partitioned table, import the records which age is more than one month into the new created table. Leave the records which age is less than one month on the table in your data warehouse Then you need to create job to
    copy the data from partition table into non-partitioned table at the last day of each month. In this case, the partition table only contain the data for current month. Please refer to the link below to see the details.
    http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/
    https://msdn.microsoft.com/en-us/library/ms190268.aspx?f=255&MSPPError=-2147217396
    If this is not what you want, please provide us more information, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • I Need To Know Some Information About Installing Windows On A Macbook Pro 13

    Hello !
    Actually Playing My Favourite Games Is A Problem Because I Can't Find DVD Games (Mac Version) For My Macbook Pro So I Found Out That You Can Install Windows 7 Software On A Mac But I Wanted To Know Some Information Like :
    - I Know That I Can Install It Using Boot Camp But I'll Need A Windows 7 DVD So Is There Some Specialized Version For Mac ? Or I Just Need A Normal Windows 7 DVD For PC ?
    - If I Installed Windows 7, Will I Lose The Mac OS X Lion ? Or I Can Have Both Softwares Together At The Same Time ?
    - If I Installed Windows 7, Will It Have The Same Specifications Of Macbook Pro 13 ? (Ex: 2.4 GHz Processor)
    - If I Installed Windows 7 And I Already Had Mac OS X Lion, Will The Macbook Lag Or It Will Work Properly ?
    - If There's Any More Info That You Know About Installing Windows 7 On A Macbook Pro 13, Please Provide Me With It, Thanks!

    This really is a forum about the MacBook Pro hardware.  The best place to ask your questions would be the Windows/BootCamp forum.  Your MacBook Pro 13 has one weakness that's going to make gaming a bad experience.  It has an integrated Intel HD graphics processor, whereas the higher end MacBook Pro's have discrete ATI graphics processors.  But the forum will help you out. 

  • Sliding window for historical data purge in multiple related tables

    All,
    It is a well known question of how to efficiently BACKUP and PURGE historical data based on a sliding window.
    I have a group of tables, they all have to be backed up and purged based on a sliding time window. These tables have FKs related to each other and these FKs are not necessary the timestamp column. I am considering using partition based on the timestamp column for all these tables, so i can export those out of date partitions and then drop them. The price I have to pay by this design is that timestamp column is actually duplicated many times among parent table, child tables, grand-child tables although the value is the same, but I have to do the partition based on this column in all tables.
    It's very much alike the statspack tables, one stats$snapshot and many child tables to store actual statistic data. I am just wondering how statspack.purge does this, since using DELETE statement is very inefficient and time consuming. In statspack tables, snap_time is only stored in stats$snapshot table, not everywhere in it's child table, and they are not partitioned. I guess the procedure is using DELETE statement.
    Any thought on other good design options? Or how would you optimize statspack tables historical data backup and purge? Thanks!

    hey oracle gurus, any thoughts?

  • Get Information About Open Windows

    Hi everyone!!!!
    I'm trying to make some kind of bot, the primary Idea is to automatize tasks. To do this, it would be really usefull to have information about the windows that are open, for example, if I open the notepad, It has a title, width, height, 1 menu with file help, etc. and it also has 1 control inside, 1 text area with with, height, etc.
    So I know this can be done in Windows with the handler, I would like to know if there is a way to do this in JAVA and how.
    There's a software called AutoIt, that has a small program called AutoIt v3 Window Info. This software shows the info I need, using the Finder Tool, but I need to make my own.
    Thanks for any reply.
    Daniel

    Not in Java.
    You could possibly write some JNI that interfaces with the relevant MS Windows API,
    but that is no longer Java.

  • How may one cancel the download of an update that was started by having actuated the "Check for Updates" button in the "About Firefox" window, please?

    How may one cancel the download of an update that was started by having actuated the "Check for Updates" button in the "About Firefox" window, please? If possible please cover all platforms, Mac, Windows, Linux, although the first mentioned is what currently applies to my circumstances.
    Thank you.

    Such a download is usually saved in an updates or updated folder in the Firefox program/application folder.
    You can delete this folder to cancel the download.
    If files already have been downloaded then remove the files in the updates and updates\0 folder.
    *http://kb.mozillazine.org/Updates_reported_when_running_newest_version
    *http://kb.mozillazine.org/Software_Update
    Mac: /Applications/Firefox.app/updates "/path_to/Firefox.app/Updated.app"
    Linux: "/path_to/firefox/updated"
    Windows: C:\Users\&lt;user&gt;\AppData\Local\Mozilla\Firefox\Mozilla Firefox\updates

  • Microsoft opens up about more Windows 10 preview features in the works

    >>>
    Microsoft opens up about more Windows 10 preview features in the works
    Carey Frisch

    From that article:
    Belfiore did officially acknowledge some of the coming Windows 10 under-the-cover features that were disclosed early in a Microsoft blog post which was later pulled —such as the fact
    a Microsoft Account won't be required for login (users will be able to use Azure Active Directory for single sign-on instead).
    Is there seriously any possibility that a true local account won't be possible?
    That's "last straw" material.  Microsoft needs to be careful.
    -Noel
    Detailed how-to in my eBooks:  
    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options
    Linux is starting to be more appealing.

  • Doubt about webDynpro windows

    HI Experts,
    I have small doubt about webdynpro windows.
    1) If i have only one application in webdynpro DC , what is use of using multiple windows.
    2) If i have multiple windows in a DC which has single application, how i can i navigate between windows?
    3)if i have multiple applications with multiple windows, then how will i know which window belongs to which application.
    4)If i have multiple windows and multiple applications, then how can we navigate between windows? It means navigation betn windows and navigation betn applications...?
    Please explain me, i browsed in SDN, i found the threads but they are explaining my doubts exactly
    Thanks in advance.
    Regards,
    Bala

    Hi.
    Simply the Window is part of Web Dynpros public interfaces, and are needed whenever you want to access a graphic component from outside of your web dynpro component.
    Web Dynpro uses the MVC design pattern. Model View Control.
    In order to reuse components, Web Dynpro exposes the View and Controller to the outside world.
    Internally the View and Control in MVC is just that:
    Views
    Component Controller and Custom Controller.
    Externally the View and Control are exposed as
    Interface Controller and Interface Views. The Interface View is the external part of a Window. (When a Window is created, an associated Interface View is created).
    So, to be able to actually see anything from a Web Dynpro application. The browser would access a Interface View that opens the Window with some view in it.
    An other example is that you have two Web Dynpro projects, where the first one have a View with an integrated view from the second Web Dynpro. The integration would be through the Interface View again.
    Internally in your Web Dynpro component, you can use the views directly (i.e. navigate between views).
    Opening an external popup would generate a new browser window. In order for the new browser window to display anything it would need to access an interface view. That's why you need to create a separate Window when you want to use a popup.
    Regards.
    Edited by: Mikael Löwgren on Feb 15, 2008 12:58 PM

  • Want to upgrade to lastest version - help/about Firefox window does not show "upgrade" as in instructions.

    I want to upgrade to latest version but -Help/About Firefox- window does not show "upgrade" as in the instructions. I cannot find an "upgrade" function anywhere else. How do I upgrade? The version I have is -18.0.1- it came with this used computer.
    I believe this computer was hacked. Word started doing very strange things. We wiped the hard drive and reloaded everything as it was originally when I bought it. I am now getting hacked online.
    They originally got into one of my credit cards last fall. That is when this all started. They got my AOL email address. They also got the credit card current balance, minimum payment, due date and then even the payment amount. They got into my Barnes & Noble account and now checkout does not work. Now I believe they have gotten into my AOL account - one thing after another has started going wrong. I cannot change that AOL user id/email address since it is the master and I would lose about 15 years of "stuff".
    The folks that sold me this computer told me to use a free version of an antivirus. I am very unhappy with it. I never had ANY trouble when I used TrendMicro's expense products. Those folks also told me to use Firefox, since AOL uses Internet Explorer - which I already knew is like Swiss cheese.
    Now, I cannot seem to get an upgrade of Firefox. Is this also a hack?
    Please help any way you can. Thank you for your time.

    It's probably just the Firefox updater having some problems. go to www.getfirefox.com and download Firefox 20.0.1

Maybe you are looking for

  • Document-level Javascript as Object

    I created a document level script called Utility. I want to create methods within this script rather than coding each one separately. function Utility() this.getFormattedDateOnly=function(pDate) {   if (typeof pDate == "undefined") {     pDate = new

  • Persistent objects - base table syntax error

    I've created a persistent object for a ztable, then the customer has asked me to change the counter field from numc 3 to numc 5, and also remove a field  I've done this, and activated and adjusted the table in SE14. Now, in SE24, I've gone in and adj

  • .substring issues

    hi, i am learning java in class for school, and in my project i have one issue with the .substring method of strings. my code is import java.util.Scanner; public class Valid      private String lastName;      private String email;      private boolea

  • Craxdrt.dll Error : Application Error.

    Hi ,      we installed VB application on a windows 2003 server. Our Users runs this application and tries to run a report when they get the General Microsoft error. The terminal server is accessed from different location. Some body locally (toronto)a

  • Including rhis one, you have autorized one computer out of your available 4 , what is that mean?

    including rhis one, you have autorized one computer out of your available 4 , what is that mean?