public SSTSerializer(IntMapper strings, int numStrings, int numUniqueStrings)
        {
            this.strings      = strings;
            _numStrings       = numStrings;
            _numUniqueStrings = numUniqueStrings;

            int infoRecs = ExtSSTRecord.GetNumberOfInfoRecsForStrings(strings.Size);

            this.bucketAbsoluteOffsets = new int[infoRecs];
            this.bucketRelativeOffsets = new int[infoRecs];
        }
Exemple #2
0
        /**
         * Creates an extended string record based on the current contents of
         * the current SST record.  The offset within the stream to the SST record
         * Is required because the extended string record points directly to the
         * strings in the SST record.
         *
         * NOTE: THIS FUNCTION MUST ONLY BE CALLED AFTER THE SST RECORD HAS BEEN
         *       SERIALIZED.
         *
         * @param sstOffset     The offset in the stream to the start of the
         *                      SST record.
         * @return  The new SST record.
         */
        public ExtSSTRecord CreateExtSSTRecord(int sstOffset)
        {
            if (bucketAbsoluteOffsets == null || bucketAbsoluteOffsets == null)
            {
                throw new InvalidOperationException("SST record has not yet been Serialized.");
            }

            ExtSSTRecord extSST = new ExtSSTRecord();

            extSST.NumStringsPerBucket = ((short)8);
            int[] absoluteOffsets = (int[])bucketAbsoluteOffsets.Clone();
            int[] relativeOffsets = (int[])bucketRelativeOffsets.Clone();
            for (int i = 0; i < absoluteOffsets.Length; i++)
            {
                absoluteOffsets[i] += sstOffset;
            }
            extSST.SetBucketOffsets(absoluteOffsets, relativeOffsets);
            return(extSST);
        }
        /**
         * Creates the ExtendedSST record with numstrings per bucket Set to 0x8.  HSSF
         * doesn't yet know what to do with this thing, but we Create it with nothing in
         * it hardly just to make Excel happy and our sheets look like Excel's
         *
         * @return record containing an ExtSSTRecord
         * @see org.apache.poi.hssf.record.ExtSSTRecord
         * @see org.apache.poi.hssf.record.Record
         */

        private static Record CreateExtendedSST()
        {
            ExtSSTRecord retval = new ExtSSTRecord();

            retval.NumStringsPerBucket=((short)0x8);
            return retval;
        }
Exemple #4
0
        /**
         * Creates an extended string record based on the current contents of
         * the current SST record.  The offset within the stream to the SST record
         * Is required because the extended string record points directly to the
         * strings in the SST record.
         *
         * NOTE: THIS FUNCTION MUST ONLY BE CALLED AFTER THE SST RECORD HAS BEEN
         *       SERIALIZED.
         *
         * @param sstOffset     The offset in the stream to the start of the
         *                      SST record.
         * @return  The new SST record.
         */
        public ExtSSTRecord CreateExtSSTRecord(int sstOffset)
        {
            if (bucketAbsoluteOffsets == null || bucketAbsoluteOffsets == null)
                throw new InvalidOperationException("SST record has not yet been Serialized.");

            ExtSSTRecord extSST = new ExtSSTRecord();
            extSST.NumStringsPerBucket=((short)8);
            int[] absoluteOffsets = (int[])bucketAbsoluteOffsets.Clone();
            int[] relativeOffsets = (int[])bucketRelativeOffsets.Clone();
            for (int i = 0; i < absoluteOffsets.Length; i++)
                absoluteOffsets[i] += sstOffset;
            extSST.SetBucketOffsets(absoluteOffsets, relativeOffsets);
            return extSST;
        }
Exemple #5
0
 /**
  * Calculates the size in bytes of the EXTSST record as it would be if the
  * record was Serialized.
  *
  * @return  The size of the ExtSST record in bytes.
  */
 public int CalcExtSSTRecordSize()
 {
     return(ExtSSTRecord.GetRecordSizeForStrings(field_3_strings.Size));
 }
Exemple #6
0
        public void Test50967()
        {
            byte[] bytes = HexRead.ReadFromString(data_50967);

            RecordInputStream in1 = TestcaseRecordInputStream.Create(bytes);
            Assert.AreEqual(ExtSSTRecord.sid, in1.Sid);
            ExtSSTRecord src = new ExtSSTRecord(in1);
            Assert.AreEqual(12386, src.DataSize);
            InfoSubRecord[] sub1 = src.InfoSubRecords;

            byte[] Serialized = src.Serialize();

            in1 = TestcaseRecordInputStream.Create(Serialized);
            Assert.AreEqual(ExtSSTRecord.sid, in1.Sid);
            ExtSSTRecord dst = new ExtSSTRecord(in1);
            Assert.AreEqual(12386, dst.DataSize);
            InfoSubRecord[] sub2 = src.InfoSubRecords;
            Assert.AreEqual(sub1.Length, sub2.Length);

            for (int i = 0; i < sub1.Length; i++)
            {
                InfoSubRecord s1 = sub1[i];
                InfoSubRecord s2 = sub2[i];

                Assert.AreEqual(s1.BucketSSTOffset, s2.BucketSSTOffset);
                Assert.AreEqual(s1.StreamPos, s2.StreamPos);

            }
        }