سریالسازی (رایانش)
From Wikipedia, the free encyclopedia
From Wikipedia, the free encyclopedia
پیاپیسازی یا سریالسازی (به انگلیسی: serialization) در علم رایانش، یک فرایند ترجمه است که در آن ساختمانهای داده، یا حالت شیء، به یک قالب (فرمت) ترجمه میشود که آن قالب توانایی ذخیره (مثلا در یک فایل) یا توانایی انتقال (مثلا در بین اتصال پیوند شبکه) برای بازساخت در آینده (احتمالا در یک محیط رایانهای متفاوت) را دارد.[1]
اطلاعات به صورت موقت در متغیرها و آرایهها ذخیره میشوند. زمانی که یک متغیر محلی از محدودهاش خارج میشود یا برنامه پایان میپذیرد، اطلاعات از بین میروند. اگر بخواهیم حجم بسیاری از اطلاعات را ذخیره کنیم، باید از فایل استفاده کنیم. کامپیوترها، فایلها را بر روی دستگاههای ذخیرهساز جانبی مانند دیسک سخت، دیسک نوری و نوارهای مغناطیسی ذخیره میکنند. پردازش فایل یکی از مهمترین تواناییهای یک زبان برنامهنویسی است و یک زیرمجموعه از پردازش فایل، پردازش جریان (جریان:اطلاعات مرتب شدهای که از یک فایل خوانده یا نوشته میشوند) است که به برنامه اجازه میدهد اطلاعات را در حافظه، در فایلها و از طریق اتصالات شبکهای بخواند و بنویسد. سریالسازی شیء هم یکی از انواع پردازش فایل است.[2]
گونههای اطلاعاتی که توسط کامپیوترها پردازش میشوند، سلسله مراتب اطلاعات را تشکیل میدهند و ساختار آنها با عبور از بیتها به کاراکترها و فیلدها بزرگتر و پیچیدهتر میشود. بهطور معمول یک رکورد دارای چند فیلد است.
مثال: در یک برنامه پرداخت حقوق، رکورد یک کارمند میتواند فیلدهای زیر را داشتهباشد که نوع این فیلدها در پرانتز مشخص شدهاست.
بنابراین رکورد گروهی از فیلدهای مربوط به هم است.[2]
سیستم بانک اطلاعاتی یا پایگاه داده، بهطور عمومی یک سیستم کامپیوتری نگهداری رکوردها میباشد. بانک اطلاعاتی را میتوان به عنوان قفسه بایگانی الکترونیکی در نظر گرفت؛ که مخزنی برای فایل داده کامپیوتری است. کاربران سیستم میتوانند عملیات گوناگونی را بر روی این فایلها انجامدهند، مانند:
فرض کنید بخواهیم از یک شیء برای کسب اطلاعات رکوردی استفاده کنیم. اگر متغیرهای نمونه یک شیء، به فایلی روی دیسک ارسال شوند، اطلاعات خاصی مثل نوع هر متغیر از بین میرود. به عنوان مثال، اگر مقدار "۳" را از یک فایل بخوانیم، به هیچ روشی نمیتوانیم بفهمیم که این مقدار، یک مقدار نوع int است یا string؛ زیرا که بر روی دیسک فقط داده مشخص است نه اطلاعات مربوط به نوع آن. اگر برنامهای که میخواهد این داده را بخواند، بداند که آن داده به چه نوع شیء ای مربوط است، در آن صورت آن داده تنها از اشیایی از همان نوع خوانده میشود. بعضی اوقات ممکن است ندانیم که این داده چگونه در یک فایل ذخیره شدهاست؛ در این مواقع تمایل داریم همه شیء را از فایل بخوانیم و بنویسیم. بعضی از زبانهای برنامهنویسی این امکان را فراهم کردهاند که به آن سریالسازی شیء میگوییم. در واقع، در زمینه ذخیرهسازی داده، سریالسازی مرحله ترجمه داده ساختارها یا اشیا به قالبی است که قابل ذخیره کردن باشد و مجدداً بتواند در همان محیط یا محیط کامپیوتر دیگر بازسازی شود.[4] یک شیء سریالسازی شده، شیء ای است که به صورت دنبالهای از بایتها نمایش داده میشود که شامل داده آن شیء و اطلاعات مرتبط با نوع شیء و انواع دادههای ذخیرهشده در شیء است.
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.